mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 15:36:41 -05:00
apply coding style for keep alive sockopt in freebsd
This commit is contained in:
parent
1a35c1dc69
commit
1a004529d9
@ -141,7 +141,7 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
|
||||
return newError("failed to set TCP_FASTOPEN_CONNECT=0").Base(err)
|
||||
}
|
||||
}
|
||||
if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 {
|
||||
|
||||
if config.TcpKeepAliveIdle > 0 {
|
||||
if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_KEEPIDLE, int(config.TcpKeepAliveIdle)); err != nil {
|
||||
return newError("failed to set TCP_KEEPIDLE").Base(err)
|
||||
@ -152,6 +152,7 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
|
||||
return newError("failed to set TCP_KEEPINTVL").Base(err)
|
||||
}
|
||||
}
|
||||
if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 {
|
||||
if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_KEEPALIVE, 1); err != nil {
|
||||
return newError("failed to set SO_KEEPALIVE").Base(err)
|
||||
}
|
||||
@ -203,7 +204,6 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
|
||||
return newError("failed to set TCP_FASTOPEN=0").Base(err)
|
||||
}
|
||||
}
|
||||
if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 {
|
||||
if config.TcpKeepAliveIdle > 0 {
|
||||
if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_KEEPIDLE, int(config.TcpKeepAliveIdle)); err != nil {
|
||||
return newError("failed to set TCP_KEEPIDLE").Base(err)
|
||||
@ -214,6 +214,7 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
|
||||
return newError("failed to set TCP_KEEPINTVL").Base(err)
|
||||
}
|
||||
}
|
||||
if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 {
|
||||
if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_KEEPALIVE, 1); err != nil {
|
||||
return newError("failed to set SO_KEEPALIVE").Base(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user