@ -24,6 +24,7 @@ import (
"tailscale.com/tka"
"tailscale.com/tstest"
"tailscale.com/types/logger"
"tailscale.com/types/opt"
"tailscale.com/types/persist"
"tailscale.com/types/preftype"
"tailscale.com/version/distro"
@ -179,6 +180,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
ControlURL : ipn . DefaultControlURL ,
WantRunning : false ,
Hostname : "foo" ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
want : "" ,
} ,
@ -191,6 +193,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
Hostname : "foo" ,
CorpDNS : true ,
NetfilterMode : preftype . NetfilterOn ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
want : accidentalUpPrefix + " --accept-dns --hostname=foo" ,
} ,
@ -202,6 +205,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
CorpDNS : true ,
NetfilterMode : preftype . NetfilterOn ,
Hostname : "foo" ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
want : "" ,
} ,
@ -213,6 +217,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
CorpDNS : true ,
NetfilterMode : preftype . NetfilterOn ,
Hostname : "foo" ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
want : "" ,
} ,
@ -232,6 +237,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
OperatorUser : "alice" ,
CorpDNS : true ,
NetfilterMode : preftype . NetfilterOn ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
curUser : "eve" ,
want : accidentalUpPrefix + " --hostname=foo --operator=alice" ,
@ -244,6 +250,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
CorpDNS : true ,
NetfilterMode : preftype . NetfilterOn ,
OperatorUser : "alice" ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
curUser : "alice" ,
want : "" ,
@ -260,6 +267,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
netip . MustParsePrefix ( "0.0.0.0/0" ) ,
netip . MustParsePrefix ( "::/0" ) ,
} ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
want : accidentalUpPrefix + " --advertise-routes=10.0.42.0/24 --advertise-exit-node" ,
} ,
@ -275,6 +283,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
netip . MustParsePrefix ( "0.0.0.0/0" ) ,
netip . MustParsePrefix ( "::/0" ) ,
} ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
want : "" ,
} ,
@ -290,6 +299,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
netip . MustParsePrefix ( "0.0.0.0/0" ) ,
netip . MustParsePrefix ( "::/0" ) ,
} ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
want : "" ,
} ,
@ -300,6 +310,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
ControlURL : ipn . DefaultControlURL ,
CorpDNS : true ,
NetfilterMode : preftype . NetfilterOn ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
want : "" ,
} ,
@ -314,6 +325,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
AdvertiseRoutes : [ ] netip . Prefix {
netip . MustParsePrefix ( "1.2.0.0/16" ) ,
} ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
want : accidentalUpPrefix + " --advertise-exit-node --advertise-routes=1.2.0.0/16" ,
} ,
@ -329,6 +341,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
netip . MustParsePrefix ( "::/0" ) ,
netip . MustParsePrefix ( "1.2.0.0/16" ) ,
} ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
want : accidentalUpPrefix + " --advertise-exit-node --advertise-routes=1.2.0.0/16" ,
} ,
@ -341,6 +354,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
NetfilterMode : preftype . NetfilterOn ,
ExitNodeID : "fooID" ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
want : "" ,
} ,
@ -364,6 +378,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
} ,
NetfilterMode : preftype . NetfilterNoDivert ,
OperatorUser : "alice" ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
curUser : "eve" ,
want : accidentalUpPrefix + " --force-reauth --accept-dns=false --accept-routes --advertise-exit-node --advertise-routes=10.0.0.0/16 --advertise-tags=tag:foo,tag:bar --exit-node=100.64.5.6 --hostname=myhostname --netfilter-mode=nodivert --operator=alice --shields-up" ,
@ -386,6 +401,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
} ,
NetfilterMode : preftype . NetfilterNoDivert ,
OperatorUser : "alice" ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
curUser : "eve" ,
want : accidentalUpPrefix + " --hostname=newhostname --accept-dns=false --accept-routes --advertise-routes=10.0.0.0/16 --advertise-tags=tag:foo,tag:bar --exit-node=100.64.5.6 --netfilter-mode=nodivert --operator=alice --shields-up" ,
@ -398,6 +414,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
LoggedOut : true ,
CorpDNS : true ,
NetfilterMode : preftype . NetfilterOn ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
want : "" , // not an error. LoggedOut is implicit.
} ,
@ -440,6 +457,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
netip . MustParsePrefix ( "::/0" ) ,
netip . MustParsePrefix ( "1.2.0.0/16" ) ,
} ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
want : accidentalUpPrefix + " --operator=expbits --advertise-exit-node --advertise-routes=1.2.0.0/16" ,
} ,
@ -455,6 +473,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
netip . MustParsePrefix ( "::/0" ) ,
netip . MustParsePrefix ( "1.2.0.0/16" ) ,
} ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
want : accidentalUpPrefix + " --advertise-routes=1.2.0.0/16 --operator=expbits --advertise-exit-node" ,
} ,
@ -468,6 +487,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
NetfilterMode : preftype . NetfilterOn ,
Hostname : "foo" ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
want : accidentalUpPrefix + " --auth-key=secretrand --force-reauth=false --reset --hostname=foo" ,
} ,
@ -480,6 +500,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
NetfilterMode : preftype . NetfilterOn ,
ExitNodeIP : netip . MustParseAddr ( "100.64.5.4" ) ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
want : accidentalUpPrefix + " --hostname=foo --exit-node=100.64.5.4" ,
} ,
@ -493,6 +514,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
NetfilterMode : preftype . NetfilterOn ,
ExitNodeID : "some_stable_id" ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
want : accidentalUpPrefix + " --hostname=foo --exit-node=100.64.5.7" ,
} ,
@ -507,6 +529,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
ExitNodeAllowLANAccess : true ,
ExitNodeID : "some_stable_id" ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
want : accidentalUpPrefix + " --hostname=foo --exit-node-allow-lan-access --exit-node=100.2.3.4" ,
} ,
@ -517,6 +540,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
ControlURL : "https://login.tailscale.com" ,
CorpDNS : true ,
NetfilterMode : preftype . NetfilterOn ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
want : "" , // not an error
} ,
@ -527,6 +551,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
ControlURL : "https://login.tailscale.com" ,
CorpDNS : false ,
NetfilterMode : preftype . NetfilterOn ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
want : accidentalUpPrefix + " --netfilter-mode=off --accept-dns=false" ,
} ,
@ -540,6 +565,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
CorpDNS : true ,
RouteAll : true ,
NetfilterMode : preftype . NetfilterOn ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
goos : "linux" ,
distro : distro . Synology ,
@ -555,6 +581,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
CorpDNS : true ,
RouteAll : true ,
NetfilterMode : preftype . NetfilterOn ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
goos : "linux" ,
distro : "" , // not Synology
@ -568,6 +595,7 @@ func TestCheckForAccidentalSettingReverts(t *testing.T) {
CorpDNS : true ,
NetfilterMode : preftype . NetfilterOn ,
ProfileName : "foo" ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
goos : "linux" ,
want : "" ,
@ -630,7 +658,7 @@ func TestPrefsFromUpArgs(t *testing.T) {
ControlURL : ipn . DefaultControlURL ,
WantRunning : true ,
NoSNAT : false ,
NoStatefulFiltering : " fals e",
NoStatefulFiltering : " tru e",
NetfilterMode : preftype . NetfilterOn ,
CorpDNS : true ,
AutoUpdate : ipn . AutoUpdatePrefs {
@ -648,7 +676,7 @@ func TestPrefsFromUpArgs(t *testing.T) {
CorpDNS : true ,
RouteAll : true ,
NoSNAT : false ,
NoStatefulFiltering : " fals e",
NoStatefulFiltering : " tru e",
NetfilterMode : preftype . NetfilterOn ,
AutoUpdate : ipn . AutoUpdatePrefs {
Check : true ,
@ -666,7 +694,7 @@ func TestPrefsFromUpArgs(t *testing.T) {
netip . MustParsePrefix ( "0.0.0.0/0" ) ,
netip . MustParsePrefix ( "::/0" ) ,
} ,
NoStatefulFiltering : " fals e",
NoStatefulFiltering : " tru e",
NetfilterMode : preftype . NetfilterOn ,
AutoUpdate : ipn . AutoUpdatePrefs {
Check : true ,
@ -1037,6 +1065,7 @@ func TestUpdatePrefs(t *testing.T) {
Persist : & persist . Persist { UserProfile : tailcfg . UserProfile { LoginName : "crawshaw.github" } } ,
CorpDNS : true ,
NetfilterMode : preftype . NetfilterOn ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
env : upCheckEnv { backendState : "Running" } ,
wantSimpleUp : true ,
@ -1051,6 +1080,7 @@ func TestUpdatePrefs(t *testing.T) {
Persist : & persist . Persist { UserProfile : tailcfg . UserProfile { LoginName : "crawshaw.github" } } ,
CorpDNS : true ,
NetfilterMode : preftype . NetfilterOn ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
env : upCheckEnv { backendState : "Running" } ,
} ,
@ -1063,6 +1093,7 @@ func TestUpdatePrefs(t *testing.T) {
CorpDNS : true ,
NetfilterMode : preftype . NetfilterOn ,
OperatorUser : "somebody" ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
env : upCheckEnv { user : "somebody" , backendState : "Running" } ,
wantJustEditMP : & ipn . MaskedPrefs {
@ -1083,6 +1114,7 @@ func TestUpdatePrefs(t *testing.T) {
Persist : & persist . Persist { UserProfile : tailcfg . UserProfile { LoginName : "crawshaw.github" } } ,
CorpDNS : true ,
NetfilterMode : preftype . NetfilterOn ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
wantJustEditMP : & ipn . MaskedPrefs {
RunSSHSet : true ,
@ -1104,6 +1136,7 @@ func TestUpdatePrefs(t *testing.T) {
CorpDNS : true ,
RunSSH : true ,
NetfilterMode : preftype . NetfilterOn ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
wantJustEditMP : & ipn . MaskedPrefs {
RunSSHSet : true ,
@ -1128,6 +1161,7 @@ func TestUpdatePrefs(t *testing.T) {
CorpDNS : true ,
NetfilterMode : preftype . NetfilterOn ,
RunSSH : true ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
wantJustEditMP : & ipn . MaskedPrefs {
RunSSHSet : true ,
@ -1150,6 +1184,7 @@ func TestUpdatePrefs(t *testing.T) {
Persist : & persist . Persist { UserProfile : tailcfg . UserProfile { LoginName : "crawshaw.github" } } ,
CorpDNS : true ,
NetfilterMode : preftype . NetfilterOn ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
wantJustEditMP : & ipn . MaskedPrefs {
RunSSHSet : true ,
@ -1172,6 +1207,7 @@ func TestUpdatePrefs(t *testing.T) {
Persist : & persist . Persist { UserProfile : tailcfg . UserProfile { LoginName : "crawshaw.github" } } ,
CorpDNS : true ,
NetfilterMode : preftype . NetfilterOn ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
wantJustEditMP : & ipn . MaskedPrefs {
RunSSHSet : true ,
@ -1194,6 +1230,7 @@ func TestUpdatePrefs(t *testing.T) {
CorpDNS : true ,
RunSSH : true ,
NetfilterMode : preftype . NetfilterOn ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
wantJustEditMP : & ipn . MaskedPrefs {
RunSSHSet : true ,
@ -1214,6 +1251,7 @@ func TestUpdatePrefs(t *testing.T) {
ControlURL : "https://login.tailscale.com" ,
CorpDNS : true ,
NetfilterMode : preftype . NetfilterOn ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
env : upCheckEnv { backendState : "Running" } ,
wantErrSubtr : "aborted, no changes made" ,
@ -1226,6 +1264,7 @@ func TestUpdatePrefs(t *testing.T) {
ControlURL : "https://login.tailscale.com" ,
CorpDNS : true ,
NetfilterMode : preftype . NetfilterOn ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
wantJustEditMP : nil ,
env : upCheckEnv { backendState : "Running" } ,
@ -1237,6 +1276,7 @@ func TestUpdatePrefs(t *testing.T) {
ControlURL : ipn . DefaultControlURL ,
CorpDNS : true ,
NetfilterMode : preftype . NetfilterOn ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
wantJustEditMP : & ipn . MaskedPrefs {
AppConnectorSet : true ,
@ -1259,6 +1299,7 @@ func TestUpdatePrefs(t *testing.T) {
AppConnector : ipn . AppConnectorPrefs {
Advertise : true ,
} ,
NoStatefulFiltering : opt . NewBool ( true ) ,
} ,
wantJustEditMP : & ipn . MaskedPrefs {
AppConnectorSet : true ,