From 0efa6449429b4ffa1fd1eafa6920d264884f7966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sun, 27 Sep 2026 17:16:25 +0800 Subject: [PATCH] Fix tun GSO check --- protocol/openconnect/endpoint.go | 5 ----- protocol/openvpn/endpoint.go | 4 ---- protocol/tun/inbound.go | 4 ++-- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/protocol/openconnect/endpoint.go b/protocol/openconnect/endpoint.go index 21999365..b7915c61 100644 --- a/protocol/openconnect/endpoint.go +++ b/protocol/openconnect/endpoint.go @@ -4,7 +4,6 @@ import ( "context" "net" "net/netip" - "slices" "strings" "github.com/sagernet/sing-box/adapter" @@ -33,10 +32,6 @@ type endpointBase struct { logger log.ContextLogger } -func (e *endpointBase) SupportsFlow(network string) bool { - return slices.Contains(e.Network(), network) -} - func (e *endpointBase) newConnection(ctx context.Context, endpoint adapter.Endpoint, localAddresses []netip.Prefix, conn net.Conn, source M.Socksaddr, destination M.Socksaddr, onClose N.CloseHandlerFunc) { var metadata adapter.InboundContext metadata.Inbound = endpoint.Tag() diff --git a/protocol/openvpn/endpoint.go b/protocol/openvpn/endpoint.go index 0aa7ff67..33cd43a1 100644 --- a/protocol/openvpn/endpoint.go +++ b/protocol/openvpn/endpoint.go @@ -38,10 +38,6 @@ type endpointBase struct { logger log.ContextLogger } -func (e *endpointBase) SupportsFlow(network string) bool { - return slices.Contains(e.Network(), network) -} - func (e *endpointBase) newConnection(ctx context.Context, endpoint adapter.Endpoint, localAddresses []netip.Prefix, conn net.Conn, source M.Socksaddr, destination M.Socksaddr, onClose N.CloseHandlerFunc) { var metadata adapter.InboundContext metadata.Inbound = endpoint.Tag() diff --git a/protocol/tun/inbound.go b/protocol/tun/inbound.go index 22172e50..719edd81 100644 --- a/protocol/tun/inbound.go +++ b/protocol/tun/inbound.go @@ -342,7 +342,7 @@ func (t *Inbound) Start(stage adapter.StartStage) error { outboundManager := service.FromContext[adapter.OutboundManager](t.ctx) endpointManager := service.FromContext[adapter.EndpointManager](t.ctx) for _, outbound := range outboundManager.Outbounds() { - if _, isFlowOutbound := outbound.(adapter.FlowOutbound); isFlowOutbound && common.Contains(outbound.Network(), N.NetworkTCP) { + if flowOutbound, isFlowOutbound := outbound.(adapter.FlowOutbound); isFlowOutbound && flowOutbound.PreMatchFlow(N.NetworkTCP, netip.Addr{}) == adapter.PreMatchFlow { if C.IsLinux { t.tunOptions.GSO = true } else { @@ -352,7 +352,7 @@ func (t *Inbound) Start(stage adapter.StartStage) error { } } for _, endpoint := range endpointManager.Endpoints() { - if _, isFlowOutbound := endpoint.(adapter.FlowOutbound); isFlowOutbound && common.Contains(endpoint.Network(), N.NetworkTCP) { + if flowOutbound, isFlowOutbound := endpoint.(adapter.FlowOutbound); isFlowOutbound && flowOutbound.PreMatchFlow(N.NetworkTCP, netip.Addr{}) == adapter.PreMatchFlow { if C.IsLinux { t.tunOptions.GSO = true } else {