From c5a171eeb8241cd09fcf78c9b440d166ffa15444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Fri, 25 Jul 2025 01:57:34 +0800 Subject: [PATCH] Update system_listener.go --- transport/internet/system_listener.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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)