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>
This commit is contained in:
Mario Minardi 2024-03-18 10:32:33 -06:00 committed by GitHub
parent da7c3d1753
commit e0886ad167
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -4508,8 +4508,13 @@ func (b *LocalBackend) ShouldRunSSH() bool { return b.sshAtomicBool.Load() && en
// call regardless of whether b.mu is held or not. // call regardless of whether b.mu is held or not.
func (b *LocalBackend) ShouldRunWebClient() bool { return b.webClientAtomicBool.Load() } 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) { 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) wasRunning := b.webClientAtomicBool.Swap(shouldRun)
if wasRunning && !shouldRun { if wasRunning && !shouldRun {
go b.webClientShutdown() // stop web client go b.webClientShutdown() // stop web client

View File

@ -2219,6 +2219,9 @@ type Oauth2Token struct {
// NodeAttrSuggestExitNode is applied to each exit node which the control plane has determined // NodeAttrSuggestExitNode is applied to each exit node which the control plane has determined
// is a recommended exit node. // is a recommended exit node.
NodeAttrSuggestExitNode NodeCapability = "suggest-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. // SetDNSRequest is a request to add a DNS record.