mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
fix: prefer ipv6 not working
This commit is contained in:
parent
45cd046df8
commit
b2939ad863
|
@ -83,6 +83,7 @@ func resolveUDPAddrWithPrefer(ctx context.Context, network, address string, pref
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var ip netip.Addr
|
var ip netip.Addr
|
||||||
|
var fallback netip.Addr
|
||||||
switch prefer {
|
switch prefer {
|
||||||
case C.IPv4Only:
|
case C.IPv4Only:
|
||||||
ip, err = resolver.ResolveIPv4ProxyServerHost(ctx, host)
|
ip, err = resolver.ResolveIPv4ProxyServerHost(ctx, host)
|
||||||
|
@ -103,13 +104,11 @@ func resolveUDPAddrWithPrefer(ctx context.Context, network, address string, pref
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ip = fallback
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
// C.IPv4Prefer, C.DualStack and other
|
// C.IPv4Prefer, C.DualStack and other
|
||||||
var ips []netip.Addr
|
var ips []netip.Addr
|
||||||
ips, err = resolver.LookupIPProxyServerHost(ctx, host)
|
ips, err = resolver.LookupIPProxyServerHost(ctx, host)
|
||||||
var fallback netip.Addr
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
for _, addr := range ips {
|
for _, addr := range ips {
|
||||||
if addr.Is4() {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user