diff --git a/protocol/vpn/server.go b/protocol/vpn/server.go index 966ab471..9ac0f645 100644 --- a/protocol/vpn/server.go +++ b/protocol/vpn/server.go @@ -126,18 +126,19 @@ func (s *ServerEndpoint) DialContext(ctx context.Context, network string, destin } } if gateway == nil { - if destination.IsIPv4() { + if s.defaultGateway != nil { + gateway = s.defaultGateway + } else if destination.IsIPv4() { gateway = &destination.Addr destination = M.Socksaddr{ Addr: Loopback, Port: destination.Port, } - } else if s.defaultGateway != nil { - gateway = s.defaultGateway } else { return nil, E.New("missing gateway") } - } else if destination.Addr.Compare(*gateway) == 0 { + } + if destination.Addr.Compare(*gateway) == 0 { destination = M.Socksaddr{ Addr: Loopback, Port: destination.Port,