all: use various net/netip parse funcs directly

Mechanical change with perl+goimports.

Changed {Must,}Parse{IP,IPPrefix,IPPort} to their netip variants, then
goimports -d .

Finally, removed the net/netaddr wrappers, to prevent future use.

Updates #5162

Change-Id: I59c0e38b5fbca5a935d701645789cddf3d7863ad
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2022-07-25 20:55:44 -07:00
committed by Brad Fitzpatrick
parent 730ca4203c
commit 6a396731eb
84 changed files with 401 additions and 355 deletions

View File

@ -9,6 +9,7 @@ import (
"errors"
"fmt"
"net"
"net/netip"
"strconv"
"strings"
@ -68,7 +69,7 @@ func dnsMapFromNetworkMap(nm *netmap.NetworkMap) dnsMap {
if rec.Type != "" {
continue
}
ip, err := netaddr.ParseIP(rec.Value)
ip, err := netip.ParseAddr(rec.Value)
if err != nil {
continue
}
@ -103,7 +104,7 @@ func (m dnsMap) resolveMemory(ctx context.Context, network, addr string) (_ neta
// addr malformed or invalid port.
return netaddr.IPPort{}, err
}
if ip, err := netaddr.ParseIP(host); err == nil {
if ip, err := netip.ParseAddr(host); err == nil {
// addr was literal ip:port.
return netaddr.IPPortFrom(ip, port), nil
}

View File

@ -5,6 +5,7 @@
package tsdial
import (
"net/netip"
"reflect"
"testing"
@ -14,8 +15,8 @@ import (
)
func TestDNSMapFromNetworkMap(t *testing.T) {
pfx := netaddr.MustParseIPPrefix
ip := netaddr.MustParseIP
pfx := netip.MustParsePrefix
ip := netip.MustParseAddr
tests := []struct {
name string
nm *netmap.NetworkMap

View File

@ -11,6 +11,7 @@ import (
"fmt"
"net"
"net/http"
"net/netip"
"runtime"
"strings"
"sync"
@ -330,7 +331,7 @@ func (d *Dialer) dialPeerAPI(ctx context.Context, network, addr string) (net.Con
default:
return nil, fmt.Errorf("peerAPI dial requires tcp; %q not supported", network)
}
ipp, err := netaddr.ParseIPPort(addr)
ipp, err := netip.ParseAddrPort(addr)
if err != nil {
return nil, fmt.Errorf("peerAPI dial requires ip:port, not name resolution: %w", err)
}