chore(all): replace net.IP with netip.Addr

This commit is contained in:
Quentin McGaw
2023-05-20 19:58:18 +00:00
parent 00ee6ff9a7
commit 0a29337c3b
91 changed files with 525 additions and 590 deletions

View File

@@ -1,15 +1,20 @@
package resolver
import "net"
import (
"net/netip"
)
func uniqueIPsToSlice(uniqueIPs map[string]struct{}) (ips []net.IP) {
ips = make([]net.IP, 0, len(uniqueIPs))
func uniqueIPsToSlice(uniqueIPs map[string]struct{}) (ips []netip.Addr) {
ips = make([]netip.Addr, 0, len(uniqueIPs))
for key := range uniqueIPs {
IP := net.ParseIP(key)
if IPv4 := IP.To4(); IPv4 != nil {
IP = IPv4
ip, err := netip.ParseAddr(key)
if err != nil {
panic(err)
}
ips = append(ips, IP)
if ip.Is4In6() {
ip = netip.AddrFrom4(ip.As4())
}
ips = append(ips, ip)
}
return ips
}