From cce42b4b83fc060cd53320748ea53998fd321d11 Mon Sep 17 00:00:00 2001 From: Skyxim Date: Fri, 25 Nov 2022 11:12:22 +0800 Subject: [PATCH] fix: prefer ipv6 not working --- adapter/outbound/util.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/adapter/outbound/util.go b/adapter/outbound/util.go index a3d88a4e..b322ba21 100644 --- a/adapter/outbound/util.go +++ b/adapter/outbound/util.go @@ -83,6 +83,7 @@ func resolveUDPAddrWithPrefer(ctx context.Context, network, address string, pref return nil, err } var ip netip.Addr + var fallback netip.Addr switch prefer { case C.IPv4Only: ip, err = resolver.ResolveIPv4ProxyServerHost(ctx, host) @@ -103,13 +104,11 @@ func resolveUDPAddrWithPrefer(ctx context.Context, network, address string, pref } } } - ip = fallback } default: // C.IPv4Prefer, C.DualStack and other var ips []netip.Addr ips, err = resolver.LookupIPProxyServerHost(ctx, host) - var fallback netip.Addr if err == nil { for _, addr := range ips { if addr.Is4() { @@ -122,12 +121,13 @@ func resolveUDPAddrWithPrefer(ctx context.Context, network, address string, pref } } - if !ip.IsValid() && fallback.IsValid() { - ip = fallback - } } } + if !ip.IsValid() && fallback.IsValid() { + ip = fallback + } + if err != nil { return nil, err }