control/controlclient: also include our own profile (for when no self-owned peers)

Fix from regression in previous commit
(0e3048d8e0) that was caught by e2e
tests.

In that previous commit, the user's own profile was omitted from the
NetworkMap in the case where the user only had one node.
pull/827/head
Brad Fitzpatrick 4 years ago
parent 0e3048d8e0
commit a6c34bdc28

@ -712,16 +712,19 @@ func (c *Direct) PollNetMap(ctx context.Context, maxPolls int, cb func(*NetworkM
DERPMap: lastDERPMap, DERPMap: lastDERPMap,
Debug: resp.Debug, Debug: resp.Debug,
} }
for _, peer := range resp.Peers { addUserProfile := func(userID tailcfg.UserID) {
userID := peer.User if _, dup := nm.UserProfiles[userID]; dup {
if _, ok := nm.UserProfiles[userID]; ok {
// Already populated it from a previous peer. // Already populated it from a previous peer.
continue return
} }
if up, ok := lastUserProfile[userID]; ok { if up, ok := lastUserProfile[userID]; ok {
nm.UserProfiles[userID] = up nm.UserProfiles[userID] = up
} }
} }
addUserProfile(nm.User)
for _, peer := range resp.Peers {
addUserProfile(peer.User)
}
if resp.Node.MachineAuthorized { if resp.Node.MachineAuthorized {
nm.MachineStatus = tailcfg.MachineAuthorized nm.MachineStatus = tailcfg.MachineAuthorized
} else { } else {

Loading…
Cancel
Save