1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-02 15:36:41 -05:00

fix tfo for darwin

This commit is contained in:
Darien Raymond 2018-09-10 21:47:24 +02:00
parent b9e4a4882c
commit 5d9dacc261
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 6 additions and 6 deletions

View File

@ -1,5 +1,3 @@
// +build darwin dragonfly freebsd netbsd openbsd
package internet package internet
import ( import (
@ -8,14 +6,16 @@ import (
) )
const ( 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 { func applyOutboundSocketOptions(network string, address string, fd uintptr, config *SocketConfig) error {
if strings.HasPrefix(network, "tcp") { if strings.HasPrefix(network, "tcp") {
switch config.Tfo { switch config.Tfo {
case SocketConfig_Enable: 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 return err
} }
case SocketConfig_Disable: case SocketConfig_Disable:
@ -32,7 +32,7 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
if strings.HasPrefix(network, "tcp") { if strings.HasPrefix(network, "tcp") {
switch config.Tfo { switch config.Tfo {
case SocketConfig_Enable: 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 return err
} }
case SocketConfig_Disable: case SocketConfig_Disable:

View File

@ -1,4 +1,4 @@
// +build js // +build js dragonfly freebsd netbsd openbsd
package internet package internet