From 3f7cc3563f91d0a1253e5c057503683d307ab174 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 26 Apr 2022 14:57:55 -0700 Subject: [PATCH] ipn: always treat login.tailscale.com as controlplane.tailscale.com Like 888e50e1, but more aggressive. Updates #4538 (likely fixes) Updates #3488 Change-Id: I3924eee9110e47bdba926ce12954253bf2413040 Signed-off-by: Brad Fitzpatrick --- ipn/prefs.go | 7 ++++++- ipn/prefs_test.go | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ipn/prefs.go b/ipn/prefs.go index 47a9b358d..50d738ad8 100644 --- a/ipn/prefs.go +++ b/ipn/prefs.go @@ -428,9 +428,14 @@ func NewPrefs() *Prefs { } // ControlURLOrDefault returns the coordination server's URL base. -// If not configured, DefaultControlURL is returned instead. +// +// If not configured, or if the configured value is a legacy name equivalent to +// the default, then DefaultControlURL is returned instead. func (p *Prefs) ControlURLOrDefault() string { if p.ControlURL != "" { + if p.ControlURL != DefaultControlURL && IsLoginServerSynonym(p.ControlURL) { + return DefaultControlURL + } return p.ControlURL } return DefaultControlURL diff --git a/ipn/prefs_test.go b/ipn/prefs_test.go index 043f7e557..145c31fd2 100644 --- a/ipn/prefs_test.go +++ b/ipn/prefs_test.go @@ -810,3 +810,18 @@ func TestExitNodeIPOfArg(t *testing.T) { }) } } + +func TestControlURLOrDefault(t *testing.T) { + var p Prefs + if got, want := p.ControlURLOrDefault(), DefaultControlURL; got != want { + t.Errorf("got %q; want %q", got, want) + } + p.ControlURL = "http://foo.bar" + if got, want := p.ControlURLOrDefault(), "http://foo.bar"; got != want { + t.Errorf("got %q; want %q", got, want) + } + p.ControlURL = "https://login.tailscale.com" + if got, want := p.ControlURLOrDefault(), DefaultControlURL; got != want { + t.Errorf("got %q; want %q", got, want) + } +}