From 5d9dacc2614b7a74b46120c15157880be9072cdf Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Mon, 10 Sep 2018 21:47:24 +0200 Subject: [PATCH] fix tfo for darwin --- .../internet/{sockopt_unix.go => sockopt_darwin.go} | 10 +++++----- transport/internet/sockopt_other.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) rename transport/internet/{sockopt_unix.go => sockopt_darwin.go} (83%) diff --git a/transport/internet/sockopt_unix.go b/transport/internet/sockopt_darwin.go similarity index 83% rename from transport/internet/sockopt_unix.go rename to transport/internet/sockopt_darwin.go index bfc5a992a..7fb5eafec 100644 --- a/transport/internet/sockopt_unix.go +++ b/transport/internet/sockopt_darwin.go @@ -1,5 +1,3 @@ -// +build darwin dragonfly freebsd netbsd openbsd - package internet import ( @@ -8,14 +6,16 @@ import ( ) const ( - TCP_FASTOPEN = 0x105 + TCP_FASTOPEN = 0x105 + TCP_FASTOPEN_SERVER = 0x01 + TCP_FASTOPEN_CLIENT = 0x02 ) func applyOutboundSocketOptions(network string, address string, fd uintptr, config *SocketConfig) error { if strings.HasPrefix(network, "tcp") { switch config.Tfo { case SocketConfig_Enable: - if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, TCP_FASTOPEN, 1); err != nil { + if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, TCP_FASTOPEN, TCP_FASTOPEN_CLIENT); err != nil { return err } case SocketConfig_Disable: @@ -32,7 +32,7 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) if strings.HasPrefix(network, "tcp") { switch config.Tfo { case SocketConfig_Enable: - if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, TCP_FASTOPEN, 1); err != nil { + if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, TCP_FASTOPEN, TCP_FASTOPEN_SERVER); err != nil { return err } case SocketConfig_Disable: diff --git a/transport/internet/sockopt_other.go b/transport/internet/sockopt_other.go index 7a1266652..8a3b03326 100644 --- a/transport/internet/sockopt_other.go +++ b/transport/internet/sockopt_other.go @@ -1,4 +1,4 @@ -// +build js +// +build js dragonfly freebsd netbsd openbsd package internet