mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-04 06:13:35 +03:00
Add SO_KEEPALIVE
This commit is contained in:
parent
6629d331fa
commit
3938c0be40
1 changed files with 6 additions and 0 deletions
|
@ -74,6 +74,9 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
|
|||
return errors.New("failed to set TCP_KEEPIDLE", err)
|
||||
}
|
||||
}
|
||||
if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.SOL_SOCKET, syscall.SO_KEEPALIVE, 1); err != nil {
|
||||
return errors.New("failed to set SO_KEEPALIVE", err)
|
||||
}
|
||||
} else if config.TcpKeepAliveInterval < 0 || config.TcpKeepAliveIdle < 0 {
|
||||
if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.SOL_SOCKET, syscall.SO_KEEPALIVE, 0); err != nil {
|
||||
return errors.New("failed to unset SO_KEEPALIVE", err)
|
||||
|
@ -100,6 +103,9 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
|
|||
return errors.New("failed to set TCP_KEEPIDLE", err)
|
||||
}
|
||||
}
|
||||
if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.SOL_SOCKET, syscall.SO_KEEPALIVE, 1); err != nil {
|
||||
return errors.New("failed to set SO_KEEPALIVE", err)
|
||||
}
|
||||
} else if config.TcpKeepAliveInterval < 0 || config.TcpKeepAliveIdle < 0 {
|
||||
if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.SOL_SOCKET, syscall.SO_KEEPALIVE, 0); err != nil {
|
||||
return errors.New("failed to unset SO_KEEPALIVE", err)
|
||||
|
|
Loading…
Add table
Reference in a new issue