1
0
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:
zhlsunshine 2022-10-25 16:39:23 +08:00
parent 6186106b99
commit e86a494a1a
2 changed files with 5 additions and 5 deletions

View File

@ -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
}

View File

@ -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
}