mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-12-04 12:26:41 +00:00
Fix pprof URL path
This commit is contained in:
parent
ea17c2786d
commit
46c8d6e61f
|
@ -5,6 +5,7 @@ import (
|
||||||
"net/http/pprof"
|
"net/http/pprof"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/sagernet/sing-box/common/badjson"
|
"github.com/sagernet/sing-box/common/badjson"
|
||||||
"github.com/sagernet/sing-box/common/humanize"
|
"github.com/sagernet/sing-box/common/humanize"
|
||||||
|
@ -47,12 +48,20 @@ func applyDebugListenOption(options option.DebugOptions) {
|
||||||
encoder.SetIndent("", " ")
|
encoder.SetIndent("", " ")
|
||||||
encoder.Encode(memObject)
|
encoder.Encode(memObject)
|
||||||
})
|
})
|
||||||
r.HandleFunc("/pprof", pprof.Index)
|
r.Route("/pprof", func(r chi.Router) {
|
||||||
r.HandleFunc("/pprof/*", pprof.Index)
|
r.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
|
||||||
r.HandleFunc("/pprof/cmdline", pprof.Cmdline)
|
if !strings.HasSuffix(request.URL.Path, "/") {
|
||||||
r.HandleFunc("/pprof/profile", pprof.Profile)
|
http.Redirect(writer, request, request.URL.Path+"/", http.StatusMovedPermanently)
|
||||||
r.HandleFunc("/pprof/symbol", pprof.Symbol)
|
} else {
|
||||||
r.HandleFunc("/pprof/trace", pprof.Trace)
|
pprof.Index(writer, request)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
r.HandleFunc("/*", pprof.Index)
|
||||||
|
r.HandleFunc("/cmdline", pprof.Cmdline)
|
||||||
|
r.HandleFunc("/profile", pprof.Profile)
|
||||||
|
r.HandleFunc("/symbol", pprof.Symbol)
|
||||||
|
r.HandleFunc("/trace", pprof.Trace)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
debugHTTPServer = &http.Server{
|
debugHTTPServer = &http.Server{
|
||||||
Addr: options.Listen,
|
Addr: options.Listen,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//go:build !linux
|
//go:build !(linux || darwin)
|
||||||
|
|
||||||
package box
|
package box
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
//go:build linux || darwin
|
||||||
|
|
||||||
package box
|
package box
|
||||||
|
|
||||||
import (
|
import (
|
Loading…
Reference in a new issue