|
|
@@ -1,7 +1,7 @@
|
|
|
package internet
|
|
|
|
|
|
import (
|
|
|
- "syscall"
|
|
|
+ "golang.org/x/sys/unix"
|
|
|
)
|
|
|
|
|
|
const (
|
|
|
@@ -18,20 +18,20 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
|
|
|
if isTCPSocket(network) {
|
|
|
switch config.Tfo {
|
|
|
case SocketConfig_Enable:
|
|
|
- if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, TCP_FASTOPEN, TCP_FASTOPEN_CLIENT); err != nil {
|
|
|
+ if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_FASTOPEN, unix.TCP_FASTOPEN_CLIENT); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
case SocketConfig_Disable:
|
|
|
- if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, TCP_FASTOPEN, 0); err != nil {
|
|
|
+ if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_FASTOPEN, 0); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if config.TcpKeepAliveInterval > 0 {
|
|
|
- if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, TCP_KEEPINTVL, int(config.TcpKeepAliveInterval)); err != nil {
|
|
|
+ if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_KEEPINTVL, int(config.TcpKeepAliveInterval)); err != nil {
|
|
|
return newError("failed to set TCP_KEEPINTVL", err)
|
|
|
}
|
|
|
- if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_KEEPALIVE, 1); err != nil {
|
|
|
+ if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_KEEPALIVE, 1); err != nil {
|
|
|
return newError("failed to set SO_KEEPALIVE", err)
|
|
|
}
|
|
|
}
|
|
|
@@ -44,19 +44,19 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
|
|
|
if isTCPSocket(network) {
|
|
|
switch config.Tfo {
|
|
|
case SocketConfig_Enable:
|
|
|
- if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, TCP_FASTOPEN, TCP_FASTOPEN_SERVER); err != nil {
|
|
|
+ if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_FASTOPEN, TCP_FASTOPEN_SERVER); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
case SocketConfig_Disable:
|
|
|
- if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, TCP_FASTOPEN, 0); err != nil {
|
|
|
+ if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_FASTOPEN, 0); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
if config.TcpKeepAliveInterval > 0 {
|
|
|
- if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, TCP_KEEPINTVL, int(config.TcpKeepAliveInterval)); err != nil {
|
|
|
+ if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_KEEPINTVL, int(config.TcpKeepAliveInterval)); err != nil {
|
|
|
return newError("failed to set TCP_KEEPINTVL", err)
|
|
|
}
|
|
|
- if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_KEEPALIVE, 1); err != nil {
|
|
|
+ if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_KEEPALIVE, 1); err != nil {
|
|
|
return newError("failed to set SO_KEEPALIVE", err)
|
|
|
}
|
|
|
}
|