mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-01 09:32:08 +00:00
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:
committed by
Brad Fitzpatrick
parent
730ca4203c
commit
6a396731eb
@@ -18,6 +18,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/netip"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -830,7 +831,7 @@ func (n *testNode) AwaitIPs() []netaddr.IP {
|
||||
addrs = make([]netaddr.IP, len(ipslice))
|
||||
|
||||
for i, ip := range ipslice {
|
||||
netIP, err := netaddr.ParseIP(ip)
|
||||
netIP, err := netip.ParseAddr(ip)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/netip"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -859,7 +860,7 @@ func filterInvalidIPv6Endpoints(eps []string) []string {
|
||||
}
|
||||
|
||||
func keepClientEndpoint(ep string) bool {
|
||||
ipp, err := netaddr.ParseIPPort(ep)
|
||||
ipp, err := netip.ParseAddrPort(ep)
|
||||
if err != nil {
|
||||
// Shouldn't have made it this far if we unmarshalled
|
||||
// the incoming JSON response.
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/netip"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
@@ -240,5 +241,5 @@ outer:
|
||||
}
|
||||
|
||||
func bytes2Netaddr(inp []byte) netaddr.IP {
|
||||
return netaddr.MustParseIP(string(bytes.TrimSpace(inp)))
|
||||
return netip.MustParseAddr(string(bytes.TrimSpace(inp)))
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/netip"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -452,7 +453,7 @@ func (h *Harness) testDistro(t *testing.T, d Distro, ipm ipMapping) {
|
||||
t.Fatalf("can't get IP: %v", err)
|
||||
}
|
||||
|
||||
netaddr.MustParseIP(string(bytes.TrimSpace(ipBytes)))
|
||||
netip.MustParseAddr(string(bytes.TrimSpace(ipBytes)))
|
||||
})
|
||||
|
||||
t.Run("ping-"+tt.ipProto, func(t *testing.T) {
|
||||
|
||||
@@ -81,7 +81,7 @@ func (p *Packet) setLocator(msg string, args ...any) {
|
||||
}
|
||||
|
||||
func mustPrefix(s string) netaddr.IPPrefix {
|
||||
ipp, err := netaddr.ParseIPPrefix(s)
|
||||
ipp, err := netip.ParsePrefix(s)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -680,7 +680,7 @@ func (m *Machine) ListenPacket(ctx context.Context, network, address string) (ne
|
||||
return nil, err
|
||||
}
|
||||
if host != "" {
|
||||
ip, err = netaddr.ParseIP(host)
|
||||
ip, err = netip.ParseAddr(host)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -841,7 +841,7 @@ func (c *conn) ReadFrom(p []byte) (n int, addr net.Addr, err error) {
|
||||
}
|
||||
|
||||
func (c *conn) WriteTo(p []byte, addr net.Addr) (n int, err error) {
|
||||
ipp, err := netaddr.ParseIPPort(addr.String())
|
||||
ipp, err := netip.ParseAddrPort(addr.String())
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("bogus addr %T %q", addr, addr.String())
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ func testFirewall(t *testing.T, f *Firewall, tests []fwTest) {
|
||||
}
|
||||
|
||||
func ipp(str string) netaddr.IPPort {
|
||||
ipp, err := netaddr.ParseIPPort(str)
|
||||
ipp, err := netip.ParseAddrPort(str)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user