types/netmap,*: pass around UserProfiles as views (pointers) instead

Smaller.

Updates tailscale/corp#26058 (@andrew-d noticed during this)

Change-Id: Id33cddd171aaf8f042073b6d3c183b0a746e9931
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2025-01-24 19:41:30 -08:00
committed by Brad Fitzpatrick
parent 1047d11102
commit 9706c9f4ff
7 changed files with 51 additions and 29 deletions

View File

@@ -76,7 +76,9 @@ type NetworkMap struct {
// If this is empty, then data-plane audit logging is disabled.
DomainAuditLogID string
UserProfiles map[tailcfg.UserID]tailcfg.UserProfile
// UserProfiles contains the profile information of UserIDs referenced
// in SelfNode and Peers.
UserProfiles map[tailcfg.UserID]tailcfg.UserProfileView
// MaxKeyDuration describes the MaxKeyDuration setting for the tailnet.
MaxKeyDuration time.Duration
@@ -289,7 +291,12 @@ func (nm *NetworkMap) PeerWithStableID(pid tailcfg.StableNodeID) (_ tailcfg.Node
func (nm *NetworkMap) printConciseHeader(buf *strings.Builder) {
fmt.Fprintf(buf, "netmap: self: %v auth=%v",
nm.NodeKey.ShortString(), nm.GetMachineStatus())
login := nm.UserProfiles[nm.User()].LoginName
var login string
up, ok := nm.UserProfiles[nm.User()]
if ok {
login = up.LoginName()
}
if login == "" {
if nm.User().IsZero() {
login = "?"