mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-13 22:47:30 +00:00
ipn/ipnlocal: add test to verify handling of unknown auto exit node expressions
We already check this for cases where ipn.Prefs.AutoExitNode is configured via syspolicy. Configuring it directly through EditPrefs should behave the same, so we add a test for that as well. Additionally, we clarify the implementation and future extensibility in (*LocalBackend).resolveAutoExitNodeLocked, where the AutoExitNode is actually enforced. Updates tailscale/corp#29969 Updates #cleanup Signed-off-by: Nick Khyl <nickk@tailscale.com>
This commit is contained in:
@@ -2071,6 +2071,14 @@ func mutationsAreWorthyOfTellingIPNBus(muts []netmap.NodeMutation) bool {
|
||||
//
|
||||
// b.mu must be held.
|
||||
func (b *LocalBackend) resolveAutoExitNodeLocked(prefs *ipn.Prefs) (prefsChanged bool) {
|
||||
// As of 2025-07-08, the only supported auto exit node expression is [ipn.AnyExitNode].
|
||||
//
|
||||
// However, to maintain forward compatibility with future auto exit node expressions,
|
||||
// we treat any non-empty AutoExitNode as [ipn.AnyExitNode].
|
||||
//
|
||||
// If and when we support additional auto exit node expressions, this method should be updated
|
||||
// to handle them appropriately, while still falling back to [ipn.AnyExitNode] or a more appropriate
|
||||
// default for unknown (or partially supported) expressions.
|
||||
if !prefs.AutoExitNode.IsSet() {
|
||||
return false
|
||||
}
|
||||
|
@@ -1002,6 +1002,23 @@ func TestConfigureExitNode(t *testing.T) {
|
||||
AutoExitNode: "foo",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "auto-foo-via-edit-prefs", // set auto exit node via EditPrefs with an unknown/unsupported expression
|
||||
prefs: ipn.Prefs{
|
||||
ControlURL: controlURL,
|
||||
},
|
||||
netMap: clientNetmap,
|
||||
report: report,
|
||||
changePrefs: &ipn.MaskedPrefs{
|
||||
Prefs: ipn.Prefs{AutoExitNode: "foo"},
|
||||
AutoExitNodeSet: true,
|
||||
},
|
||||
wantPrefs: ipn.Prefs{
|
||||
ControlURL: controlURL,
|
||||
ExitNodeID: exitNode1.StableID(), // unknown exit node expressions should work as "any"
|
||||
AutoExitNode: "foo",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "auto-any-via-policy/toggle-off", // cannot toggle off the exit node if it was set via syspolicy
|
||||
prefs: ipn.Prefs{
|
||||
|
Reference in New Issue
Block a user