Update system_dialer.go

pull/4932/head
xqzr 2025-07-25 17:49:36 +08:00 committed by GitHub
parent 560704db35
commit 9b0a02f8e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package internet
import (
"context"
"math/rand"
gonet "net"
"syscall"
"time"
@ -87,14 +88,22 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne
Dest: destAddr,
}, nil
}
TCPKeepAlive := time.Duration(45)
TCPKeepAlive := time.Duration(1)
TCPKeepAliveConfig := gonet.KeepAliveConfig {
Enable: true,
Idle: 45 * time.Second,
Interval: 45 * time.Second,
Count: -1,
}
if sockopt != nil && (sockopt.TcpKeepAliveInterval != 0 || sockopt.TcpKeepAliveIdle != 0) {
TCPKeepAlive = time.Duration(-1)
TCPKeepAliveConfig.Enable = false
}
dialer := &net.Dialer{
Timeout: time.Second * 16,
LocalAddr: resolveSrcAddr(dest.Network, src),
KeepAlive: TCPKeepAlive,
KeepAliveConfig: TCPKeepAliveConfig,
}
if sockopt != nil || len(d.controllers) > 0 {