From a6c34bdc28a18badeb661761cdb64481e8a484ab Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 14 Oct 2020 19:07:31 -0700 Subject: [PATCH] control/controlclient: also include our own profile (for when no self-owned peers) Fix from regression in previous commit (0e3048d8e01921758655dea212ecf010346d9300) 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. --- control/controlclient/direct.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/control/controlclient/direct.go b/control/controlclient/direct.go index 977825400..3de527dfd 100644 --- a/control/controlclient/direct.go +++ b/control/controlclient/direct.go @@ -712,16 +712,19 @@ func (c *Direct) PollNetMap(ctx context.Context, maxPolls int, cb func(*NetworkM DERPMap: lastDERPMap, Debug: resp.Debug, } - for _, peer := range resp.Peers { - userID := peer.User - if _, ok := nm.UserProfiles[userID]; ok { + addUserProfile := func(userID tailcfg.UserID) { + if _, dup := nm.UserProfiles[userID]; dup { // Already populated it from a previous peer. - continue + return } if up, ok := lastUserProfile[userID]; ok { nm.UserProfiles[userID] = up } } + addUserProfile(nm.User) + for _, peer := range resp.Peers { + addUserProfile(peer.User) + } if resp.Node.MachineAuthorized { nm.MachineStatus = tailcfg.MachineAuthorized } else {