mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-26 06:05:52 -05:00
Send UserProfile info for the peers' namespaces
This commit is contained in:
parent
8094e6fdef
commit
01f755ecf9
31
api.go
31
api.go
@ -9,6 +9,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/fatih/set"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@ -243,11 +244,7 @@ func (h *Headscale) getMapResponse(mKey wgkey.Key, req tailcfg.MapRequest, m *Ma
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
profile := tailcfg.UserProfile{
|
profiles := getMapResponseUserProfiles(*m, peers)
|
||||||
ID: tailcfg.UserID(m.NamespaceID),
|
|
||||||
LoginName: m.Namespace.Name,
|
|
||||||
DisplayName: m.Namespace.Name,
|
|
||||||
}
|
|
||||||
|
|
||||||
nodePeers, err := peers.toNodes(h.cfg.BaseDomain, h.cfg.DNSConfig, true)
|
nodePeers, err := peers.toNodes(h.cfg.BaseDomain, h.cfg.DNSConfig, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -275,10 +272,9 @@ func (h *Headscale) getMapResponse(mKey wgkey.Key, req tailcfg.MapRequest, m *Ma
|
|||||||
Domain: h.cfg.BaseDomain,
|
Domain: h.cfg.BaseDomain,
|
||||||
PacketFilter: *h.aclRules,
|
PacketFilter: *h.aclRules,
|
||||||
DERPMap: h.cfg.DerpMap,
|
DERPMap: h.cfg.DerpMap,
|
||||||
|
UserProfiles: profiles,
|
||||||
// TODO(juanfont): We should send the profiles of all the peers (this own namespace + those from the shared peers)
|
|
||||||
UserProfiles: []tailcfg.UserProfile{profile},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Trace().
|
log.Trace().
|
||||||
Str("func", "getMapResponse").
|
Str("func", "getMapResponse").
|
||||||
Str("machine", req.Hostinfo.Hostname).
|
Str("machine", req.Hostinfo.Hostname).
|
||||||
@ -419,3 +415,22 @@ func (h *Headscale) handleAuthKey(c *gin.Context, db *gorm.DB, idKey wgkey.Key,
|
|||||||
Str("ip", ip.String()).
|
Str("ip", ip.String()).
|
||||||
Msg("Successfully authenticated via AuthKey")
|
Msg("Successfully authenticated via AuthKey")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getMapResponseUserProfiles(m Machine, peers Machines) []tailcfg.UserProfile {
|
||||||
|
namespaceSet := set.New(set.ThreadSafe)
|
||||||
|
namespaceSet.Add(m.Namespace)
|
||||||
|
for _, p := range peers {
|
||||||
|
namespaceSet.Add(p.Namespace)
|
||||||
|
}
|
||||||
|
|
||||||
|
profiles := []tailcfg.UserProfile{}
|
||||||
|
for _, namespace := range namespaceSet.List() {
|
||||||
|
profiles = append(profiles,
|
||||||
|
tailcfg.UserProfile{
|
||||||
|
ID: tailcfg.UserID(namespace.(Namespace).ID),
|
||||||
|
LoginName: namespace.(Namespace).Name,
|
||||||
|
DisplayName: namespace.(Namespace).Name,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return profiles
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user