diff options
Diffstat (limited to 'pkg/server/sockopt_linux.go')
-rw-r--r-- | pkg/server/sockopt_linux.go | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/pkg/server/sockopt_linux.go b/pkg/server/sockopt_linux.go index 203087ab..55d27bd4 100644 --- a/pkg/server/sockopt_linux.go +++ b/pkg/server/sockopt_linux.go @@ -70,13 +70,8 @@ func setTCPMD5SigSockopt(l *net.TCPListener, address string, key string) error { return setsockOptString(sc, syscall.IPPROTO_TCP, tcpMD5SIG, string(b[:])) } -func setListenTCPTTLSockopt(l *net.TCPListener, ttl int) error { - family := extractFamilyFromTCPListener(l) - sc, err := l.SyscallConn() - if err != nil { - return err - } - return setsockoptIpTtl(sc, family, ttl) +func setBindToDevSockopt(sc syscall.RawConn, device string) error { + return setsockOptString(sc, syscall.SOL_SOCKET, syscall.SO_BINDTODEVICE, device) } func setTCPTTLSockopt(conn *net.TCPConn, ttl int) error { @@ -162,14 +157,9 @@ func dialerControl(network, address string, c syscall.RawConn, ttl, minTtl uint8 } } if bindInterface != "" { - if err := c.Control(func(fd uintptr) { - sockerr = os.NewSyscallError("setsockopt", syscall.SetsockoptString(int(fd), syscall.SOL_SOCKET, syscall.SO_BINDTODEVICE, bindInterface)) - }); err != nil { + if err := setBindToDevSockopt(c, bindInterface); err != nil { return err } - if sockerr != nil { - return sockerr - } } return nil } |