Skip to content

Commit

Permalink
Fix override UDP destination
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Feb 6, 2025
1 parent 17b502b commit a2d40eb
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions route/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit a2d40eb

Please sign in to comment.