diff --git a/transport/internet/system_listener.go b/transport/internet/system_listener.go index 7f4d1f0c..ddb0bb50 100644 --- a/transport/internet/system_listener.go +++ b/transport/internet/system_listener.go @@ -2,12 +2,12 @@ package internet import ( "context" + gonet "net" "os" "runtime" "strconv" "strings" "syscall" - "time" "github.com/pires/go-proxyproto" "github.com/sagernet/sing/common/control" @@ -88,7 +88,13 @@ 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) - lc.KeepAlive = time.Duration(-1) + lc.KeepAliveConfig = gonet.KeepAliveConfig{ + // Set Enable to true but all other fields to -1 to use system defaults (see https://pkg.go.dev/net#KeepAliveConfig) + Enable: true, + Idle: -1, + Interval: -1, + Count: -1, + } if sockopt != nil { if sockopt.TcpMptcp { lc.SetMultipathTCP(true)