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