tailcfg: add CapabilityDebug

Updates tailscale/corp#7948

Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
Maisem Ali
2022-11-16 23:36:01 +05:00
committed by Maisem Ali
parent 1e78fc462c
commit 296e712591
3 changed files with 56 additions and 22 deletions

View File

@@ -778,6 +778,17 @@ func (h *peerAPIHandler) canPutFile() bool {
// canDebug reports whether h can debug this node (goroutines, metrics,
// magicsock internal state, etc).
func (h *peerAPIHandler) canDebug() bool {
// Reread the selfNode as it may have changed since the peerAPIServer
// was created.
// TODO(maisem): handle this in other places too.
nm := h.ps.b.NetMap()
if nm == nil || nm.SelfNode == nil {
return false
}
if !slices.Contains(nm.SelfNode.Capabilities, tailcfg.CapabilityDebug) {
// This node does not expose debug info.
return false
}
return h.isSelf || h.peerHasCap(tailcfg.CapabilityDebugPeer)
}