ipn: move Options.ServerURL into Prefs.

We can't rely on a frontend to provide a control
server URL, so this naturally belongs in server-persisted
state.

Signed-off-by: David Anderson <dave@natulte.net>
This commit is contained in:
David Anderson
2020-02-18 21:03:22 -08:00
committed by Dave Anderson
parent 45d687e213
commit cf1e386cbd
10 changed files with 37 additions and 28 deletions

View File

@@ -20,7 +20,7 @@ func fieldsOf(t reflect.Type) (fields []string) {
}
func TestPrefsEqual(t *testing.T) {
prefsHandles := []string{"RouteAll", "AllowSingleHosts", "CorpDNS", "WantRunning", "UsePacketFilter", "AdvertiseRoutes", "NotepadURLs", "Persist"}
prefsHandles := []string{"ControlURL", "RouteAll", "AllowSingleHosts", "CorpDNS", "WantRunning", "UsePacketFilter", "AdvertiseRoutes", "NotepadURLs", "Persist"}
if have := fieldsOf(reflect.TypeOf(Prefs{})); !reflect.DeepEqual(have, prefsHandles) {
t.Errorf("Prefs.Equal check might be out of sync\nfields: %q\nhandled: %q\n",
have, prefsHandles)
@@ -56,6 +56,17 @@ func TestPrefsEqual(t *testing.T) {
true,
},
{
&Prefs{ControlURL: "https://login.tailscale.com"},
&Prefs{ControlURL: "https://login.private.co"},
false,
},
{
&Prefs{ControlURL: "https://login.tailscale.com"},
&Prefs{ControlURL: "https://login.tailscale.com"},
true,
},
{
&Prefs{RouteAll: true},
&Prefs{RouteAll: false},
@@ -209,7 +220,9 @@ func checkPrefs(t *testing.T, p Prefs) {
}
func TestBasicPrefs(t *testing.T) {
p := Prefs{}
p := Prefs{
ControlURL: "https://login.tailscale.com",
}
checkPrefs(t, p)
}
@@ -218,8 +231,9 @@ func TestPrefsPersist(t *testing.T) {
LoginName: "test@example.com",
}
p := Prefs{
CorpDNS: true,
Persist: &c,
ControlURL: "https://login.tailscale.com",
CorpDNS: true,
Persist: &c,
}
checkPrefs(t, p)
}