mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-23 18:15:26 +00:00
Make displayName include basedomain if set
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
e7f322b9b6
commit
99e33181b2
@ -35,7 +35,7 @@ func (h *Headscale) generateMapResponse(
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
profiles := getMapResponseUserProfiles(*machine, peers)
|
profiles := h.getMapResponseUserProfiles(*machine, peers)
|
||||||
|
|
||||||
nodePeers, err := peers.toNodes(h.cfg.BaseDomain, h.cfg.DNSConfig)
|
nodePeers, err := peers.toNodes(h.cfg.BaseDomain, h.cfg.DNSConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -211,7 +211,10 @@ func (n *Namespace) toLogin() *tailcfg.Login {
|
|||||||
return &login
|
return &login
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMapResponseUserProfiles(machine Machine, peers Machines) []tailcfg.UserProfile {
|
func (h *Headscale) getMapResponseUserProfiles(
|
||||||
|
machine Machine,
|
||||||
|
peers Machines,
|
||||||
|
) []tailcfg.UserProfile {
|
||||||
namespaceMap := make(map[string]Namespace)
|
namespaceMap := make(map[string]Namespace)
|
||||||
namespaceMap[machine.Namespace.Name] = machine.Namespace
|
namespaceMap[machine.Namespace.Name] = machine.Namespace
|
||||||
for _, peer := range peers {
|
for _, peer := range peers {
|
||||||
@ -220,11 +223,17 @@ func getMapResponseUserProfiles(machine Machine, peers Machines) []tailcfg.UserP
|
|||||||
|
|
||||||
profiles := []tailcfg.UserProfile{}
|
profiles := []tailcfg.UserProfile{}
|
||||||
for _, namespace := range namespaceMap {
|
for _, namespace := range namespaceMap {
|
||||||
|
displayName := namespace.Name
|
||||||
|
|
||||||
|
if h.cfg.BaseDomain != "" {
|
||||||
|
displayName = fmt.Sprintf("%s@%s", namespace.Name, h.cfg.BaseDomain)
|
||||||
|
}
|
||||||
|
|
||||||
profiles = append(profiles,
|
profiles = append(profiles,
|
||||||
tailcfg.UserProfile{
|
tailcfg.UserProfile{
|
||||||
ID: tailcfg.UserID(namespace.ID),
|
ID: tailcfg.UserID(namespace.ID),
|
||||||
LoginName: namespace.Name,
|
LoginName: namespace.Name,
|
||||||
DisplayName: namespace.Name,
|
DisplayName: displayName,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ func (s *Suite) TestGetMapResponseUserProfiles(c *check.C) {
|
|||||||
peersOfMachine1InShared1, err := app.getPeers(machineInShared1)
|
peersOfMachine1InShared1, err := app.getPeers(machineInShared1)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
|
||||||
userProfiles := getMapResponseUserProfiles(
|
userProfiles := app.getMapResponseUserProfiles(
|
||||||
*machineInShared1,
|
*machineInShared1,
|
||||||
peersOfMachine1InShared1,
|
peersOfMachine1InShared1,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user