control/controlclient: scope a variable tighter, de-pointer a *time.Time

Just misc cleanups.

Updates #1909

Change-Id: I9d64cb6c46d634eb5fdf725c13a6c5e514e02e9a
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/8978/head
Brad Fitzpatrick 1 year ago committed by Brad Fitzpatrick
parent 2548496cef
commit 21170fb175

@ -93,7 +93,7 @@ type Direct struct {
persist persist.PersistView persist persist.PersistView
authKey string authKey string
tryingNewKey key.NodePrivate tryingNewKey key.NodePrivate
expiry *time.Time expiry time.Time // or zero value if none/unknown
hostinfo *tailcfg.Hostinfo // always non-nil hostinfo *tailcfg.Hostinfo // always non-nil
netinfo *tailcfg.NetInfo netinfo *tailcfg.NetInfo
endpoints []tailcfg.Endpoint endpoints []tailcfg.Endpoint
@ -438,7 +438,7 @@ func (c *Direct) doLogin(ctx context.Context, opt loginOpt) (mustRegen bool, new
authKey, isWrapped, wrappedSig, wrappedKey := decodeWrappedAuthkey(c.authKey, c.logf) authKey, isWrapped, wrappedSig, wrappedKey := decodeWrappedAuthkey(c.authKey, c.logf)
hi := c.hostInfoLocked() hi := c.hostInfoLocked()
backendLogID := hi.BackendLogID backendLogID := hi.BackendLogID
expired := c.expiry != nil && !c.expiry.IsZero() && c.expiry.Before(c.clock.Now()) expired := !c.expiry.IsZero() && c.expiry.Before(c.clock.Now())
c.mu.Unlock() c.mu.Unlock()
machinePrivKey, err := c.getMachinePrivKey() machinePrivKey, err := c.getMachinePrivKey()
@ -1077,17 +1077,16 @@ func (c *Direct) sendMapRequest(ctx context.Context, isStreaming bool, nu Netmap
metricMapResponseMapDelta.Add(1) metricMapResponseMapDelta.Add(1)
} }
hasDebug := resp.Debug != nil if debug := resp.Debug; debug != nil {
if hasDebug { if code := debug.Exit; code != nil {
if code := resp.Debug.Exit; code != nil {
c.logf("exiting process with status %v per controlplane", *code) c.logf("exiting process with status %v per controlplane", *code)
os.Exit(*code) os.Exit(*code)
} }
if resp.Debug.DisableLogTail { if debug.DisableLogTail {
logtail.Disable() logtail.Disable()
envknob.SetNoLogsNoSupport() envknob.SetNoLogsNoSupport()
} }
if sleep := time.Duration(resp.Debug.SleepSeconds * float64(time.Second)); sleep > 0 { if sleep := time.Duration(debug.SleepSeconds * float64(time.Second)); sleep > 0 {
if err := sleepAsRequested(ctx, c.logf, timeoutReset, sleep, c.clock); err != nil { if err := sleepAsRequested(ctx, c.logf, timeoutReset, sleep, c.clock); err != nil {
return err return err
} }
@ -1134,7 +1133,7 @@ func (c *Direct) sendMapRequest(ctx context.Context, isStreaming bool, nu Netmap
c.persist = newPersist.View() c.persist = newPersist.View()
persist = c.persist persist = c.persist
} }
c.expiry = &nm.Expiry c.expiry = nm.Expiry
c.mu.Unlock() c.mu.Unlock()
nu.UpdateFullNetmap(nm) nu.UpdateFullNetmap(nm)

Loading…
Cancel
Save