Do not include BaseDomain as full route in DNSConfig + code reorg

This commit is contained in:
Juan Font Alonso 2021-10-17 11:57:53 +02:00
parent a9a1a8fb3c
commit 061efa1822
2 changed files with 32 additions and 13 deletions

14
api.go
View file

@ -258,13 +258,13 @@ func (h *Headscale) getMapResponse(mKey wgkey.Key, req tailcfg.MapRequest, m *Ma
return nil, err
}
var dnsConfig *tailcfg.DNSConfig
if h.cfg.DNSConfig != nil && h.cfg.DNSConfig.Proxied { // if MagicDNS is enabled
// Only inject the Search Domain of the current namespace - shared nodes should use their full FQDN
dnsConfig = h.cfg.DNSConfig.Clone()
dnsConfig.Domains = append(dnsConfig.Domains, fmt.Sprintf("%s.%s", m.Namespace.Name, h.cfg.BaseDomain))
} else {
dnsConfig = h.cfg.DNSConfig
dnsConfig, err := h.getMapResponseDNSConfig(*m, peers)
if err != nil {
log.Error().
Str("func", "getMapResponse").
Err(err).
Msg("Failed generate the DNSConfig")
return nil, err
}
resp := tailcfg.MapResponse{