mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-07-12 12:17:41 -04:00
Adjust default build set to remove pprof from default distribution
This commit is contained in:
committed by
Xiaokang Wang (Shelikhoo)
parent
44a28de6f8
commit
c5dcf1be03
29
main/plugins/plugin_pprof/plugin_pprof.go
Normal file
29
main/plugins/plugin_pprof/plugin_pprof.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package plugin_pprof
|
||||
|
||||
import (
|
||||
"github.com/v2fly/v2ray-core/v5/main/plugins"
|
||||
"net/http"
|
||||
"net/http/pprof"
|
||||
|
||||
"github.com/v2fly/v2ray-core/v5/main/commands/base"
|
||||
)
|
||||
|
||||
var pprofPlugin plugins.Plugin = func(cmd *base.Command) func() error {
|
||||
addr := cmd.Flag.String("pprof", "", "")
|
||||
return func() error {
|
||||
if *addr != "" {
|
||||
h := http.NewServeMux()
|
||||
h.HandleFunc("/debug/pprof/", pprof.Index)
|
||||
h.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
|
||||
h.HandleFunc("/debug/pprof/profile", pprof.Profile)
|
||||
h.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
|
||||
h.HandleFunc("/debug/pprof/trace", pprof.Trace)
|
||||
return (&http.Server{Addr: *addr, Handler: h}).ListenAndServe()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
plugins.RegisterPlugin(pprofPlugin)
|
||||
}
|
||||
Reference in New Issue
Block a user