diff options
| author | Andrea Gottardo <andrea@gottardo.me> | 2024-02-15 14:28:38 -0800 |
|---|---|---|
| committer | Andrea Gottardo <andrea@gottardo.me> | 2024-02-23 10:51:33 -0800 |
| commit | 8a66006f371a408fe58a38eb4b1d1a755b6d17b5 (patch) | |
| tree | 7452ca987589d6d1c5790b92394be47515ccdb89 /control | |
| parent | 131f9094fdeda05b0c949055d9b18a495f200769 (diff) | |
| download | tailscale-angott/sleep-debug-apis.tar.xz tailscale-angott/sleep-debug-apis.zip | |
controlclient, ipn: add endpoints to manage sleep/wakeangott/sleep-debug-apis
Updates #3363. Adds localapi + debug endpoints to set/unset sleep mode.
Signed-off-by: Andrea Gottardo <andrea@gottardo.me>
Diffstat (limited to 'control')
| -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. |
