chore(all): replace net.IP with netip.Addr
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user