diff options
Diffstat (limited to 'control/controlclient')
| -rw-r--r-- | control/controlclient/auto.go | 11 | ||||
| -rw-r--r-- | control/controlclient/client.go | 4 |
2 files changed, 15 insertions, 0 deletions
diff --git a/control/controlclient/auto.go b/control/controlclient/auto.go index d0551cdab..f4d9a4f1a 100644 --- a/control/controlclient/auto.go +++ b/control/controlclient/auto.go @@ -139,6 +139,7 @@ type Auto struct { loginGoal *LoginGoal // non-nil if some login activity is desired inMapPoll bool // true once we get the first MapResponse in a stream; false when HTTP response ends state State // TODO(bradfitz): delete this, make it computed by method from other state + isSleeping bool // whether we are ZZZing authCtx context.Context // context used for auth requests mapCtx context.Context // context used for netmap and update requests @@ -200,6 +201,16 @@ func NewNoStart(opts Options) (_ *Auto, err error) { } +func (c *Auto) SetSleepMode(enabled bool) { + c.logf("setSleepMode(%v)", enabled) + c.isSleeping = enabled + c.SetPaused(enabled) +} + +func (c *Auto) IsSleeping() bool { + return c.isSleeping +} + // SetPaused controls whether HTTP activity should be paused. // // The client can be paused and unpaused repeatedly, unlike Start and Shutdown, which can only be used once. diff --git a/control/controlclient/client.go b/control/controlclient/client.go index ef5af68c6..2acd82ef8 100644 --- a/control/controlclient/client.go +++ b/control/controlclient/client.go @@ -54,6 +54,10 @@ type Client interface { // TODO: It might be better to simply shutdown the controlclient and // make a new one when it's time to unpause. SetPaused(bool) + // SetSleepMode pauses the control client and prevents anybody else + // from unpausing it until SetSleepMode(false) is called again + SetSleepMode(bool) + IsSleeping() bool // AuthCantContinue returns whether authentication is blocked. If it // is, you either need to visit the auth URL (previously sent in a // Status callback) or call the Login function appropriately. |
