types/netmap, all: make NetworkMap.SelfNode a tailcfg.NodeView

Updates #1909

Change-Id: I8c470cbc147129a652c1d58eac9b790691b87606
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2023-08-21 10:53:57 -07:00
committed by Brad Fitzpatrick
parent 699f9699ca
commit 84b94b3146
26 changed files with 90 additions and 90 deletions

View File

@@ -25,7 +25,7 @@ import (
type NetworkMap struct {
// Core networking
SelfNode *tailcfg.Node
SelfNode tailcfg.NodeView
NodeKey key.NodePublic
PrivateKey key.NodePrivate
Expiry time.Time
@@ -90,8 +90,8 @@ type NetworkMap struct {
// User returns nm.SelfNode.User if nm.SelfNode is non-nil, otherwise it returns
// 0.
func (nm *NetworkMap) User() tailcfg.UserID {
if nm.SelfNode != nil {
return nm.SelfNode.User
if nm.SelfNode.Valid() {
return nm.SelfNode.User()
}
return 0
}
@@ -149,12 +149,13 @@ func (nm *NetworkMap) MagicDNSSuffix() string {
// SelfCapabilities returns SelfNode.Capabilities if nm and nm.SelfNode are
// non-nil. This is a method so we can use it in envknob/logknob without a
// circular dependency.
func (nm *NetworkMap) SelfCapabilities() []string {
if nm == nil || nm.SelfNode == nil {
return nil
func (nm *NetworkMap) SelfCapabilities() views.Slice[string] {
var zero views.Slice[string]
if nm == nil || !nm.SelfNode.Valid() {
return zero
}
return nm.SelfNode.Capabilities
return nm.SelfNode.Capabilities()
}
func (nm *NetworkMap) String() string {