2021-05-06 18:48:14 +00:00
|
|
|
package resolver
|
|
|
|
|
|
2023-05-20 19:58:18 +00:00
|
|
|
import (
|
|
|
|
|
"net/netip"
|
|
|
|
|
)
|
2021-05-06 18:48:14 +00:00
|
|
|
|
2023-05-20 19:58:18 +00:00
|
|
|
func uniqueIPsToSlice(uniqueIPs map[string]struct{}) (ips []netip.Addr) {
|
|
|
|
|
ips = make([]netip.Addr, 0, len(uniqueIPs))
|
2021-05-06 18:48:14 +00:00
|
|
|
for key := range uniqueIPs {
|
2023-05-20 19:58:18 +00:00
|
|
|
ip, err := netip.ParseAddr(key)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
2021-05-06 18:48:14 +00:00
|
|
|
}
|
2023-05-20 19:58:18 +00:00
|
|
|
if ip.Is4In6() {
|
|
|
|
|
ip = netip.AddrFrom4(ip.As4())
|
|
|
|
|
}
|
|
|
|
|
ips = append(ips, ip)
|
2021-05-06 18:48:14 +00:00
|
|
|
}
|
|
|
|
|
return ips
|
|
|
|
|
}
|