add profiling support

This commit is contained in:
Johannes Kimmel 2023-08-26 23:04:39 +02:00
parent be3f826fb0
commit cd9725276c
1 changed files with 10 additions and 0 deletions

10
main.go
View File

@ -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 {