Compare commits

...

2 Commits

1 changed files with 12 additions and 2 deletions

14
main.go
View File

@ -8,12 +8,15 @@ import (
"log"
"math"
"net"
"net/http"
"net/netip"
"sync"
"syscall"
_ "net/http/pprof"
"golang.org/x/net/ipv4"
"golang.org/x/net/ipv6"
"golang.org/x/sys/unix"
)
const (
@ -21,7 +24,7 @@ const (
)
var (
OOB_SIZE = unix.CmsgSpace(16 + 2) // ipv6 address + port
OOB_SIZE = syscall.CmsgSpace(syscall.SizeofInet6Pktinfo) // ipv6 address + iface index, struct in6_pktinfo
)
func (vx *vx46) transform46(msgs4 []ipv4.Message, msgs6 []ipv6.Message) error {
@ -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 {