mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-30 02:43:05 +00:00
Send search domains
This commit is contained in:
parent
45e71ecba0
commit
36ae14bccf
1 changed files with 17 additions and 1 deletions
18
api.go
18
api.go
|
@ -241,11 +241,27 @@ func (h *Headscale) getMapResponse(mKey wgkey.Key, req tailcfg.MapRequest, m Mac
|
||||||
DisplayName: m.Namespace.Name,
|
DisplayName: m.Namespace.Name,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var dnsConfig *tailcfg.DNSConfig
|
||||||
|
if h.cfg.DNSConfig.Proxied { // if MagicDNS is enabled
|
||||||
|
// TODO(juanfont): We should not be regenerating this all the time
|
||||||
|
// And we should only send the domains of the peers (this own namespace + those from the shared peers)
|
||||||
|
namespaces, err := h.ListNamespaces()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
dnsConfig := h.cfg.DNSConfig.Clone()
|
||||||
|
for _, ns := range *namespaces {
|
||||||
|
dnsConfig.Domains = append(dnsConfig.Domains, fmt.Sprintf("%s.%s", ns.Name, h.cfg.BaseDomain))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dnsConfig = h.cfg.DNSConfig
|
||||||
|
}
|
||||||
|
|
||||||
resp := tailcfg.MapResponse{
|
resp := tailcfg.MapResponse{
|
||||||
KeepAlive: false,
|
KeepAlive: false,
|
||||||
Node: node,
|
Node: node,
|
||||||
Peers: *peers,
|
Peers: *peers,
|
||||||
DNSConfig: h.cfg.DNSConfig,
|
DNSConfig: dnsConfig,
|
||||||
Domain: h.cfg.BaseDomain,
|
Domain: h.cfg.BaseDomain,
|
||||||
PacketFilter: *h.aclRules,
|
PacketFilter: *h.aclRules,
|
||||||
DERPMap: h.cfg.DerpMap,
|
DERPMap: h.cfg.DerpMap,
|
||||||
|
|
Loading…
Reference in a new issue