diff --git a/ipn/ipn_clone.go b/ipn/ipn_clone.go index 68c942dfb..7f38f9397 100644 --- a/ipn/ipn_clone.go +++ b/ipn/ipn_clone.go @@ -52,6 +52,7 @@ var _PrefsCloneNeedsRegeneration = Prefs(struct { OperatorUser string ProfileName string AutoUpdate AutoUpdatePrefs + PostureChecking bool Persist *persist.Persist }{}) diff --git a/ipn/ipn_view.go b/ipn/ipn_view.go index dbbf37476..a3ef660fa 100644 --- a/ipn/ipn_view.go +++ b/ipn/ipn_view.go @@ -87,6 +87,7 @@ func (v PrefsView) NetfilterMode() preftype.NetfilterMode { return v.ж.Netfilte func (v PrefsView) OperatorUser() string { return v.ж.OperatorUser } func (v PrefsView) ProfileName() string { return v.ж.ProfileName } 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() } // 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 ProfileName string AutoUpdate AutoUpdatePrefs + PostureChecking bool Persist *persist.Persist }{}) diff --git a/ipn/prefs.go b/ipn/prefs.go index 356359533..148293426 100644 --- a/ipn/prefs.go +++ b/ipn/prefs.go @@ -200,6 +200,10 @@ type Prefs struct { // AutoUpdatePrefs docs for more details. 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 // compatibility with earlier versions. // 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"` ProfileNameSet bool `json:",omitempty"` AutoUpdateSet bool `json:",omitempty"` + PostureCheckingSet bool `json:",omitempty"` } // 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) && p.Persist.Equals(p2.Persist) && p.ProfileName == p2.ProfileName && - p.AutoUpdate == p2.AutoUpdate + p.AutoUpdate == p2.AutoUpdate && + p.PostureChecking == p2.PostureChecking } func (au AutoUpdatePrefs) Pretty() string { diff --git a/ipn/prefs_test.go b/ipn/prefs_test.go index e963d3265..20d1bbfac 100644 --- a/ipn/prefs_test.go +++ b/ipn/prefs_test.go @@ -57,6 +57,7 @@ func TestPrefsEqual(t *testing.T) { "OperatorUser", "ProfileName", "AutoUpdate", + "PostureChecking", "Persist", } 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}}, true, }, + { + &Prefs{PostureChecking: true}, + &Prefs{PostureChecking: true}, + true, + }, + { + &Prefs{PostureChecking: true}, + &Prefs{PostureChecking: false}, + false, + }, } for i, tt := range tests { got := tt.a.Equals(tt.b)