From cd9725276c04ae014b397ff0e86073c23bc65267 Mon Sep 17 00:00:00 2001 From: Johannes Kimmel Date: Sat, 26 Aug 2023 23:04:39 +0200 Subject: [PATCH] add profiling support --- main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/main.go b/main.go index 4e7f1a6..4344720 100644 --- a/main.go +++ b/main.go @@ -8,10 +8,13 @@ import ( "log" "math" "net" + "net/http" "net/netip" "sync" "syscall" + _ "net/http/pprof" + "golang.org/x/net/ipv4" "golang.org/x/net/ipv6" ) @@ -270,6 +273,7 @@ func main() { portInt := flag.Int("port", 8472, "port for vxlan communication") mtuInt := flag.Uint("mtu", 1422, "buffer size") buffersInt := flag.Int("buffers", 64, "number of buffers for I/O batching") + pprofBool := flag.Bool("pprof", false, "enable pprof http endpoint on http://localhost:6060") flag.Parse() @@ -295,6 +299,12 @@ func main() { log.Fatalf("buffers < 1: %d", *mtuInt) } + if *pprofBool { + go func() { + log.Println(http.ListenAndServe("localhost:6060", nil)) + }() + } + if *buffersInt == 1 { log.Println(vx46forward(natprefix, upstreamAddr, port, mtu)) } else {