diff --git a/config/bridge.go b/config/bridge.go index 0fed970..5436c10 100644 --- a/config/bridge.go +++ b/config/bridge.go @@ -80,9 +80,7 @@ type BridgeConfig struct { DefaultBridgeReceipts bool `yaml:"default_bridge_receipts"` DefaultBridgePresence bool `yaml:"default_bridge_presence"` - DoublePuppetServerMap map[string]string `yaml:"double_puppet_server_map"` - DoublePuppetAllowDiscovery bool `yaml:"double_puppet_allow_discovery"` - LoginSharedSecretMap map[string]string `yaml:"login_shared_secret_map"` + DoublePuppetConfig bridgeconfig.DoublePuppetConfig `yaml:",inline"` MessageHandlingTimeout struct { ErrorAfterStr string `yaml:"error_after"` @@ -95,8 +93,9 @@ type BridgeConfig struct { Encryption bridgeconfig.EncryptionConfig `yaml:"encryption"` Provisioning struct { - Prefix string `yaml:"prefix"` - SharedSecret string `yaml:"shared_secret"` + Prefix string `yaml:"prefix"` + SharedSecret string `yaml:"shared_secret"` + DebugEndpoints bool `yaml:"debug_endpoints"` } `yaml:"provisioning"` Permissions bridgeconfig.PermissionConfig `yaml:"permissions"` @@ -154,6 +153,10 @@ func (bc *BridgeConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { var _ bridgeconfig.BridgeConfig = (*BridgeConfig)(nil) +func (bc BridgeConfig) GetDoublePuppetConfig() bridgeconfig.DoublePuppetConfig { + return bc.DoublePuppetConfig +} + func (bc BridgeConfig) GetEncryptionConfig() bridgeconfig.EncryptionConfig { return bc.Encryption } diff --git a/config/config.go b/config/config.go index 0bd1906..0cdea2d 100644 --- a/config/config.go +++ b/config/config.go @@ -29,7 +29,7 @@ type Config struct { func (config *Config) CanAutoDoublePuppet(userID id.UserID) bool { _, homeserver, _ := userID.Parse() - _, hasSecret := config.Bridge.LoginSharedSecretMap[homeserver] + _, hasSecret := config.Bridge.DoublePuppetConfig.SharedSecretMap[homeserver] return hasSecret } diff --git a/config/upgrade.go b/config/upgrade.go index 8a952b4..e6d368a 100644 --- a/config/upgrade.go +++ b/config/upgrade.go @@ -17,9 +17,9 @@ package config import ( + up "go.mau.fi/util/configupgrade" + "go.mau.fi/util/random" "maunium.net/go/mautrix/bridge/bridgeconfig" - "maunium.net/go/mautrix/util" - up "maunium.net/go/mautrix/util/configupgrade" ) func DoUpgrade(helper *up.Helper) { @@ -50,7 +50,13 @@ func DoUpgrade(helper *up.Helper) { helper.Copy(up.Bool, "bridge", "default_bridge_presence") helper.Copy(up.Map, "bridge", "double_puppet_server_map") helper.Copy(up.Bool, "bridge", "double_puppet_allow_discovery") - helper.Copy(up.Map, "bridge", "login_shared_secret_map") + if legacySecret, ok := helper.Get(up.Str, "bridge", "login_shared_secret"); ok && len(legacySecret) > 0 { + baseNode := helper.GetBaseNode("bridge", "login_shared_secret_map") + baseNode.Map[helper.GetBase("homeserver", "domain")] = up.StringNode(legacySecret) + baseNode.UpdateContent() + } else { + helper.Copy(up.Map, "bridge", "login_shared_secret_map") + } helper.Copy(up.Map, "bridge", "message_handling_timeout") helper.Copy(up.Str, "bridge", "command_prefix") helper.Copy(up.Str, "bridge", "management_room_text", "welcome") @@ -85,11 +91,12 @@ func DoUpgrade(helper *up.Helper) { helper.Copy(up.Str, "bridge", "provisioning", "prefix") if secret, ok := helper.Get(up.Str, "bridge", "provisioning", "shared_secret"); !ok || secret == "generate" { - sharedSecret := util.RandomString(64) + sharedSecret := random.String(64) helper.Set(up.Str, sharedSecret, "bridge", "provisioning", "shared_secret") } else { helper.Copy(up.Str, "bridge", "provisioning", "shared_secret") } + helper.Copy(up.Bool, "bridge", "provisioning", "debug_endpoints") helper.Copy(up.Map, "bridge", "permissions") //helper.Copy(up.Bool, "bridge", "relay", "enabled") diff --git a/custompuppet.go b/custompuppet.go index 6785dd8..ae7baf6 100644 --- a/custompuppet.go +++ b/custompuppet.go @@ -44,11 +44,11 @@ func (br *SlackBridge) newDoublePuppetClient(mxid id.UserID, accessToken string) return nil, err } - homeserverURL, found := br.Config.Bridge.DoublePuppetServerMap[homeserver] + homeserverURL, found := br.Config.Bridge.DoublePuppetConfig.ServerMap[homeserver] if !found { if homeserver == br.AS.HomeserverDomain { homeserverURL = "" - } else if br.Config.Bridge.DoublePuppetAllowDiscovery { + } else if br.Config.Bridge.DoublePuppetConfig.AllowDiscovery { resp, err := mautrix.DiscoverClientAPI(homeserver) if err != nil { return nil, fmt.Errorf("failed to find homeserver URL for %s: %v", homeserver, err) @@ -173,7 +173,7 @@ func (puppet *Puppet) LoadRoom(_ id.RoomID) *mautrix.Room { // ///////////////////////////////////////////////////////////////////////////// // additional puppet api // ///////////////////////////////////////////////////////////////////////////// -func (puppet *Puppet) clearCustomMXID() { +func (puppet *Puppet) ClearCustomMXID() { puppet.CustomMXID = "" puppet.AccessToken = "" puppet.customIntent = nil @@ -204,14 +204,14 @@ func (puppet *Puppet) newCustomIntent() (*appservice.IntentAPI, error) { func (puppet *Puppet) StartCustomMXID(reloginOnFail bool) error { if puppet.CustomMXID == "" { - puppet.clearCustomMXID() + puppet.ClearCustomMXID() return nil } intent, err := puppet.newCustomIntent() if err != nil { - puppet.clearCustomMXID() + puppet.ClearCustomMXID() return err } @@ -219,14 +219,14 @@ func (puppet *Puppet) StartCustomMXID(reloginOnFail bool) error { resp, err := intent.Whoami() if err != nil { if !reloginOnFail || (errors.Is(err, mautrix.MUnknownToken) && !puppet.tryRelogin(err, "initializing double puppeting")) { - puppet.clearCustomMXID() + puppet.ClearCustomMXID() return err } intent.AccessToken = puppet.AccessToken } else if resp.UserID != puppet.CustomMXID { - puppet.clearCustomMXID() + puppet.ClearCustomMXID() return ErrMismatchingMXID } @@ -287,7 +287,7 @@ func (puppet *Puppet) loginWithSharedSecret(mxid id.UserID, teamID string) (stri puppet.log.Debugfln("Logging into %s with shared secret", mxid) - loginSecret := puppet.bridge.Config.Bridge.LoginSharedSecretMap[homeserver] + loginSecret := puppet.bridge.Config.Bridge.DoublePuppetConfig.SharedSecretMap[homeserver] client, err := puppet.bridge.newDoublePuppetClient(mxid, "") if err != nil { diff --git a/database/attachment.go b/database/attachment.go index 6d1112c..94f3028 100644 --- a/database/attachment.go +++ b/database/attachment.go @@ -22,8 +22,8 @@ import ( log "maunium.net/go/maulogger/v2" + "go.mau.fi/util/dbutil" "maunium.net/go/mautrix/id" - "maunium.net/go/mautrix/util/dbutil" ) type Attachment struct { diff --git a/database/backfill.go b/database/backfill.go index b3849c8..f4565d9 100644 --- a/database/backfill.go +++ b/database/backfill.go @@ -22,7 +22,7 @@ import ( log "maunium.net/go/maulogger/v2" - "maunium.net/go/mautrix/util/dbutil" + "go.mau.fi/util/dbutil" ) type BackfillQuery struct { diff --git a/database/database.go b/database/database.go index 94d5596..d853706 100644 --- a/database/database.go +++ b/database/database.go @@ -23,7 +23,7 @@ import ( _ "github.com/lib/pq" _ "github.com/mattn/go-sqlite3" - "maunium.net/go/mautrix/util/dbutil" + "go.mau.fi/util/dbutil" "go.mau.fi/mautrix-slack/database/upgrades" "maunium.net/go/maulogger/v2" diff --git a/database/emoji.go b/database/emoji.go index 14e23cb..fe5dbf1 100644 --- a/database/emoji.go +++ b/database/emoji.go @@ -5,8 +5,8 @@ import ( log "maunium.net/go/maulogger/v2" + "go.mau.fi/util/dbutil" "maunium.net/go/mautrix/id" - "maunium.net/go/mautrix/util/dbutil" ) type EmojiQuery struct { diff --git a/database/message.go b/database/message.go index 4e4138a..7643298 100644 --- a/database/message.go +++ b/database/message.go @@ -22,8 +22,8 @@ import ( log "maunium.net/go/maulogger/v2" + "go.mau.fi/util/dbutil" "maunium.net/go/mautrix/id" - "maunium.net/go/mautrix/util/dbutil" ) type Message struct { diff --git a/database/portal.go b/database/portal.go index 4b96d1a..6388107 100644 --- a/database/portal.go +++ b/database/portal.go @@ -21,8 +21,8 @@ import ( log "maunium.net/go/maulogger/v2" + "go.mau.fi/util/dbutil" "maunium.net/go/mautrix/id" - "maunium.net/go/mautrix/util/dbutil" ) type ChannelType int64 diff --git a/database/puppet.go b/database/puppet.go index 275d94d..abddf6a 100644 --- a/database/puppet.go +++ b/database/puppet.go @@ -21,8 +21,8 @@ import ( log "maunium.net/go/maulogger/v2" + "go.mau.fi/util/dbutil" "maunium.net/go/mautrix/id" - "maunium.net/go/mautrix/util/dbutil" ) const ( diff --git a/database/reaction.go b/database/reaction.go index d3bd19e..f502434 100644 --- a/database/reaction.go +++ b/database/reaction.go @@ -22,8 +22,8 @@ import ( log "maunium.net/go/maulogger/v2" + "go.mau.fi/util/dbutil" "maunium.net/go/mautrix/id" - "maunium.net/go/mautrix/util/dbutil" ) type Reaction struct { diff --git a/database/teaminfo.go b/database/teaminfo.go index a172dd1..2dd48cb 100644 --- a/database/teaminfo.go +++ b/database/teaminfo.go @@ -21,8 +21,8 @@ import ( log "maunium.net/go/maulogger/v2" + "go.mau.fi/util/dbutil" "maunium.net/go/mautrix/id" - "maunium.net/go/mautrix/util/dbutil" ) type TeamInfoQuery struct { diff --git a/database/upgrades/upgrades.go b/database/upgrades/upgrades.go index 38921a8..b630081 100644 --- a/database/upgrades/upgrades.go +++ b/database/upgrades/upgrades.go @@ -20,7 +20,7 @@ import ( "embed" "errors" - "maunium.net/go/mautrix/util/dbutil" + "go.mau.fi/util/dbutil" ) var Table dbutil.UpgradeTable diff --git a/database/user.go b/database/user.go index 1cbf2ff..23685fc 100644 --- a/database/user.go +++ b/database/user.go @@ -22,8 +22,8 @@ import ( log "maunium.net/go/maulogger/v2" + "go.mau.fi/util/dbutil" "maunium.net/go/mautrix/id" - "maunium.net/go/mautrix/util/dbutil" ) type User struct { diff --git a/database/userteam.go b/database/userteam.go index 244b5c7..b3dd37d 100644 --- a/database/userteam.go +++ b/database/userteam.go @@ -22,8 +22,8 @@ import ( log "maunium.net/go/maulogger/v2" + "go.mau.fi/util/dbutil" "maunium.net/go/mautrix/id" - "maunium.net/go/mautrix/util/dbutil" "github.com/slack-go/slack" ) diff --git a/example-config.yaml b/example-config.yaml index db7abde..a85939e 100644 --- a/example-config.yaml +++ b/example-config.yaml @@ -265,6 +265,8 @@ bridge: # Shared secret for authentication. If set to "generate", a random secret will be generated, # or if set to "disable", the provisioning API will be disabled. shared_secret: generate + # Enable debug API at /debug with provisioning authentication. + debug_endpoints: false # Permissions for using the bridge. # Permitted values: diff --git a/formatter.go b/formatter.go index a310429..47999f2 100644 --- a/formatter.go +++ b/formatter.go @@ -29,10 +29,10 @@ import ( "github.com/yuin/goldmark/text" goldmarkUtil "github.com/yuin/goldmark/util" "go.mau.fi/mautrix-slack/database" + "go.mau.fi/util/exmime" "maunium.net/go/mautrix/event" "maunium.net/go/mautrix/format" "maunium.net/go/mautrix/id" - "maunium.net/go/mautrix/util" ) var escapeFixer = regexp.MustCompile(`\\(__[^_]|\*\*[^*])`) @@ -79,7 +79,7 @@ func (portal *Portal) renderSlackFile(file slack.File) event.MessageEventContent content.Body = mimeClass } - content.Body += util.ExtensionFromMimetype(file.Mimetype) + content.Body += exmime.ExtensionFromMimetype(file.Mimetype) } if strings.HasPrefix(file.Mimetype, "image") { diff --git a/go.mod b/go.mod index f1aadd7..c402b5d 100644 --- a/go.mod +++ b/go.mod @@ -5,28 +5,30 @@ go 1.19 require ( github.com/gorilla/websocket v1.5.0 github.com/lib/pq v1.10.9 - github.com/mattn/go-sqlite3 v1.14.17 + github.com/mattn/go-sqlite3 v1.14.18 github.com/slack-go/slack v0.10.3 - github.com/yuin/goldmark v1.5.4 + github.com/yuin/goldmark v1.6.0 maunium.net/go/maulogger/v2 v2.4.1 - maunium.net/go/mautrix v0.15.4 + maunium.net/go/mautrix v0.16.2 ) +require go.mau.fi/util v0.2.1 + require ( github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/gorilla/mux v1.8.0 // indirect - github.com/mattn/go-colorable v0.1.12 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect - github.com/rs/zerolog v1.29.1 // indirect - github.com/tidwall/gjson v1.14.4 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect + github.com/rs/zerolog v1.31.0 // indirect + github.com/tidwall/gjson v1.17.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect github.com/tidwall/sjson v1.2.5 // indirect go.mau.fi/zeroconfig v0.1.2 // indirect - golang.org/x/crypto v0.11.0 // indirect - golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 - golang.org/x/net v0.12.0 // indirect - golang.org/x/sys v0.10.0 // indirect + golang.org/x/crypto v0.15.0 // indirect + golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa + golang.org/x/net v0.18.0 // indirect + golang.org/x/sys v0.14.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect maunium.net/go/mauflag v1.0.0 // indirect diff --git a/go.sum b/go.sum index a45c495..aad5991 100644 --- a/go.sum +++ b/go.sum @@ -17,43 +17,47 @@ github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWm github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM= -github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-sqlite3 v1.14.18 h1:JL0eqdCOq6DJVNPSvArO/bIV9/P7fbGrV00LZHc+5aI= +github.com/mattn/go-sqlite3 v1.14.18/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= -github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU= +github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= +github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= -github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM= +github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= -github.com/yuin/goldmark v1.5.4 h1:2uY/xC0roWy8IBEGLgB1ywIoEJFGmRrX21YQcvGZzjU= -github.com/yuin/goldmark v1.5.4/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yuin/goldmark v1.6.0 h1:boZcn2GTjpsynOsC0iJHnBWa4Bi0qzfJjthwauItG68= +github.com/yuin/goldmark v1.6.0/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.mau.fi/util v0.2.1 h1:eazulhFE/UmjOFtPrGg6zkF5YfAyiDzQb8ihLMbsPWw= +go.mau.fi/util v0.2.1/go.mod h1:MjlzCQEMzJ+G8RsPawHzpLB8rwTo3aPIjG5FzBvQT/c= go.mau.fi/zeroconfig v0.1.2 h1:DKOydWnhPMn65GbXZOafgkPm11BvFashZWLct0dGFto= go.mau.fi/zeroconfig v0.1.2/go.mod h1:NcSJkf180JT+1IId76PcMuLTNa1CzsFFZ0nBygIQM70= -golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= -golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= -golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xppfqWlA5ZT9OhtUUhTNw= -golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= -golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= -golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= -golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= +golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= +golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= +golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= +golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= +golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= +golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -65,5 +69,5 @@ maunium.net/go/mauflag v1.0.0 h1:YiaRc0tEI3toYtJMRIfjP+jklH45uDHtT80nUamyD4M= maunium.net/go/mauflag v1.0.0/go.mod h1:nLivPOpTpHnpzEh8jEdSL9UqO9+/KBJFmNRlwKfkPeA= maunium.net/go/maulogger/v2 v2.4.1 h1:N7zSdd0mZkB2m2JtFUsiGTQQAdP0YeFWT7YMc80yAL8= maunium.net/go/maulogger/v2 v2.4.1/go.mod h1:omPuYwYBILeVQobz8uO3XC8DIRuEb5rXYlQSuqrbCho= -maunium.net/go/mautrix v0.15.4 h1:Ug3n2Mo+9Yb94AjZTWJQSNHmShaksEzZi85EPl3S3P0= -maunium.net/go/mautrix v0.15.4/go.mod h1:dBaDmsnOOBM4a+gKcgefXH73pHGXm+MCJzCs1dXFgrw= +maunium.net/go/mautrix v0.16.2 h1:a6GUJXNWsTEOO8VE4dROBfCIfPp50mqaqzv7KPzChvg= +maunium.net/go/mautrix v0.16.2/go.mod h1:YL4l4rZB46/vj/ifRMEjcibbvHjgxHftOF1SgmruLu4= diff --git a/historysync.go b/historysync.go index 531c08d..03fb7d5 100644 --- a/historysync.go +++ b/historysync.go @@ -25,12 +25,12 @@ import ( "github.com/slack-go/slack" + "go.mau.fi/util/dbutil" "maunium.net/go/mautrix" "maunium.net/go/mautrix/appservice" "maunium.net/go/mautrix/bridge/bridgeconfig" "maunium.net/go/mautrix/event" "maunium.net/go/mautrix/id" - "maunium.net/go/mautrix/util/dbutil" "go.mau.fi/mautrix-slack/database" ) diff --git a/main.go b/main.go index daf0ad2..51d4bec 100644 --- a/main.go +++ b/main.go @@ -20,11 +20,11 @@ import ( _ "embed" "sync" + "go.mau.fi/util/configupgrade" "maunium.net/go/mautrix/bridge" "maunium.net/go/mautrix/bridge/commands" "maunium.net/go/mautrix/format" "maunium.net/go/mautrix/id" - "maunium.net/go/mautrix/util/configupgrade" "go.mau.fi/mautrix-slack/config" "go.mau.fi/mautrix-slack/database" diff --git a/portal.go b/portal.go index bc7a374..1f42ceb 100644 --- a/portal.go +++ b/portal.go @@ -32,13 +32,13 @@ import ( "github.com/slack-go/slack" + "go.mau.fi/util/dbutil" "maunium.net/go/mautrix" "maunium.net/go/mautrix/appservice" "maunium.net/go/mautrix/bridge" "maunium.net/go/mautrix/bridge/bridgeconfig" "maunium.net/go/mautrix/event" "maunium.net/go/mautrix/id" - "maunium.net/go/mautrix/util/dbutil" "go.mau.fi/mautrix-slack/config" "go.mau.fi/mautrix-slack/database" diff --git a/provisioning.go b/provisioning.go index 7619f94..82ca892 100644 --- a/provisioning.go +++ b/provisioning.go @@ -24,6 +24,7 @@ import ( "fmt" "net" "net/http" + _ "net/http/pprof" "net/url" "strings" "time" @@ -64,6 +65,13 @@ func newProvisioningAPI(br *SlackBridge) *ProvisioningAPI { p.bridge.AS.Router.HandleFunc("/_matrix/app/com.beeper.asmux/ping", p.BridgeStatePing).Methods(http.MethodPost) p.bridge.AS.Router.HandleFunc("/_matrix/app/com.beeper.bridge_state", p.BridgeStatePing).Methods(http.MethodPost) + if p.bridge.Config.Bridge.Provisioning.DebugEndpoints { + p.log.Debugln("Enabling debug API at /debug") + r := p.bridge.AS.Router.PathPrefix("/debug").Subrouter() + r.Use(p.authMiddleware) + r.PathPrefix("/pprof").Handler(http.DefaultServeMux) + } + return p }