ipn/ipnlocal: add NodeKey func to return the public node NodeKey
This change introduces a NodeKey func on localbackend that returns the public node key. Updates tailscale/corp#9967 Signed-off-by: Charlotte Brandhorst-Satzkorn <charlotte@tailscale.com>pull/8072/head
parent
8864112a0c
commit
8d3d48e000
|
@ -3627,6 +3627,19 @@ func (b *LocalBackend) hasNodeKey() bool {
|
||||||
return p.Valid() && p.Persist().Valid() && !p.Persist().PrivateNodeKey().IsZero()
|
return p.Valid() && p.Persist().Valid() && !p.Persist().PrivateNodeKey().IsZero()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NodeKey returns the public node key.
|
||||||
|
func (b *LocalBackend) NodeKey() key.NodePublic {
|
||||||
|
b.mu.Lock()
|
||||||
|
defer b.mu.Unlock()
|
||||||
|
|
||||||
|
p := b.pm.CurrentPrefs()
|
||||||
|
if !p.Valid() || !p.Persist().Valid() || p.Persist().PrivateNodeKey().IsZero() {
|
||||||
|
return key.NodePublic{}
|
||||||
|
}
|
||||||
|
|
||||||
|
return p.Persist().PublicNodeKey()
|
||||||
|
}
|
||||||
|
|
||||||
// nextState returns the state the backend seems to be in, based on
|
// nextState returns the state the backend seems to be in, based on
|
||||||
// its internal state.
|
// its internal state.
|
||||||
func (b *LocalBackend) nextState() ipn.State {
|
func (b *LocalBackend) nextState() ipn.State {
|
||||||
|
|
Loading…
Reference in New Issue