summaryrefslogtreecommitdiffhomepage
path: root/server/sockopt_linux.go
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2017-07-12 11:54:15 +0900
committerIWASE Yusuke <iwase.yusuke0@gmail.com>2017-07-18 15:11:05 +0900
commitc3d98dac4df7d55fc6aceb4558707f252bbbd765 (patch)
tree795c27dca84473172484c237209f67e60510b63b /server/sockopt_linux.go
parent178e65f8f113da82f8dfcc56b5fa7682da1bd932 (diff)
server: Set incoming TTL before accepting connection
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'server/sockopt_linux.go')
-rw-r--r--server/sockopt_linux.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/server/sockopt_linux.go b/server/sockopt_linux.go
index c251f8fd..3c347581 100644
--- a/server/sockopt_linux.go
+++ b/server/sockopt_linux.go
@@ -65,16 +65,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)
}
@@ -88,6 +83,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()