From 003089820dd050972a6d32abca020f2e7f515dd8 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 2 Dec 2021 21:10:08 -0800 Subject: [PATCH] cmd/tailscale: fix setting revert checker's finding an exit node It was using the wrong prefs (intended vs current) to map the current exit node ID to an IP. Fixes #3480 Change-Id: I9f117d99a84edddb4cd1cb0df44a2f486abde6c2 Signed-off-by: Brad Fitzpatrick --- cmd/tailscale/cli/cli_test.go | 15 +++++++++++++++ cmd/tailscale/cli/up.go | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/cmd/tailscale/cli/cli_test.go b/cmd/tailscale/cli/cli_test.go index d6de6ff94..df228b48d 100644 --- a/cmd/tailscale/cli/cli_test.go +++ b/cmd/tailscale/cli/cli_test.go @@ -408,6 +408,21 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) { }, want: accidentalUpPrefix + " --hostname=foo --exit-node=100.64.5.7", }, + { + name: "error_exit_node_and_allow_lan_omit_with_id_pref", // Isue 3480 + flags: []string{"--hostname=foo"}, + curExitNodeIP: netaddr.MustParseIP("100.2.3.4"), + curPrefs: &ipn.Prefs{ + ControlURL: ipn.DefaultControlURL, + AllowSingleHosts: true, + CorpDNS: true, + NetfilterMode: preftype.NetfilterOn, + + ExitNodeAllowLANAccess: true, + ExitNodeID: "some_stable_id", + }, + want: accidentalUpPrefix + " --hostname=foo --exit-node-allow-lan-access --exit-node=100.2.3.4", + }, { name: "ignore_login_server_synonym", flags: []string{"--login-server=https://controlplane.tailscale.com"}, diff --git a/cmd/tailscale/cli/up.go b/cmd/tailscale/cli/up.go index 598097572..cc9f1cbce 100644 --- a/cmd/tailscale/cli/up.go +++ b/cmd/tailscale/cli/up.go @@ -447,7 +447,7 @@ func runUp(ctx context.Context, args []string) error { flagSet: upFlagSet, upArgs: upArgs, backendState: st.BackendState, - curExitNodeIP: exitNodeIP(prefs, st), + curExitNodeIP: exitNodeIP(curPrefs, st), } simpleUp, justEditMP, err := updatePrefs(prefs, curPrefs, env) if err != nil {