Skip to content

Commit

Permalink
ipn/ipnlocal, tailcfg: add disable-web-client node attribute
Browse files Browse the repository at this point in the history
Add a disable-web-client node attribute and add handling for disabling
the web client when this node attribute is set.

Updates #10261

Signed-off-by: Mario Minardi <mario@tailscale.com>
  • Loading branch information
mpminardi committed Mar 14, 2024
1 parent cf8948d commit bdc6712
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ipn/ipnlocal/local.go
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tailcfg/tailcfg.go
Expand Up @@ -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.
Expand Down

0 comments on commit bdc6712

Please sign in to comment.