mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-24 10:41:19 -08:00
ipn/ipnlocal: guard on expired key when connected to exit node
Signed-off-by: Taylor McIntyre <[email protected]>
This commit is contained in:
1 file changed
+14
-2
+14
-2
@@ -379,6 +379,7 @@ type LocalBackend struct {
|
||||
// hostinfo is mutated in-place while mu is held.
|
||||
hostinfo *tailcfg.Hostinfo // TODO(nickkhyl): move to nodeBackend
|
||||
nmExpiryTimer tstime.TimerController // for updating netMap on node expiry; can be nil; TODO(nickkhyl): move to nodeBackend
|
||||
nmExpiryAt time.Time // wall time at which nmExpiryTimer should fire
|
||||
activeLogin string // last logged LoginName from netMap; TODO(nickkhyl): move to nodeBackend (or remove? it's in [ipn.LoginProfile]).
|
||||
engineStatus ipn.EngineStatus
|
||||
endpoints []tailcfg.Endpoint
|
||||
@@ -1249,6 +1250,14 @@ func (b *LocalBackend) linkChange(delta *netmon.ChangeDelta) {
|
||||
|
||||
b.interfaceState = delta.CurrentState()
|
||||
|
||||
if delta.TimeJumped() && b.nmExpiryTimer != nil {
|
||||
// The timer runs on monotonic time, which on most platforms
|
||||
// does not advance while the device is asleep. Reschedule it
|
||||
// against the wall clock so that a key that expired during
|
||||
// sleep is handled now rather than a sleep's duration late.
|
||||
b.nmExpiryTimer.Reset(max(0, b.nmExpiryAt.Sub(b.clock.Now())))
|
||||
}
|
||||
|
||||
b.pauseOrResumeControlClientLocked()
|
||||
prefs := b.pm.CurrentPrefs()
|
||||
if delta.RebindLikelyRequired && prefs.AutoExitNode().IsSet() {
|
||||
@@ -1983,6 +1992,9 @@ func (b *LocalBackend) setControlClientStatusLocked(c controlclient.Client, st c
|
||||
nextExpiry := b.em.nextPeerExpiry(st.NetMap, now)
|
||||
if !nextExpiry.IsZero() {
|
||||
tmrDuration := nextExpiry.Sub(now) + 10*time.Second
|
||||
// From time package's docs: "The canonical way to strip a
|
||||
// monotonic clock reading is to use t = t.Round(0)."
|
||||
b.nmExpiryAt = now.Add(tmrDuration).Round(0)
|
||||
b.nmExpiryTimer = b.clock.AfterFunc(tmrDuration, func() {
|
||||
b.handleNetmapExpiry(c, st, currCall, tmrDuration)
|
||||
})
|
||||
@@ -2007,7 +2019,7 @@ func (b *LocalBackend) setControlClientStatusLocked(c controlclient.Client, st c
|
||||
b.blockEngineUpdatesLocked(false)
|
||||
}
|
||||
|
||||
if st.LoggedIn && (wasBlocked || authWasInProgress) {
|
||||
if st.LoggedIn && !b.keyExpired && (wasBlocked || authWasInProgress) {
|
||||
if wasBlocked {
|
||||
// Auth completed, unblock the engine
|
||||
b.blockEngineUpdatesLocked(false)
|
||||
@@ -2042,7 +2054,7 @@ func (b *LocalBackend) setControlClientStatusLocked(c controlclient.Client, st c
|
||||
prefs.Persist = st.Persist.AsStruct()
|
||||
}
|
||||
}
|
||||
if st.LoggedIn {
|
||||
if st.LoggedIn && !b.keyExpired {
|
||||
if authWasInProgress {
|
||||
b.resetAuthURLLocked()
|
||||
// Interactive login finished successfully (URL visited).
|
||||
|
||||
Reference in new issue
Block a user