mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-01 18:42:12 +02:00
ipn/ipnlocal: simplify pickNewAutoExitNode
(*profileManager).CurrentPrefs() is always valid. Additionally, there's no value in cloning and passing the full ipn.Prefs when editing preferences. Instead, ipn.MaskedPrefs should only have ExitNodeID set. Updates tailscale/corp#29969 Signed-off-by: Nick Khyl <nickk@tailscale.com>
This commit is contained in:
parent
1a2185b1ee
commit
56d772bd63
@ -5835,23 +5835,16 @@ func (b *LocalBackend) pickNewAutoExitNode() {
|
|||||||
unlock := b.lockAndGetUnlock()
|
unlock := b.lockAndGetUnlock()
|
||||||
defer unlock()
|
defer unlock()
|
||||||
|
|
||||||
prefs := b.pm.CurrentPrefs()
|
|
||||||
if !prefs.Valid() {
|
|
||||||
b.logf("[unexpected]: received tailnet exit node ID pref change callback but current prefs are nil")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
prefsClone := prefs.AsStruct()
|
|
||||||
newSuggestion, err := b.suggestExitNodeLocked(nil)
|
newSuggestion, err := b.suggestExitNodeLocked(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.logf("setAutoExitNodeID: %v", err)
|
b.logf("setAutoExitNodeID: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if prefsClone.ExitNodeID == newSuggestion.ID {
|
if b.pm.CurrentPrefs().ExitNodeID() == newSuggestion.ID {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
prefsClone.ExitNodeID = newSuggestion.ID
|
|
||||||
_, err = b.editPrefsLockedOnEntry(&ipn.MaskedPrefs{
|
_, err = b.editPrefsLockedOnEntry(&ipn.MaskedPrefs{
|
||||||
Prefs: *prefsClone,
|
Prefs: ipn.Prefs{ExitNodeID: newSuggestion.ID},
|
||||||
ExitNodeIDSet: true,
|
ExitNodeIDSet: true,
|
||||||
}, unlock)
|
}, unlock)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user