mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-21 06:01:42 +00:00
ipn/ipnlocal: make tests pass when offline
Updates #cleanup Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
parent
25a7204bb4
commit
82454b57dd
@ -8,6 +8,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
@ -64,6 +65,7 @@ import (
|
|||||||
"tailscale.com/types/dnstype"
|
"tailscale.com/types/dnstype"
|
||||||
"tailscale.com/types/empty"
|
"tailscale.com/types/empty"
|
||||||
"tailscale.com/types/key"
|
"tailscale.com/types/key"
|
||||||
|
"tailscale.com/types/lazy"
|
||||||
"tailscale.com/types/logger"
|
"tailscale.com/types/logger"
|
||||||
"tailscale.com/types/logid"
|
"tailscale.com/types/logid"
|
||||||
"tailscale.com/types/netmap"
|
"tailscale.com/types/netmap"
|
||||||
@ -91,6 +93,14 @@ import (
|
|||||||
"tailscale.com/wgengine/wgcfg/nmcfg"
|
"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()
|
var controlDebugFlags = getControlDebugFlags()
|
||||||
|
|
||||||
func getControlDebugFlags() []string {
|
func getControlDebugFlags() []string {
|
||||||
@ -496,7 +506,7 @@ func (b *LocalBackend) maybePauseControlClientLocked() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
networkUp := b.prevIfState.AnyInterfaceUp()
|
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.
|
// linkChange is our network monitor callback, called whenever the network changes.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user