From 7a406b991e46a67ac2d9a8e29ac407415a60b827 Mon Sep 17 00:00:00 2001 From: yaling888 <73897884+yaling888@users.noreply.github.com> Date: Wed, 18 May 2022 04:08:35 +0800 Subject: [PATCH] Fix: module clash-test --- test/clash_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/clash_test.go b/test/clash_test.go index ade2ed76..49c1466d 100644 --- a/test/clash_test.go +++ b/test/clash_test.go @@ -8,6 +8,7 @@ import ( "fmt" "io" "net" + "net/netip" "os" "path/filepath" "runtime" @@ -38,7 +39,7 @@ const ( var ( waitTime = time.Second - localIP = net.ParseIP("127.0.0.1") + localIP = netip.MustParseAddr("127.0.0.1") defaultExposedPorts = nat.PortSet{ "10002/tcp": struct{}{}, @@ -67,10 +68,11 @@ func init() { C.SetHomeDir(homeDir) if isDarwin { - localIP, err = defaultRouteIP() + routeIp, err := defaultRouteIP() if err != nil { panic(err) } + localIP = netip.MustParseAddr(routeIp.String()) } c, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) @@ -309,7 +311,7 @@ func testPingPongWithPacketConn(t *testing.T, pc net.PacketConn) error { } defer l.Close() - rAddr := &net.UDPAddr{IP: localIP, Port: 10001} + rAddr := &net.UDPAddr{IP: localIP.AsSlice(), Port: 10001} pingCh, pongCh, test := newPingPongPair() go func() { @@ -448,7 +450,7 @@ func testLargeDataWithPacketConn(t *testing.T, pc net.PacketConn) error { } defer l.Close() - rAddr := &net.UDPAddr{IP: localIP, Port: 10001} + rAddr := &net.UDPAddr{IP: localIP.AsSlice(), Port: 10001} times := 50 chunkSize := int64(1024)