net/netaddr: start migrating to net/netip via new netaddr adapter package

Updates #5162

Change-Id: Id7bdec303b25471f69d542f8ce43805328d56c12
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2022-07-24 20:08:42 -07:00
committed by Brad Fitzpatrick
parent 7b1a91dfd3
commit 7eaf5e509f
191 changed files with 1009 additions and 888 deletions

View File

@@ -12,7 +12,7 @@ import (
"strconv"
"strings"
"inet.af/netaddr"
"tailscale.com/net/netaddr"
"tailscale.com/types/netmap"
"tailscale.com/util/dnsname"
)
@@ -37,13 +37,13 @@ func dnsMapFromNetworkMap(nm *netmap.NetworkMap) dnsMap {
suffix := nm.MagicDNSSuffix()
have4 := false
if nm.Name != "" && len(nm.Addresses) > 0 {
ip := nm.Addresses[0].IP()
ip := nm.Addresses[0].Addr()
ret[canonMapKey(nm.Name)] = ip
if dnsname.HasSuffix(nm.Name, suffix) {
ret[canonMapKey(dnsname.TrimSuffix(nm.Name, suffix))] = ip
}
for _, a := range nm.Addresses {
if a.IP().Is4() {
if a.Addr().Is4() {
have4 = true
}
}
@@ -53,7 +53,7 @@ func dnsMapFromNetworkMap(nm *netmap.NetworkMap) dnsMap {
continue
}
for _, a := range p.Addresses {
ip := a.IP()
ip := a.Addr()
if ip.Is4() && !have4 {
continue
}
@@ -112,7 +112,7 @@ func (m dnsMap) resolveMemory(ctx context.Context, network, addr string) (_ neta
// Try MagicDNS first, otherwise a real DNS lookup.
ip := m[canonMapKey(host)]
if !ip.IsZero() {
if ip.IsValid() {
return netaddr.IPPortFrom(ip, port), nil
}