ipn/{localapi, ipnlocal}: forget the prior exit node when localAPI is used to zero the ExitNodeID (#11681)

Updates tailscale/corp#18724

When localAPI clients directly set ExitNodeID to "", the expected behaviour is that the prior exit node also gets zero'd - effectively setting the UI state back to 'no exit node was ever selected'

The IntenalExitNodePrior has been changed to be a non-opaque type, as it is read by the UI to render the users last selected exit node, and must be concrete. Future-us can either break this, or deprecate it and replace it with something more interesting.

Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>
This commit is contained in:
Jonathan Nobels
2024-04-16 14:53:56 -04:00
committed by GitHub
parent 0fba9e7570
commit 7e2b4268d6
5 changed files with 72 additions and 27 deletions
+4 -4
View File
@@ -107,11 +107,11 @@ type Prefs struct {
// InternalExitNodePrior is the most recently used ExitNodeID in string form. It is set by
// the backend on transition from exit node on to off and used by the
// backend. It's not of type tailcfg.StableNodeID because in the future we plan
// to overload this field to mean things like "Anything in country $FOO" too.
// backend.
//
// As an Internal field, it can't be set by LocalAPI clients.
InternalExitNodePrior string
// As an Internal field, it can't be set by LocalAPI clients, rather it is set indirectly
// when the ExitNodeID value is zero'd and via the set-use-exit-node-enabled endpoint.
InternalExitNodePrior tailcfg.StableNodeID
// ExitNodeAllowLANAccess indicates whether locally accessible subnets should be
// routed directly or via the exit node.