From a2d40eb8b8f53f9c5059223a0d415e03f0a0f0fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Thu, 6 Feb 2025 11:20:18 +0800 Subject: [PATCH] Fix override UDP destination --- route/route.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/route/route.go b/route/route.go index bb29261c..bad7922b 100644 --- a/route/route.go +++ b/route/route.go @@ -489,12 +489,8 @@ match: break match } } - if !preMatch && inputPacketConn != nil && !metadata.Destination.IsFqdn() && !metadata.Destination.Addr.IsGlobalUnicast() { - var timeout time.Duration - if metadata.InboundType == C.TypeSOCKS { - timeout = C.TCPTimeout - } - newBuffer, newPacketBuffers, newErr := r.actionSniff(ctx, metadata, &rule.RuleActionSniff{Timeout: timeout}, inputConn, inputPacketConn) + if !preMatch && inputPacketConn != nil && (metadata.InboundType == C.TypeSOCKS || metadata.InboundType == C.TypeMixed) && !metadata.Destination.IsFqdn() && !metadata.Destination.Addr.IsGlobalUnicast() { + newBuffer, newPacketBuffers, newErr := r.actionSniff(ctx, metadata, &rule.RuleActionSniff{Timeout: C.TCPTimeout}, inputConn, inputPacketConn) if newErr != nil { fatalErr = newErr return @@ -590,7 +586,7 @@ func (r *Router) actionSniff( return } } else { - if !metadata.Destination.Addr.IsGlobalUnicast() { + if (metadata.InboundType == C.TypeSOCKS || metadata.InboundType == C.TypeMixed) && !metadata.Destination.IsFqdn() && !metadata.Destination.Addr.IsGlobalUnicast() { metadata.Destination = destination } if len(packetBuffers) > 0 {