diff --git a/pkg/transport/resolve.go b/pkg/transport/resolve.go index dc7c76ef0d..601dd07240 100644 --- a/pkg/transport/resolve.go +++ b/pkg/transport/resolve.go @@ -39,9 +39,10 @@ func resolveIPAddrWithPreference(host string, pref ResolvePreference) (*net.IPAd var ip4, ip6 *net.IPAddr for i := range ips { ip := &ips[i] - if ip4 == nil && ip.IP.To4() != nil { + is4 := ip.IP.To4() != nil + if ip4 == nil && is4 { ip4 = ip - } else if ip6 == nil && ip.IP.To4() == nil { + } else if ip6 == nil && !is4 { ip6 = ip } if ip4 != nil && ip6 != nil {