github.com/yggdrasil-network/yggdrasil-go@v0.5.6/src/core/link_tcp_linux.go (about) 1 //go:build linux 2 // +build linux 3 4 package core 5 6 import ( 7 "syscall" 8 9 "golang.org/x/sys/unix" 10 ) 11 12 // WARNING: This context is used both by net.Dialer and net.Listen in tcp.go 13 14 func (t *linkTCP) tcpContext(network, address string, c syscall.RawConn) error { 15 return nil 16 } 17 18 func (t *linkTCP) getControl(sintf string) func(string, string, syscall.RawConn) error { 19 return func(network, address string, c syscall.RawConn) error { 20 var err error 21 btd := func(fd uintptr) { 22 err = unix.BindToDevice(int(fd), sintf) 23 } 24 _ = c.Control(btd) 25 if err != nil { 26 t.links.core.log.Debugln("Failed to set SO_BINDTODEVICE:", sintf) 27 } 28 return t.tcpContext(network, address, c) 29 } 30 }