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:
parent
b9e4a4882c
commit
5d9dacc261
@ -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:
|
@ -1,4 +1,4 @@
|
|||||||
// +build js
|
// +build js dragonfly freebsd netbsd openbsd
|
||||||
|
|
||||||
package internet
|
package internet
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user