mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 09:18:34 +00:00
Add tcpKeepAliveInterval in transport sockopt (#754)
Co-authored-by: Ahmad Karimi <ak12hastam@gmail.com> Co-authored-by: Shelikhoo <xiaokangwang@outlook.com>
This commit is contained in:
parent
ef4c63812b
commit
4bb61701b5
4 changed files with 58 additions and 28 deletions
|
@ -57,6 +57,12 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
|
|||
return newError("failed to set TCP_FASTOPEN_CONNECT=", tfo).Base(err)
|
||||
}
|
||||
}
|
||||
|
||||
if config.TcpKeepAliveInterval != 0 {
|
||||
if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_KEEPINTVL, int(config.TcpKeepAliveInterval)); err != nil {
|
||||
return newError("failed to set TCP_KEEPINTVL", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if config.Tproxy.IsEnabled() {
|
||||
|
@ -81,6 +87,12 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
|
|||
return newError("failed to set TCP_FASTOPEN=", tfo).Base(err)
|
||||
}
|
||||
}
|
||||
|
||||
if config.TcpKeepAliveInterval != 0 {
|
||||
if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_KEEPINTVL, int(config.TcpKeepAliveInterval)); err != nil {
|
||||
return newError("failed to set TCP_KEEPINTVL", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if config.Tproxy.IsEnabled() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue