Skip to content

Commit

Permalink
fix: resolve_preference should only assign each ip once 2
Browse files Browse the repository at this point in the history
  • Loading branch information
tobyxdd committed Aug 13, 2022
1 parent 88099ee commit 944c0ec
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/transport/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 944c0ec

Please sign in to comment.