Expose debug API with pprof
Runs along the provisioning API with same authentication.
This commit is contained in:
parent
98d9fd5a95
commit
47fc0a19e2
4 changed files with 14 additions and 2 deletions
|
@ -68,6 +68,7 @@ type BridgeConfig struct {
|
||||||
Provisioning struct {
|
Provisioning struct {
|
||||||
Prefix string `yaml:"prefix"`
|
Prefix string `yaml:"prefix"`
|
||||||
SharedSecret string `yaml:"shared_secret"`
|
SharedSecret string `yaml:"shared_secret"`
|
||||||
|
DebugEndpoints bool `yaml:"debug_endpoints"`
|
||||||
} `yaml:"provisioning"`
|
} `yaml:"provisioning"`
|
||||||
|
|
||||||
Permissions bridgeconfig.PermissionConfig `yaml:"permissions"`
|
Permissions bridgeconfig.PermissionConfig `yaml:"permissions"`
|
||||||
|
|
|
@ -92,6 +92,7 @@ func DoUpgrade(helper *up.Helper) {
|
||||||
} else {
|
} else {
|
||||||
helper.Copy(up.Str, "bridge", "provisioning", "shared_secret")
|
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.Map, "bridge", "permissions")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -276,6 +276,8 @@ bridge:
|
||||||
# Shared secret for authentication. If set to "generate", a random secret will be generated,
|
# 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.
|
# or if set to "disable", the provisioning API will be disabled.
|
||||||
shared_secret: generate
|
shared_secret: generate
|
||||||
|
# Enable debug API at /debug with provisioning authentication.
|
||||||
|
debug_endpoints: false
|
||||||
|
|
||||||
# Permissions for using the bridge.
|
# Permissions for using the bridge.
|
||||||
# Permitted values:
|
# Permitted values:
|
||||||
|
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
_ "net/http/pprof"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -59,6 +60,13 @@ func (prov *ProvisioningAPI) Init() {
|
||||||
prov.bridge.AS.Router.HandleFunc("/_matrix/app/com.beeper.asmux/ping", prov.BridgeStatePing).Methods(http.MethodPost)
|
prov.bridge.AS.Router.HandleFunc("/_matrix/app/com.beeper.asmux/ping", prov.BridgeStatePing).Methods(http.MethodPost)
|
||||||
prov.bridge.AS.Router.HandleFunc("/_matrix/app/com.beeper.bridge_state", prov.BridgeStatePing).Methods(http.MethodPost)
|
prov.bridge.AS.Router.HandleFunc("/_matrix/app/com.beeper.bridge_state", prov.BridgeStatePing).Methods(http.MethodPost)
|
||||||
|
|
||||||
|
if prov.bridge.Config.Bridge.Provisioning.DebugEndpoints {
|
||||||
|
prov.zlog.Debug().Msg("Enabling debug API at /debug")
|
||||||
|
r := prov.bridge.AS.Router.PathPrefix("/debug").Subrouter()
|
||||||
|
r.Use(prov.AuthMiddleware)
|
||||||
|
r.PathPrefix("/pprof").Handler(http.DefaultServeMux)
|
||||||
|
}
|
||||||
|
|
||||||
// Deprecated, just use /disconnect
|
// Deprecated, just use /disconnect
|
||||||
r.HandleFunc("/v1/delete_connection", prov.Disconnect).Methods(http.MethodPost)
|
r.HandleFunc("/v1/delete_connection", prov.Disconnect).Methods(http.MethodPost)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue