diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index c8ca64058..43619a62a 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -8,6 +8,7 @@ import ( "encoding/base64" "encoding/json" "errors" + "flag" "fmt" "io" "log" @@ -64,6 +65,7 @@ import ( "tailscale.com/types/dnstype" "tailscale.com/types/empty" "tailscale.com/types/key" + "tailscale.com/types/lazy" "tailscale.com/types/logger" "tailscale.com/types/logid" "tailscale.com/types/netmap" @@ -91,6 +93,14 @@ import ( "tailscale.com/wgengine/wgcfg/nmcfg" ) +var lazyInTest lazy.SyncValue[bool] + +func inTest() bool { + return lazyInTest.Get(func() bool { + return flag.Lookup("test.v") != nil + }) +} + var controlDebugFlags = getControlDebugFlags() func getControlDebugFlags() []string { @@ -496,7 +506,7 @@ func (b *LocalBackend) maybePauseControlClientLocked() { return } networkUp := b.prevIfState.AnyInterfaceUp() - b.cc.SetPaused((b.state == ipn.Stopped && b.netMap != nil) || !networkUp) + b.cc.SetPaused((b.state == ipn.Stopped && b.netMap != nil) || (!networkUp && !inTest())) } // linkChange is our network monitor callback, called whenever the network changes.