Skip to content

Commit

Permalink
wgengine/magicsock: quiet an IPv6 warning in tests
Browse files Browse the repository at this point in the history
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.

(cherry picked from commit 450cfed)
  • Loading branch information
bradfitz committed Nov 10, 2020
1 parent c73c300 commit d8a5311
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions wgengine/magicsock/magicsock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d8a5311

Please sign in to comment.