cmd,ipn/ipnlocal,tailcfg: implement TKA disablement

* Plumb disablement values through some of the internals of TKA enablement.
 * Transmit the node's TKA hash at the end of sync so the control plane understands each node's head.
 * Implement /machine/tka/disable RPC to actuate disablement on the control plane.

There is a partner PR for the control server I'll send shortly.

Signed-off-by: Tom DNetto <tom@tailscale.com>
This commit is contained in:
Tom DNetto
2022-10-27 13:40:31 -07:00
committed by Tom
parent 3d8eda5b72
commit d98305c537
12 changed files with 322 additions and 38 deletions

View File

@@ -831,6 +831,16 @@ func (b *LocalBackend) setClientStatus(st controlclient.Status) {
b.logf("[v1] TKA sync error: %v", err)
}
b.mu.Lock()
if b.tka != nil {
head, err := b.tka.authority.Head().MarshalText()
if err != nil {
b.logf("[v1] error marshalling tka head: %v", err)
} else {
b.cc.SetTKAHead(string(head))
}
} else {
b.cc.SetTKAHead("")
}
if !envknob.TKASkipSignatureCheck() {
b.tkaFilterNetmapLocked(st.NetMap)
@@ -1226,11 +1236,21 @@ func (b *LocalBackend) Start(opts ipn.Options) error {
b.cc = cc
b.ccAuto, _ = cc.(*controlclient.Auto)
endpoints := b.endpoints
var tkaHead string
if b.tka != nil {
head, err := b.tka.authority.Head().MarshalText()
if err != nil {
b.mu.Unlock()
return fmt.Errorf("marshalling tka head: %w", err)
}
tkaHead = string(head)
}
b.mu.Unlock()
if endpoints != nil {
cc.UpdateEndpoints(endpoints)
}
cc.SetTKAHead(tkaHead)
b.e.SetNetInfoCallback(b.setNetInfo)