mirror of
https://github.com/golang/go
synced 2024-11-21 22:14:41 -07:00
change code in LookupNetIP rather than AddrFromSlice
This commit is contained in:
parent
6186106b99
commit
e86a494a1a
@ -255,9 +255,11 @@ func (r *Resolver) LookupNetIP(ctx context.Context, network, host string) ([]net
|
||||
}
|
||||
ret := make([]netip.Addr, 0, len(ips))
|
||||
for _, ip := range ips {
|
||||
if a, ok := netip.AddrFromSlice(ip); ok {
|
||||
ret = append(ret, a)
|
||||
a, err := netip.ParseAddr(ip.String())
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
ret = append(ret, a)
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
@ -354,9 +354,7 @@ func AddrFromSlice(slice []byte) (ip Addr, ok bool) {
|
||||
case 4:
|
||||
return AddrFrom4(*(*[4]byte)(slice)), true
|
||||
case 16:
|
||||
ipAddr := ipv6Slice(slice)
|
||||
unwrapAddr := ipAddr.Unmap()
|
||||
return unwrapAddr, true
|
||||
return ipv6Slice(slice), true
|
||||
}
|
||||
return Addr{}, false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user