From 944c0ecf646324c0151b026a55752c23378b909c Mon Sep 17 00:00:00 2001 From: Toby Date: Sat, 13 Aug 2022 11:48:09 -0700 Subject: [PATCH] fix: resolve_preference should only assign each ip once 2 --- pkg/transport/resolve.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 {