Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Mautrix + deps & debug API #42

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Expose debug API with pprof
Runs along the provisioning API with same authentication.
hifi committed Dec 5, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 7dca2fb60289d29186468734617ca144faaf5792
5 changes: 3 additions & 2 deletions config/bridge.go
Original file line number Diff line number Diff line change
@@ -93,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"`
1 change: 1 addition & 0 deletions config/upgrade.go
Original file line number Diff line number Diff line change
@@ -96,6 +96,7 @@ func DoUpgrade(helper *up.Helper) {
} 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")
2 changes: 2 additions & 0 deletions example-config.yaml
Original file line number Diff line number Diff line change
@@ -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:
8 changes: 8 additions & 0 deletions provisioning.go
Original file line number Diff line number Diff line change
@@ -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
}