mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-04 16:37:12 -05:00
use sys/unix instead of syscall
Suggestion from: https://github.com/v2fly/v2ray-core/pull/1395#issuecomment-974761647
This commit is contained in:
parent
a47fcffe50
commit
718922b047
@ -5,20 +5,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// TCP_FASTOPEN is the socket option on darwin for TCP fast open.
|
|
||||||
TCP_FASTOPEN = 0x105 // nolint: revive,stylecheck
|
|
||||||
// TCP_FASTOPEN_SERVER is the value to enable TCP fast open on darwin for server connections.
|
// TCP_FASTOPEN_SERVER is the value to enable TCP fast open on darwin for server connections.
|
||||||
TCP_FASTOPEN_SERVER = 0x01 // nolint: revive,stylecheck
|
TCP_FASTOPEN_SERVER = 0x01 // nolint: revive,stylecheck
|
||||||
// TCP_FASTOPEN_CLIENT is the value to enable TCP fast open on darwin for client connections.
|
// TCP_FASTOPEN_CLIENT is the value to enable TCP fast open on darwin for client connections.
|
||||||
TCP_FASTOPEN_CLIENT = 0x02 // nolint: revive,stylecheck
|
TCP_FASTOPEN_CLIENT = 0x02 // nolint: revive,stylecheck
|
||||||
TCP_KEEPINTVL = 0x101 // nolint: golint,stylecheck
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func applyOutboundSocketOptions(network string, address string, fd uintptr, config *SocketConfig) error {
|
func applyOutboundSocketOptions(network string, address string, fd uintptr, config *SocketConfig) error {
|
||||||
if isTCPSocket(network) {
|
if isTCPSocket(network) {
|
||||||
switch config.Tfo {
|
switch config.Tfo {
|
||||||
case SocketConfig_Enable:
|
case SocketConfig_Enable:
|
||||||
if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_FASTOPEN, unix.TCP_FASTOPEN_CLIENT); err != nil {
|
if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_FASTOPEN, TCP_FASTOPEN_CLIENT); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
case SocketConfig_Disable:
|
case SocketConfig_Disable:
|
||||||
|
Loading…
Reference in New Issue
Block a user