From 450cfedebaed30bcca7cf07b365a55b77df5c214 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 10 Nov 2020 09:11:21 -0800 Subject: [PATCH] wgengine/magicsock: quiet an IPv6 warning in tests In tests, we force binding to localhost to avoid OS firewall warning dialogs. But for IPv6, we were trying (and failing) to bind to 127.0.0.1. You'd think we'd just say "localhost", but that's apparently ill defined. See https://tools.ietf.org/html/draft-ietf-dnsop-let-localhost-be-localhost and golang/go#22826. (It's bitten me in the past, but I can't remember specific bugs.) So use "::1" explicitly for "udp6", which makes the test quieter. --- wgengine/magicsock/magicsock.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wgengine/magicsock/magicsock.go b/wgengine/magicsock/magicsock.go index e1d2b375f..09ead62d4 100644 --- a/wgengine/magicsock/magicsock.go +++ b/wgengine/magicsock/magicsock.go @@ -2492,6 +2492,9 @@ func (c *Conn) bind1(ruc **RebindingUDPConn, which string) error { host := "" if inTest() && !c.simulatedNetwork { host = "127.0.0.1" + if which == "udp6" { + host = "::1" + } } var pc net.PacketConn var err error