Fix socks5 UDP implementation

This commit is contained in:
世界 2024-12-10 20:36:09 +08:00
parent 4d41f03bd5
commit d5e7af7a7e
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
5 changed files with 32 additions and 13 deletions

View file

@ -461,8 +461,12 @@ match:
break match
}
}
if !preMatch && metadata.Destination.Addr.IsUnspecified() {
newBuffer, newPacketBuffers, newErr := r.actionSniff(ctx, metadata, &rule.RuleActionSniff{}, inputConn, inputPacketConn)
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 newErr != nil {
fatalErr = newErr
return
@ -558,8 +562,7 @@ func (r *Router) actionSniff(
return
}
} else {
// TODO: maybe always override destination
if metadata.Destination.Addr.IsUnspecified() {
if !metadata.Destination.Addr.IsGlobalUnicast() {
metadata.Destination = destination
}
if len(packetBuffers) > 0 {