|
|
|
|
@ -6,6 +6,7 @@ package testcontrol |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"bytes" |
|
|
|
|
"cmp" |
|
|
|
|
"context" |
|
|
|
|
"encoding/binary" |
|
|
|
|
"encoding/json" |
|
|
|
|
@ -476,13 +477,22 @@ func (s *Server) AddFakeNode() { |
|
|
|
|
// TODO: send updates to other (non-fake?) nodes
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (s *Server) AllUsers() (users []*tailcfg.User) { |
|
|
|
|
func (s *Server) allUserProfiles() (res []tailcfg.UserProfile) { |
|
|
|
|
s.mu.Lock() |
|
|
|
|
defer s.mu.Unlock() |
|
|
|
|
for _, u := range s.users { |
|
|
|
|
users = append(users, u.Clone()) |
|
|
|
|
for k, u := range s.users { |
|
|
|
|
up := tailcfg.UserProfile{ |
|
|
|
|
ID: u.ID, |
|
|
|
|
DisplayName: u.DisplayName, |
|
|
|
|
} |
|
|
|
|
if login, ok := s.logins[k]; ok { |
|
|
|
|
up.LoginName = login.LoginName |
|
|
|
|
up.ProfilePicURL = cmp.Or(up.ProfilePicURL, login.ProfilePicURL) |
|
|
|
|
up.DisplayName = cmp.Or(up.DisplayName, login.DisplayName) |
|
|
|
|
} |
|
|
|
|
res = append(res, up) |
|
|
|
|
} |
|
|
|
|
return users |
|
|
|
|
return res |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (s *Server) AllNodes() (nodes []*tailcfg.Node) { |
|
|
|
|
@ -523,9 +533,7 @@ func (s *Server) getUser(nodeKey key.NodePublic) (*tailcfg.User, *tailcfg.Login) |
|
|
|
|
} |
|
|
|
|
user := &tailcfg.User{ |
|
|
|
|
ID: id, |
|
|
|
|
LoginName: loginName, |
|
|
|
|
DisplayName: displayName, |
|
|
|
|
Logins: []tailcfg.LoginID{login.ID}, |
|
|
|
|
} |
|
|
|
|
s.users[nodeKey] = user |
|
|
|
|
s.logins[nodeKey] = login |
|
|
|
|
@ -1001,13 +1009,7 @@ func (s *Server) MapResponse(req *tailcfg.MapRequest) (res *tailcfg.MapResponse, |
|
|
|
|
sort.Slice(res.Peers, func(i, j int) bool { |
|
|
|
|
return res.Peers[i].ID < res.Peers[j].ID |
|
|
|
|
}) |
|
|
|
|
for _, u := range s.AllUsers() { |
|
|
|
|
res.UserProfiles = append(res.UserProfiles, tailcfg.UserProfile{ |
|
|
|
|
ID: u.ID, |
|
|
|
|
LoginName: u.LoginName, |
|
|
|
|
DisplayName: u.DisplayName, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
res.UserProfiles = s.allUserProfiles() |
|
|
|
|
|
|
|
|
|
v4Prefix := netip.PrefixFrom(netaddr.IPv4(100, 64, uint8(tailcfg.NodeID(user.ID)>>8), uint8(tailcfg.NodeID(user.ID))), 32) |
|
|
|
|
v6Prefix := netip.PrefixFrom(tsaddr.Tailscale4To6(v4Prefix.Addr()), 128) |
|
|
|
|
|