ipn: add PostureChecks to Prefs

Updates #5902

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
pull/9665/head
Kristoffer Dalby 1 year ago committed by Kristoffer Dalby
parent 553f657248
commit 886917c42b

@ -52,6 +52,7 @@ var _PrefsCloneNeedsRegeneration = Prefs(struct {
OperatorUser string OperatorUser string
ProfileName string ProfileName string
AutoUpdate AutoUpdatePrefs AutoUpdate AutoUpdatePrefs
PostureChecking bool
Persist *persist.Persist Persist *persist.Persist
}{}) }{})

@ -87,6 +87,7 @@ func (v PrefsView) NetfilterMode() preftype.NetfilterMode { return v.ж.Netfilte
func (v PrefsView) OperatorUser() string { return v.ж.OperatorUser } func (v PrefsView) OperatorUser() string { return v.ж.OperatorUser }
func (v PrefsView) ProfileName() string { return v.ж.ProfileName } func (v PrefsView) ProfileName() string { return v.ж.ProfileName }
func (v PrefsView) AutoUpdate() AutoUpdatePrefs { return v.ж.AutoUpdate } func (v PrefsView) AutoUpdate() AutoUpdatePrefs { return v.ж.AutoUpdate }
func (v PrefsView) PostureChecking() bool { return v.ж.PostureChecking }
func (v PrefsView) Persist() persist.PersistView { return v.ж.Persist.View() } func (v PrefsView) Persist() persist.PersistView { return v.ж.Persist.View() }
// A compilation failure here means this code must be regenerated, with the command at the top of this file. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
@ -113,6 +114,7 @@ var _PrefsViewNeedsRegeneration = Prefs(struct {
OperatorUser string OperatorUser string
ProfileName string ProfileName string
AutoUpdate AutoUpdatePrefs AutoUpdate AutoUpdatePrefs
PostureChecking bool
Persist *persist.Persist Persist *persist.Persist
}{}) }{})

@ -200,6 +200,10 @@ type Prefs struct {
// AutoUpdatePrefs docs for more details. // AutoUpdatePrefs docs for more details.
AutoUpdate AutoUpdatePrefs AutoUpdate AutoUpdatePrefs
// PostureChecking enables the collection of information used for device
// posture checks.
PostureChecking bool
// The Persist field is named 'Config' in the file for backward // The Persist field is named 'Config' in the file for backward
// compatibility with earlier versions. // compatibility with earlier versions.
// TODO(apenwarr): We should move this out of here, it's not a pref. // TODO(apenwarr): We should move this out of here, it's not a pref.
@ -246,6 +250,7 @@ type MaskedPrefs struct {
OperatorUserSet bool `json:",omitempty"` OperatorUserSet bool `json:",omitempty"`
ProfileNameSet bool `json:",omitempty"` ProfileNameSet bool `json:",omitempty"`
AutoUpdateSet bool `json:",omitempty"` AutoUpdateSet bool `json:",omitempty"`
PostureCheckingSet bool `json:",omitempty"`
} }
// ApplyEdits mutates p, assigning fields from m.Prefs for each MaskedPrefs // ApplyEdits mutates p, assigning fields from m.Prefs for each MaskedPrefs
@ -439,7 +444,8 @@ func (p *Prefs) Equals(p2 *Prefs) bool {
compareStrings(p.AdvertiseTags, p2.AdvertiseTags) && compareStrings(p.AdvertiseTags, p2.AdvertiseTags) &&
p.Persist.Equals(p2.Persist) && p.Persist.Equals(p2.Persist) &&
p.ProfileName == p2.ProfileName && p.ProfileName == p2.ProfileName &&
p.AutoUpdate == p2.AutoUpdate p.AutoUpdate == p2.AutoUpdate &&
p.PostureChecking == p2.PostureChecking
} }
func (au AutoUpdatePrefs) Pretty() string { func (au AutoUpdatePrefs) Pretty() string {

@ -57,6 +57,7 @@ func TestPrefsEqual(t *testing.T) {
"OperatorUser", "OperatorUser",
"ProfileName", "ProfileName",
"AutoUpdate", "AutoUpdate",
"PostureChecking",
"Persist", "Persist",
} }
if have := fieldsOf(reflect.TypeOf(Prefs{})); !reflect.DeepEqual(have, prefsHandles) { if have := fieldsOf(reflect.TypeOf(Prefs{})); !reflect.DeepEqual(have, prefsHandles) {
@ -304,6 +305,16 @@ func TestPrefsEqual(t *testing.T) {
&Prefs{AutoUpdate: AutoUpdatePrefs{Check: true, Apply: false}}, &Prefs{AutoUpdate: AutoUpdatePrefs{Check: true, Apply: false}},
true, true,
}, },
{
&Prefs{PostureChecking: true},
&Prefs{PostureChecking: true},
true,
},
{
&Prefs{PostureChecking: true},
&Prefs{PostureChecking: false},
false,
},
} }
for i, tt := range tests { for i, tt := range tests {
got := tt.a.Equals(tt.b) got := tt.a.Equals(tt.b)

Loading…
Cancel
Save