summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMario Minardi <mario@tailscale.com>2024-03-18 10:32:33 -0600
committerGitHub <noreply@github.com>2024-03-18 10:32:33 -0600
commite0886ad167cbdfd3fcd4870c4ace531ae0050ddf (patch)
tree343b24c3d19f47723e706aaec869587ddcd60d65
parentda7c3d1753d07392281620730fac73384425d130 (diff)
downloadtailscale-e0886ad167cbdfd3fcd4870c4ace531ae0050ddf.tar.xz
tailscale-e0886ad167cbdfd3fcd4870c4ace531ae0050ddf.zip
ipn/ipnlocal, tailcfg: add disable-web-client node attribute (#11418)
Add a disable-web-client node attribute and add handling for disabling the web client when this node attribute is set. Updates https://github.com/tailscale/tailscale/issues/10261 Signed-off-by: Mario Minardi <mario@tailscale.com>
-rw-r--r--ipn/ipnlocal/local.go7
-rw-r--r--tailcfg/tailcfg.go3
2 files changed, 9 insertions, 1 deletions
diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go
index 8a5736b6f..aee9a9f87 100644
--- a/ipn/ipnlocal/local.go
+++ b/ipn/ipnlocal/local.go
@@ -4508,8 +4508,13 @@ func (b *LocalBackend) ShouldRunSSH() bool { return b.sshAtomicBool.Load() && en
// call regardless of whether b.mu is held or not.
func (b *LocalBackend) ShouldRunWebClient() bool { return b.webClientAtomicBool.Load() }
+// setWebClientAtomicBoolLocked sets webClientAtomicBool based on whether
+// the RunWebClient pref is set, and whether tailcfg.NodeAttrDisableWebClient
+// has been set in the netmap.NetworkMap.
+//
+// b.mu must be held.
func (b *LocalBackend) setWebClientAtomicBoolLocked(nm *netmap.NetworkMap, prefs ipn.PrefsView) {
- shouldRun := prefs.Valid() && prefs.RunWebClient()
+ shouldRun := prefs.Valid() && prefs.RunWebClient() && !hasCapability(nm, tailcfg.NodeAttrDisableWebClient)
wasRunning := b.webClientAtomicBool.Swap(shouldRun)
if wasRunning && !shouldRun {
go b.webClientShutdown() // stop web client
diff --git a/tailcfg/tailcfg.go b/tailcfg/tailcfg.go
index aeb41ce7e..8af421e77 100644
--- a/tailcfg/tailcfg.go
+++ b/tailcfg/tailcfg.go
@@ -2219,6 +2219,9 @@ const (
// NodeAttrSuggestExitNode is applied to each exit node which the control plane has determined
// is a recommended exit node.
NodeAttrSuggestExitNode NodeCapability = "suggest-exit-node"
+
+ // NodeAttrDisableWebClient disables using the web client.
+ NodeAttrDisableWebClient NodeCapability = "disable-web-client"
)
// SetDNSRequest is a request to add a DNS record.