From 1df3c8d02a145debfde78d9341755fa7e86418d7 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 30 Mar 2020 11:29:08 -0700 Subject: [PATCH] derp, netcheck: make tests listen on localhost only avoid macOS firewall pop-ups --- derp/derp_test.go | 2 +- netcheck/netcheck_test.go | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/derp/derp_test.go b/derp/derp_test.go index 337a866c8..26cf81e55 100644 --- a/derp/derp_test.go +++ b/derp/derp_test.go @@ -42,7 +42,7 @@ func TestSendRecv(t *testing.T) { clientKeys = append(clientKeys, priv.Public()) } - ln, err := net.Listen("tcp", ":0") + ln, err := net.Listen("tcp", "127.0.0.1:0") if err != nil { t.Fatal(err) } diff --git a/netcheck/netcheck_test.go b/netcheck/netcheck_test.go index 0f58e5f3e..4eacd448f 100644 --- a/netcheck/netcheck_test.go +++ b/netcheck/netcheck_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net" "reflect" - "strings" "testing" "time" @@ -71,14 +70,13 @@ func TestBasic(t *testing.T) { } func TestWorksWhenUDPBlocked(t *testing.T) { - blackhole, err := net.ListenPacket("udp4", ":0") + blackhole, err := net.ListenPacket("udp4", "127.0.0.1:0") if err != nil { t.Fatalf("failed to open blackhole STUN listener: %v", err) } defer blackhole.Close() stunAddr := blackhole.LocalAddr().String() - stunAddr = strings.Replace(stunAddr, "0.0.0.0:", "127.0.0.1:", 1) c := &Client{ DERP: derpmap.NewTestWorld(stunAddr),