mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-12 13:48:01 +00:00
cmd/tailscale,ipn: minor fixes to tailscale lock commands
* Fix broken add/remove key commands * Make lock status display whether the node is signed Signed-off-by: Tom DNetto <tom@tailscale.com>
This commit is contained in:
@@ -329,10 +329,17 @@ func (b *LocalBackend) NetworkLockStatus() *ipnstate.NetworkLockStatus {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
|
||||
var nodeKey *key.NodePublic
|
||||
if p := b.pm.CurrentPrefs(); p.Valid() {
|
||||
nkp := p.Persist().PublicNodeKey()
|
||||
nodeKey = &nkp
|
||||
}
|
||||
|
||||
if b.tka == nil {
|
||||
return &ipnstate.NetworkLockStatus{
|
||||
Enabled: false,
|
||||
PublicKey: b.nlPrivKey.Public(),
|
||||
NodeKey: nodeKey,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,10 +347,28 @@ func (b *LocalBackend) NetworkLockStatus() *ipnstate.NetworkLockStatus {
|
||||
h := b.tka.authority.Head()
|
||||
copy(head[:], h[:])
|
||||
|
||||
var selfAuthorized bool
|
||||
if b.netMap != nil {
|
||||
selfAuthorized = b.tka.authority.NodeKeyAuthorized(b.netMap.SelfNode.Key, b.netMap.SelfNode.KeySignature) == nil
|
||||
}
|
||||
|
||||
keys := b.tka.authority.Keys()
|
||||
outKeys := make([]ipnstate.TKAKey, len(keys))
|
||||
for i, k := range keys {
|
||||
outKeys[i] = ipnstate.TKAKey{
|
||||
Key: key.NLPublicFromEd25519Unsafe(k.Public),
|
||||
Metadata: k.Meta,
|
||||
Votes: k.Votes,
|
||||
}
|
||||
}
|
||||
|
||||
return &ipnstate.NetworkLockStatus{
|
||||
Enabled: true,
|
||||
Head: &head,
|
||||
PublicKey: b.nlPrivKey.Public(),
|
||||
Enabled: true,
|
||||
Head: &head,
|
||||
PublicKey: b.nlPrivKey.Public(),
|
||||
NodeKey: nodeKey,
|
||||
NodeKeySigned: selfAuthorized,
|
||||
TrustedKeys: outKeys,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -67,6 +67,13 @@ type Status struct {
|
||||
User map[tailcfg.UserID]tailcfg.UserProfile
|
||||
}
|
||||
|
||||
// TKAKey describes a key trusted by network lock.
|
||||
type TKAKey struct {
|
||||
Key key.NLPublic
|
||||
Metadata map[string]string
|
||||
Votes uint
|
||||
}
|
||||
|
||||
// NetworkLockStatus represents whether network-lock is enabled,
|
||||
// along with details about the locally-known state of the tailnet
|
||||
// key authority.
|
||||
@@ -78,8 +85,19 @@ type NetworkLockStatus struct {
|
||||
// if network lock is not enabled.
|
||||
Head *[32]byte
|
||||
|
||||
// PublicKey describes the nodes' network-lock public key.
|
||||
// PublicKey describes the node's network-lock public key.
|
||||
PublicKey key.NLPublic
|
||||
|
||||
// NodeKey describes the node's current node-key. This field is not
|
||||
// populated if the node is not operating (i.e. waiting for a login).
|
||||
NodeKey *key.NodePublic
|
||||
|
||||
// NodeKeySigned is true if our node is authorized by network-lock.
|
||||
NodeKeySigned bool
|
||||
|
||||
// TrustedKeys describes the keys currently trusted to make changes
|
||||
// to network-lock.
|
||||
TrustedKeys []TKAKey
|
||||
}
|
||||
|
||||
// TailnetStatus is information about a Tailscale network ("tailnet").
|
||||
|
Reference in New Issue
Block a user