1
0
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:
Shelikhoo
2024-09-06 15:11:56 +01:00
committed by Xiaokang Wang (Shelikhoo)
parent 44a28de6f8
commit c5dcf1be03
2 changed files with 4 additions and 4 deletions

View 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)
}