diff options
Diffstat (limited to 'ipn')
| -rw-r--r-- | ipn/ipnlocal/local.go | 21 | ||||
| -rw-r--r-- | ipn/ipnlocal/network-lock.go | 1 | ||||
| -rw-r--r-- | ipn/ipnlocal/profiles.go | 4 | ||||
| -rw-r--r-- | ipn/prefs.go | 14 |
4 files changed, 24 insertions, 16 deletions
diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index eadf78f49..841ad22bf 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -1119,17 +1119,22 @@ func (b *LocalBackend) SetControlClientStatus(c controlclient.Client, st control // Until recently, we did not store the account's tailnet name. So check if this is the case, // and backfill it on incoming status update. - if b.pm.requiresBackfill() && st.NetMap != nil && st.NetMap.Domain != "" { - prefsChanged = true + var np ipn.NetworkProfile + if st.NetMap != nil { + np = ipn.NetworkProfile{ + MagicDNSName: st.NetMap.MagicDNSSuffix(), + DomainName: st.NetMap.DomainName(), + DisplayName: st.NetMap.GetDisplayName(), + } + if b.pm.requiresBackfill(np) { + prefsChanged = true + } } // Perform all mutations of prefs based on the netmap here. if prefsChanged { // Prefs will be written out if stale; this is not safe unless locked or cloned. - if err := b.pm.SetPrefs(prefs.View(), ipn.NetworkProfile{ - MagicDNSName: st.NetMap.MagicDNSSuffix(), - DomainName: st.NetMap.DomainName(), - }); err != nil { + if err := b.pm.SetPrefs(prefs.View(), np); err != nil { b.logf("Failed to save new controlclient state: %v", err) } } @@ -1188,6 +1193,7 @@ func (b *LocalBackend) SetControlClientStatus(c controlclient.Client, st control if err := b.pm.SetPrefs(p, ipn.NetworkProfile{ MagicDNSName: st.NetMap.MagicDNSSuffix(), DomainName: st.NetMap.DomainName(), + DisplayName: st.NetMap.GetDisplayName(), }); err != nil { b.logf("Failed to save new controlclient state: %v", err) } @@ -1618,6 +1624,7 @@ func (b *LocalBackend) Start(opts ipn.Options) error { if err := b.pm.SetPrefs(pv, ipn.NetworkProfile{ MagicDNSName: b.netMap.MagicDNSSuffix(), DomainName: b.netMap.DomainName(), + DisplayName: b.netMap.GetDisplayName(), }); err != nil { b.logf("failed to save UpdatePrefs state: %v", err) } @@ -2527,6 +2534,7 @@ func (b *LocalBackend) migrateStateLocked(prefs *ipn.Prefs) (err error) { if err := b.pm.SetPrefs(prefs.View(), ipn.NetworkProfile{ MagicDNSName: b.netMap.MagicDNSSuffix(), DomainName: b.netMap.DomainName(), + DisplayName: b.netMap.GetDisplayName(), }); err != nil { return fmt.Errorf("store.WriteState: %v", err) } @@ -3111,6 +3119,7 @@ func (b *LocalBackend) setPrefsLockedOnEntry(caller string, newp *ipn.Prefs) ipn if err := b.pm.SetPrefs(prefs, ipn.NetworkProfile{ MagicDNSName: b.netMap.MagicDNSSuffix(), DomainName: b.netMap.DomainName(), + DisplayName: b.netMap.GetDisplayName(), }); err != nil { b.logf("failed to save new controlclient state: %v", err) } diff --git a/ipn/ipnlocal/network-lock.go b/ipn/ipnlocal/network-lock.go index cfe33147b..381d9c3a1 100644 --- a/ipn/ipnlocal/network-lock.go +++ b/ipn/ipnlocal/network-lock.go @@ -581,6 +581,7 @@ func (b *LocalBackend) NetworkLockForceLocalDisable() error { if err := b.pm.SetPrefs(newPrefs.View(), ipn.NetworkProfile{ MagicDNSName: b.netMap.MagicDNSSuffix(), DomainName: b.netMap.DomainName(), + DisplayName: b.netMap.GetDisplayName(), }); err != nil { return fmt.Errorf("saving prefs: %w", err) } diff --git a/ipn/ipnlocal/profiles.go b/ipn/ipnlocal/profiles.go index 55bb6a1a1..442ed5277 100644 --- a/ipn/ipnlocal/profiles.go +++ b/ipn/ipnlocal/profiles.go @@ -608,10 +608,10 @@ func (pm *profileManager) migrateFromLegacyPrefs() error { return nil } -func (pm *profileManager) requiresBackfill() bool { +func (pm *profileManager) requiresBackfill(np ipn.NetworkProfile) bool { return pm != nil && pm.currentProfile != nil && - pm.currentProfile.NetworkProfile.RequiresBackfill() + pm.currentProfile.NetworkProfile.RequiresBackfill(np) } var ( diff --git a/ipn/prefs.go b/ipn/prefs.go index 5e8033a28..6417a6f62 100644 --- a/ipn/prefs.go +++ b/ipn/prefs.go @@ -795,16 +795,14 @@ type WindowsUserID string type NetworkProfile struct { MagicDNSName string DomainName string + DisplayName string } -// RequiresBackfill returns whether this object does not have all the data -// expected. This is because this struct is a later addition to LoginProfile and -// this method can be checked to see if it's been backfilled to the current -// expectation or not. Note that for now, it just checks if the struct is empty. -// In the future, if we have new optional fields, this method can be changed to -// do more explicit checks to return whether it's apt for a backfill or not. -func (n NetworkProfile) RequiresBackfill() bool { - return n == NetworkProfile{} +// RequiresBackfill returns whether the new NetworkProfile has changed +// from the already existing one and therefore requires updating the +// local storage. +func (n NetworkProfile) RequiresBackfill(np NetworkProfile) bool { + return n != np } // LoginProfile represents a single login profile as managed |
