Reset dial plan when switching profile (#11933)

When switching profile, the server URL can change (e.g.
because of switching to a self-hosted headscale instance).

If it is not reset here, dial plans returned by old
server (e.g. tailscale control server) will be used to
connect to new server (e.g. self-hosted headscale server),
and the register request will be blocked by it until
timeout, leading to very slow profile switches.

Updates #11938 11938

Signed-off-by: Shaw Drastin <showier.drastic0a@icloud.com>
This commit is contained in:
Shaw Drastin 2024-05-01 01:42:49 +08:00 committed by GitHub
parent a47ce618bd
commit 1fe073098c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5881,6 +5881,11 @@ func (b *LocalBackend) SwitchProfile(profile ipn.ProfileID) error {
if err := b.pm.SwitchProfile(profile); err != nil {
return err
}
// TODO: Check if serverUrl in the switched profile is actually changed;
// if not, then no need to reset dial plan
b.dialPlan.Store(nil)
return b.resetForProfileChangeLockedOnEntry(unlock)
}