fix: resolve_preference not work

This commit is contained in:
Haruue Icymoon 2022-08-13 22:05:07 +08:00
parent 1b2eb49da1
commit 4747be198e
No known key found for this signature in database
GPG key ID: F6083B28CBCBC148

View file

@ -37,11 +37,15 @@ func resolveIPAddrWithPreference(host string, pref ResolvePreference) (*net.IPAd
return nil, err
}
var ip4, ip6 *net.IPAddr
for _, ip := range ips {
for i := range ips {
ip := &ips[i]
if ip.IP.To4() != nil {
ip4 = &ip
ip4 = ip
} else {
ip6 = &ip
ip6 = ip
}
if ip4 != nil && ip6 != nil {
break
}
}
switch pref {