1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-07-26 11:44:22 -04:00

Fix sockopt.TcpKeepAliveInterval

The Keep-Alive configs may be overridden with golang default settings when `tcpKeepAliveInterval` is set without `tcpKeepAliveIdle`.
Adopt: https://github.com/XTLS/Xray-core/pull/1328
This commit is contained in:
Cubarco 2022-11-11 14:42:57 +08:00 committed by Shelikhoo
parent 67c19f7054
commit c5386b88ad
No known key found for this signature in database
GPG Key ID: C4D5E79D22B25316
2 changed files with 2 additions and 2 deletions

View File

@ -64,7 +64,7 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne
}, nil
}
goStdKeepAlive := time.Duration(0)
if sockopt != nil && sockopt.TcpKeepAliveIdle != 0 {
if sockopt != nil && (sockopt.TcpKeepAliveInterval != 0 || sockopt.TcpKeepAliveIdle != 0) {
goStdKeepAlive = time.Duration(-1)
}
dialer := &net.Dialer{

View File

@ -50,7 +50,7 @@ func (dl *DefaultListener) Listen(ctx context.Context, addr net.Addr, sockopt *S
network = addr.Network()
address = addr.String()
lc.Control = getControlFunc(ctx, sockopt, dl.controllers)
if sockopt != nil && sockopt.TcpKeepAliveIdle != 0 {
if sockopt != nil && (sockopt.TcpKeepAliveInterval != 0 || sockopt.TcpKeepAliveIdle != 0) {
lc.KeepAlive = time.Duration(-1)
}
case *net.UnixAddr: