diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2017-07-12 11:54:15 +0900 |
---|---|---|
committer | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2017-07-18 15:11:05 +0900 |
commit | c3d98dac4df7d55fc6aceb4558707f252bbbd765 (patch) | |
tree | 795c27dca84473172484c237209f67e60510b63b /server/sockopt_openbsd.go | |
parent | 178e65f8f113da82f8dfcc56b5fa7682da1bd932 (diff) |
server: Set incoming TTL before accepting connection
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'server/sockopt_openbsd.go')
-rw-r--r-- | server/sockopt_openbsd.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/server/sockopt_openbsd.go b/server/sockopt_openbsd.go index 1adbaf94..5ce1b7ef 100644 --- a/server/sockopt_openbsd.go +++ b/server/sockopt_openbsd.go @@ -363,16 +363,11 @@ func setsockoptTcpMD5Sig(fd int, address string, key string) error { } func SetTcpMD5SigSockopt(l *net.TCPListener, address string, key string) error { - fi, err := l.File() + fi, _, err := extractFileAndFamilyFromTCPListener(l) defer fi.Close() if err != nil { return err } - fl, err := net.FileListener(fi) - defer fl.Close() - if err != nil { - return err - } return setsockoptTcpMD5Sig(int(fi.Fd()), address, key) } @@ -386,6 +381,15 @@ func setsockoptIpTtl(fd int, family int, value int) error { return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd, level, name, value)) } +func SetListenTcpTTLSockopt(l *net.TCPListener, ttl int) error { + fi, family, err := extractFileAndFamilyFromTCPListener(l) + defer fi.Close() + if err != nil { + return err + } + return setsockoptIpTtl(int(fi.Fd()), family, ttl) +} + func SetTcpTTLSockopt(conn *net.TCPConn, ttl int) error { fi, family, err := extractFileAndFamilyFromTCPConn(conn) defer fi.Close() |