Fix DefaultGateway

This commit is contained in:
Shtorm
2026-08-08 20:43:13 +03:00
parent da4c532efb
commit 9f34cdb2f8

View File

@@ -126,18 +126,19 @@ func (s *ServerEndpoint) DialContext(ctx context.Context, network string, destin
} }
} }
if gateway == nil { if gateway == nil {
if destination.IsIPv4() { if s.defaultGateway != nil {
gateway = s.defaultGateway
} else if destination.IsIPv4() {
gateway = &destination.Addr gateway = &destination.Addr
destination = M.Socksaddr{ destination = M.Socksaddr{
Addr: Loopback, Addr: Loopback,
Port: destination.Port, Port: destination.Port,
} }
} else if s.defaultGateway != nil {
gateway = s.defaultGateway
} else { } else {
return nil, E.New("missing gateway") return nil, E.New("missing gateway")
} }
} else if destination.Addr.Compare(*gateway) == 0 { }
if destination.Addr.Compare(*gateway) == 0 {
destination = M.Socksaddr{ destination = M.Socksaddr{
Addr: Loopback, Addr: Loopback,
Port: destination.Port, Port: destination.Port,