Skip to content

Commit 86aa048

Browse files
committed
ipn/ipnlocal, util/syspolicy: make run exit node a preference option
Previously, the "RunExitNode" policy merely controlled the visibility of the "run as exit node" menu item, not the setting itself. This migrates that setting to a preference option named "AdvertiseExitNode". Updates ENG-2138 Change-Id: Ia6a125beb6b4563d380c6162637ce4088f1117a0 Signed-off-by: Adrian Dewhurst <adrian@tailscale.com>
1 parent 21958d2 commit 86aa048

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

ipn/ipnlocal/local.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,11 @@ var preferencePolicies = []preferencePolicyInfo{
12741274
get: func(p ipn.PrefsView) bool { return p.AutoUpdate().Apply },
12751275
set: func(p *ipn.Prefs, v bool) { p.AutoUpdate.Apply = v },
12761276
},
1277+
{
1278+
key: syspolicy.EnableRunExitNode,
1279+
get: func(p ipn.PrefsView) bool { return p.AdvertisesExitNode() },
1280+
set: func(p *ipn.Prefs, v bool) { p.SetAdvertiseExitNode(v) },
1281+
},
12771282
}
12781283

12791284
// applySysPolicy overwrites configured preferences with policies that may be

util/syspolicy/policy_keys.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ const (
1818

1919
// Keys with a string value that specifies an option: "always", "never", "user-decides".
2020
// The default is "user-decides" unless otherwise stated. Enforcement of
21-
// these policies is typically performed in ipnlocal.applySysPolicy().
21+
// these policies is typically performed in ipnlocal.applySysPolicy(). GUIs
22+
// typically hide menu items related to policies that are enforced.
2223
EnableIncomingConnections Key = "AllowIncomingConnections"
2324
EnableServerMode Key = "UnattendedMode"
2425
ExitNodeAllowLANAccess Key = "ExitNodeAllowLANAccess"
@@ -31,15 +32,23 @@ const (
3132
// installed. Its value is "InstallUpdates" because of an awkwardly-named
3233
// visibility option "ApplyUpdates" on MacOS.
3334
ApplyUpdates Key = "InstallUpdates"
35+
// EnableRunExitNode controls if the device acts as an exit node. Even when
36+
// running as an exit node, the device must be approved by a tailnet
37+
// administrator. Its name is slightly awkward because RunExitNodeVisibility
38+
// predates this option but is preserved for backwards compatibility.
39+
EnableRunExitNode Key = "AdvertiseExitNode"
3440

3541
// Keys with a string value that controls visibility: "show", "hide".
3642
// The default is "show" unless otherwise stated. Enforcement of these
3743
// policies is typically performed by the UI code for the relevant operating
3844
// system.
39-
AdminConsoleVisibility Key = "AdminConsole"
40-
NetworkDevicesVisibility Key = "NetworkDevices"
41-
TestMenuVisibility Key = "TestMenu"
42-
UpdateMenuVisibility Key = "UpdateMenu"
45+
AdminConsoleVisibility Key = "AdminConsole"
46+
NetworkDevicesVisibility Key = "NetworkDevices"
47+
TestMenuVisibility Key = "TestMenu"
48+
UpdateMenuVisibility Key = "UpdateMenu"
49+
// RunExitNodeVisibility controls if the "run as exit node" menu item is
50+
// visible, without controlling the setting itself. This is preserved for
51+
// backwards compatibility but prefer EnableRunExitNode in new deployments.
4352
RunExitNodeVisibility Key = "RunExitNode"
4453
PreferencesMenuVisibility Key = "PreferencesMenu"
4554
ExitNodeMenuVisibility Key = "ExitNodesPicker"

0 commit comments

Comments
 (0)