From c9089c82e8748acce85e10d4aa145705d69c5bfb Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 3 Jul 2020 13:55:33 -0700 Subject: [PATCH] control/controlclient, tailcfg: turn active route discovery on by default Updates #483 --- control/controlclient/direct.go | 37 ++++++++++++++++++++------------- tailcfg/tailcfg.go | 6 ++++++ 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/control/controlclient/direct.go b/control/controlclient/direct.go index 25abb1a39..568e60311 100644 --- a/control/controlclient/direct.go +++ b/control/controlclient/direct.go @@ -475,14 +475,15 @@ func (c *Direct) PollNetMap(ctx context.Context, maxPolls int, cb func(*NetworkM } request := tailcfg.MapRequest{ - Version: 4, - IncludeIPv6: true, - KeepAlive: c.keepAlive, - NodeKey: tailcfg.NodeKey(persist.PrivateNodeKey.Public()), - DiscoKey: c.discoPubKey, - Endpoints: ep, - Stream: allowStream, - Hostinfo: hostinfo, + Version: 4, + IncludeIPv6: true, + KeepAlive: c.keepAlive, + NodeKey: tailcfg.NodeKey(persist.PrivateNodeKey.Public()), + DiscoKey: c.discoPubKey, + Endpoints: ep, + Stream: allowStream, + Hostinfo: hostinfo, + DebugForceDisco: Debug.ForceDisco, } if c.newDecompressor != nil { request.Compress = "zstd" @@ -782,17 +783,23 @@ func loadServerKey(ctx context.Context, httpc *http.Client, serverURL string) (w var Debug = initDebug() type debug struct { - NetMap bool - OnlyDisco bool - Disco bool + NetMap bool + OnlyDisco bool + Disco bool + ForceDisco bool // ask control server to not filter out our disco key } func initDebug() debug { - return debug{ - NetMap: envBool("TS_DEBUG_NETMAP"), - OnlyDisco: os.Getenv("TS_DEBUG_USE_DISCO") == "only", - Disco: os.Getenv("TS_DEBUG_USE_DISCO") == "only" || envBool("TS_DEBUG_USE_DISCO"), + d := debug{ + NetMap: envBool("TS_DEBUG_NETMAP"), + OnlyDisco: os.Getenv("TS_DEBUG_USE_DISCO") == "only", + ForceDisco: os.Getenv("TS_DEBUG_USE_DISCO") == "only" || envBool("TS_DEBUG_USE_DISCO"), } + if d.ForceDisco || os.Getenv("TS_DEBUG_USE_DISCO") == "" { + // This is now defaults to on. + d.Disco = true + } + return d } func envBool(k string) bool { diff --git a/tailcfg/tailcfg.go b/tailcfg/tailcfg.go index 954b2c153..79a123826 100644 --- a/tailcfg/tailcfg.go +++ b/tailcfg/tailcfg.go @@ -454,6 +454,12 @@ type MapRequest struct { IncludeIPv6 bool // include IPv6 endpoints in returned Node Endpoints Stream bool // if true, multiple MapResponse objects are returned Hostinfo *Hostinfo + + // DebugForceDisco is a temporary flag during the deployment + // of magicsock active discovery. It says that that the client + // has environment variables explicitly turning discovery on, + // so control should not disable it. + DebugForceDisco bool `json:"debugForceDisco,omitempty"` } // PortRange represents a range of UDP or TCP port numbers.