mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-19 19:38:40 +00:00
all: keep UserProfiles a slice instead of a map for longer
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
parent
4d4ca2e496
commit
e5894aba42
@ -654,7 +654,7 @@ func (c *Direct) PollNetMap(ctx context.Context, maxPolls int, cb func(*NetworkM
|
|||||||
Peers: resp.Peers,
|
Peers: resp.Peers,
|
||||||
LocalPort: localPort,
|
LocalPort: localPort,
|
||||||
User: resp.Node.User,
|
User: resp.Node.User,
|
||||||
UserProfiles: make(map[tailcfg.UserID]tailcfg.UserProfile),
|
UserProfiles: resp.UserProfiles,
|
||||||
Domain: resp.Domain,
|
Domain: resp.Domain,
|
||||||
DNS: resp.DNSConfig,
|
DNS: resp.DNSConfig,
|
||||||
Hostinfo: resp.Node.Hostinfo,
|
Hostinfo: resp.Node.Hostinfo,
|
||||||
@ -662,9 +662,6 @@ func (c *Direct) PollNetMap(ctx context.Context, maxPolls int, cb func(*NetworkM
|
|||||||
DERPMap: lastDERPMap,
|
DERPMap: lastDERPMap,
|
||||||
Debug: resp.Debug,
|
Debug: resp.Debug,
|
||||||
}
|
}
|
||||||
for _, profile := range resp.UserProfiles {
|
|
||||||
nm.UserProfiles[profile.ID] = profile
|
|
||||||
}
|
|
||||||
if resp.Node.MachineAuthorized {
|
if resp.Node.MachineAuthorized {
|
||||||
nm.MachineStatus = tailcfg.MachineAuthorized
|
nm.MachineStatus = tailcfg.MachineAuthorized
|
||||||
} else {
|
} else {
|
||||||
|
@ -44,11 +44,9 @@ type NetworkMap struct {
|
|||||||
|
|
||||||
// ACLs
|
// ACLs
|
||||||
|
|
||||||
User tailcfg.UserID
|
User tailcfg.UserID
|
||||||
Domain string
|
Domain string
|
||||||
// TODO(crawshaw): reduce UserProfiles to []tailcfg.UserProfile?
|
UserProfiles []tailcfg.UserProfile
|
||||||
// There are lots of ways to slice this data, leave it up to users.
|
|
||||||
UserProfiles map[tailcfg.UserID]tailcfg.UserProfile
|
|
||||||
// TODO(crawshaw): Groups []tailcfg.Group
|
// TODO(crawshaw): Groups []tailcfg.Group
|
||||||
// TODO(crawshaw): Capabilities []tailcfg.Capability
|
// TODO(crawshaw): Capabilities []tailcfg.Capability
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ func (sb *StatusBuilder) SetSelfStatus(ss *PeerStatus) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddUser adds a user profile to the status.
|
// AddUser adds a user profile to the status.
|
||||||
func (sb *StatusBuilder) AddUser(id tailcfg.UserID, up tailcfg.UserProfile) {
|
func (sb *StatusBuilder) AddUser(up tailcfg.UserProfile) {
|
||||||
sb.mu.Lock()
|
sb.mu.Lock()
|
||||||
defer sb.mu.Unlock()
|
defer sb.mu.Unlock()
|
||||||
if sb.locked {
|
if sb.locked {
|
||||||
@ -124,7 +124,7 @@ func (sb *StatusBuilder) AddUser(id tailcfg.UserID, up tailcfg.UserProfile) {
|
|||||||
sb.st.User = make(map[tailcfg.UserID]tailcfg.UserProfile)
|
sb.st.User = make(map[tailcfg.UserID]tailcfg.UserProfile)
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.st.User[id] = up
|
sb.st.User[up.ID] = up
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddIP adds a Tailscale IP address to the status.
|
// AddIP adds a Tailscale IP address to the status.
|
||||||
|
@ -163,8 +163,8 @@ func (b *LocalBackend) UpdateStatus(sb *ipnstate.StatusBuilder) {
|
|||||||
// TODO: hostinfo, and its networkinfo
|
// TODO: hostinfo, and its networkinfo
|
||||||
// TODO: EngineStatus copy (and deprecate it?)
|
// TODO: EngineStatus copy (and deprecate it?)
|
||||||
if b.netMap != nil {
|
if b.netMap != nil {
|
||||||
for id, up := range b.netMap.UserProfiles {
|
for _, up := range b.netMap.UserProfiles {
|
||||||
sb.AddUser(id, up)
|
sb.AddUser(up)
|
||||||
}
|
}
|
||||||
for _, p := range b.netMap.Peers {
|
for _, p := range b.netMap.Peers {
|
||||||
var lastSeen time.Time
|
var lastSeen time.Time
|
||||||
|
Loading…
x
Reference in New Issue
Block a user