ipn,ipn/local: broadcast ClientVersion if AutoUpdate.Check (#19107)
If AutoUpdate.Check is false, the client has opted out of checking for updates, so we shouldn't broadcast ClientVersion. If the client has opted in, it should be included in the initial Notify. Updates tailscale/corp#32629 Signed-off-by: kari-ts <kari@tailscale.com>
This commit is contained in:
+17
-3
@@ -3143,7 +3143,7 @@ func (b *LocalBackend) WatchNotificationsAs(ctx context.Context, actor ipnauth.A
|
||||
|
||||
b.mu.Lock()
|
||||
|
||||
const initialBits = ipn.NotifyInitialState | ipn.NotifyInitialPrefs | ipn.NotifyInitialNetMap | ipn.NotifyInitialDriveShares | ipn.NotifyInitialSuggestedExitNode
|
||||
const initialBits = ipn.NotifyInitialState | ipn.NotifyInitialPrefs | ipn.NotifyInitialNetMap | ipn.NotifyInitialDriveShares | ipn.NotifyInitialSuggestedExitNode | ipn.NotifyInitialClientVersion
|
||||
if mask&initialBits != 0 {
|
||||
cn := b.currentNode()
|
||||
ini = &ipn.Notify{Version: version.Long()}
|
||||
@@ -3171,6 +3171,11 @@ func (b *LocalBackend) WatchNotificationsAs(ctx context.Context, actor ipnauth.A
|
||||
ini.SuggestedExitNode = &en.ID
|
||||
}
|
||||
}
|
||||
if mask&ipn.NotifyInitialClientVersion != 0 {
|
||||
if prefs := b.pm.CurrentPrefs(); prefs.Valid() && prefs.AutoUpdate().Check {
|
||||
ini.ClientVersion = b.lastClientVersion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
@@ -3551,10 +3556,13 @@ func (b *LocalBackend) tellRecipientToBrowseToURLLocked(url string, recipient no
|
||||
// a non-nil ClientVersion message.
|
||||
func (b *LocalBackend) onClientVersion(v *tailcfg.ClientVersion) {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
b.lastClientVersion = v
|
||||
b.health.SetLatestVersion(v)
|
||||
b.mu.Unlock()
|
||||
b.send(ipn.Notify{ClientVersion: v})
|
||||
prefs := b.pm.CurrentPrefs()
|
||||
if prefs.Valid() && prefs.AutoUpdate().Check {
|
||||
b.sendLocked(ipn.Notify{ClientVersion: v})
|
||||
}
|
||||
}
|
||||
|
||||
func (b *LocalBackend) onTailnetDefaultAutoUpdate(au bool) {
|
||||
@@ -4757,6 +4765,12 @@ func (b *LocalBackend) setPrefsLocked(newp *ipn.Prefs) ipn.PrefsView {
|
||||
b.authReconfigLocked()
|
||||
}
|
||||
|
||||
if newp.AutoUpdate.Check && !oldp.AutoUpdate().Check {
|
||||
if cv := b.lastClientVersion; cv != nil {
|
||||
b.sendLocked(ipn.Notify{ClientVersion: cv})
|
||||
}
|
||||
}
|
||||
|
||||
b.sendLocked(ipn.Notify{Prefs: &prefs})
|
||||
return prefs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user