From 056fbee4eff539a564a6a380b1f035d3d1e2a91d Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 2 Jul 2020 09:53:10 -0700 Subject: [PATCH] wgengine/magicsock: add TS_DEBUG_OMIT_LOCAL_ADDRS knob to force STUN use only For debugging. --- wgengine/magicsock/magicsock.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wgengine/magicsock/magicsock.go b/wgengine/magicsock/magicsock.go index 2f124900f..d742283cd 100644 --- a/wgengine/magicsock/magicsock.go +++ b/wgengine/magicsock/magicsock.go @@ -562,6 +562,8 @@ func (c *Conn) goDerpConnect(node int) { go c.derpWriteChanOfAddr(netaddr.IPPort{IP: derpMagicIPAddr, Port: uint16(node)}, key.Public{}) } +var debugOmitLocalAddresses, _ = strconv.ParseBool(os.Getenv("TS_DEBUG_OMIT_LOCAL_ADDRS")) + // determineEndpoints returns the machine's endpoint addresses. It // does a STUN lookup (via netcheck) to determine its public address. // @@ -577,6 +579,9 @@ func (c *Conn) determineEndpoints(ctx context.Context) (ipPorts []string, reason var eps []string // unique endpoints addAddr := func(s, reason string) { + if debugOmitLocalAddresses && (reason == "localAddresses" || reason == "socket") { + return + } if _, ok := already[s]; !ok { already[s] = reason eps = append(eps, s)