mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-18 19:01:19 +02:00
feature/relayserver: consider relay:server node attribute for enablement (#15901)
Updates tailscale/corp#27502 Signed-off-by: Jordan Whited <jordan@tailscale.com>
This commit is contained in:
parent
48dacf1bf7
commit
7e2630235f
@ -72,10 +72,20 @@ func (e *extension) Init(host ipnext.Host) error {
|
|||||||
profile, prefs := host.Profiles().CurrentProfileState()
|
profile, prefs := host.Profiles().CurrentProfileState()
|
||||||
e.profileStateChanged(profile, prefs, false)
|
e.profileStateChanged(profile, prefs, false)
|
||||||
host.Hooks().ProfileStateChange.Add(e.profileStateChanged)
|
host.Hooks().ProfileStateChange.Add(e.profileStateChanged)
|
||||||
// TODO(jwhited): callback for netmap/nodeattr changes (e.hasNodeAttrRelayServer)
|
host.Hooks().OnSelfChange.Add(e.selfNodeViewChanged)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *extension) selfNodeViewChanged(nodeView tailcfg.NodeView) {
|
||||||
|
e.mu.Lock()
|
||||||
|
defer e.mu.Unlock()
|
||||||
|
e.hasNodeAttrRelayServer = nodeView.HasCap(tailcfg.NodeAttrRelayServer)
|
||||||
|
if !e.hasNodeAttrRelayServer && e.server != nil {
|
||||||
|
e.server.Close()
|
||||||
|
e.server = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (e *extension) profileStateChanged(_ ipn.LoginProfileView, prefs ipn.PrefsView, sameNode bool) {
|
func (e *extension) profileStateChanged(_ ipn.LoginProfileView, prefs ipn.PrefsView, sameNode bool) {
|
||||||
e.mu.Lock()
|
e.mu.Lock()
|
||||||
defer e.mu.Unlock()
|
defer e.mu.Unlock()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user