github.com/slackhq/nebula@v1.9.0/udp/udp_android.go (about) 1 //go:build !e2e_testing 2 // +build !e2e_testing 3 4 package udp 5 6 import ( 7 "fmt" 8 "net" 9 "syscall" 10 11 "github.com/sirupsen/logrus" 12 "golang.org/x/sys/unix" 13 ) 14 15 func NewListener(l *logrus.Logger, ip net.IP, port int, multi bool, batch int) (Conn, error) { 16 return NewGenericListener(l, ip, port, multi, batch) 17 } 18 19 func NewListenConfig(multi bool) net.ListenConfig { 20 return net.ListenConfig{ 21 Control: func(network, address string, c syscall.RawConn) error { 22 if multi { 23 var controlErr error 24 err := c.Control(func(fd uintptr) { 25 if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, unix.SO_REUSEPORT, 1); err != nil { 26 controlErr = fmt.Errorf("SO_REUSEPORT failed: %v", err) 27 return 28 } 29 }) 30 if err != nil { 31 return err 32 } 33 if controlErr != nil { 34 return controlErr 35 } 36 } 37 return nil 38 }, 39 } 40 } 41 42 func (u *GenericConn) Rebind() error { 43 return nil 44 }