From 6981543db68ca7e1008871c4c1564932e5831d31 Mon Sep 17 00:00:00 2001 From: Juan Font Date: Tue, 5 Oct 2021 19:00:40 +0200 Subject: [PATCH] Only search domain from current namespace in MapResponse --- api.go | 11 ++--------- dns.go | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/api.go b/api.go index e360187c..dd762a07 100644 --- a/api.go +++ b/api.go @@ -260,16 +260,9 @@ func (h *Headscale) getMapResponse(mKey wgkey.Key, req tailcfg.MapRequest, m *Ma var dnsConfig *tailcfg.DNSConfig if h.cfg.DNSConfig != nil && 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 - } + // Only inject the Search Domain of the current namespace - shared nodes should use their full FQDN dnsConfig = h.cfg.DNSConfig.Clone() - for _, ns := range *namespaces { - dnsConfig.Domains = append(dnsConfig.Domains, fmt.Sprintf("%s.%s", ns.Name, h.cfg.BaseDomain)) - } + dnsConfig.Domains = append(dnsConfig.Domains, fmt.Sprintf("%s.%s", m.Namespace.Name, h.cfg.BaseDomain)) } else { dnsConfig = h.cfg.DNSConfig } diff --git a/dns.go b/dns.go index 74a85aee..9cd747f6 100644 --- a/dns.go +++ b/dns.go @@ -13,7 +13,7 @@ func (h *Headscale) generateMagicDNSRootDomains() (*[]dnsname.FQDN, error) { } // TODO(juanfont): we are not handing out IPv6 addresses yet - // and in fact this is Tailscale.com's range (not the fd7a:115c:a1e0: range in the fc00::/7 network) + // and in fact this is Tailscale.com's range (note the fd7a:115c:a1e0: range in the fc00::/7 network) ipv6base := dnsname.FQDN("0.e.1.a.c.5.1.1.a.7.d.f.ip6.arpa.") fqdns := []dnsname.FQDN{base, ipv6base}