mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-27 20:15:25 +00:00
Do not use the full application for getMapResponseDNSConfig
This commit is contained in:
parent
01f755ecf9
commit
687e8d12be
2
api.go
2
api.go
@ -255,7 +255,7 @@ func (h *Headscale) getMapResponse(mKey wgkey.Key, req tailcfg.MapRequest, m *Ma
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
dnsConfig, err := h.getMapResponseDNSConfig(*m, peers)
|
dnsConfig, err := getMapResponseDNSConfig(h.cfg.DNSConfig, h.cfg.BaseDomain, *m, peers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().
|
log.Error().
|
||||||
Str("func", "getMapResponse").
|
Str("func", "getMapResponse").
|
||||||
|
12
dns.go
12
dns.go
@ -69,12 +69,12 @@ func generateMagicDNSRootDomains(ipPrefix netaddr.IPPrefix, baseDomain string) (
|
|||||||
return fqdns, nil
|
return fqdns, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Headscale) getMapResponseDNSConfig(m Machine, peers Machines) (*tailcfg.DNSConfig, error) {
|
func getMapResponseDNSConfig(dnsConfigOrig *tailcfg.DNSConfig, baseDomain string, m Machine, peers Machines) (*tailcfg.DNSConfig, error) {
|
||||||
var dnsConfig *tailcfg.DNSConfig
|
var dnsConfig *tailcfg.DNSConfig
|
||||||
if h.cfg.DNSConfig != nil && h.cfg.DNSConfig.Proxied { // if MagicDNS is enabled
|
if dnsConfigOrig != nil && dnsConfigOrig.Proxied { // if MagicDNS is enabled
|
||||||
// Only inject the Search Domain of the current namespace - shared nodes should use their full FQDN
|
// Only inject the Search Domain of the current namespace - shared nodes should use their full FQDN
|
||||||
dnsConfig = h.cfg.DNSConfig.Clone()
|
dnsConfig = dnsConfigOrig.Clone()
|
||||||
dnsConfig.Domains = append(dnsConfig.Domains, fmt.Sprintf("%s.%s", m.Namespace.Name, h.cfg.BaseDomain))
|
dnsConfig.Domains = append(dnsConfig.Domains, fmt.Sprintf("%s.%s", m.Namespace.Name, baseDomain))
|
||||||
|
|
||||||
namespaceSet := set.New(set.ThreadSafe)
|
namespaceSet := set.New(set.ThreadSafe)
|
||||||
namespaceSet.Add(m.Namespace)
|
namespaceSet.Add(m.Namespace)
|
||||||
@ -82,11 +82,11 @@ func (h *Headscale) getMapResponseDNSConfig(m Machine, peers Machines) (*tailcfg
|
|||||||
namespaceSet.Add(p.Namespace)
|
namespaceSet.Add(p.Namespace)
|
||||||
}
|
}
|
||||||
for _, namespace := range namespaceSet.List() {
|
for _, namespace := range namespaceSet.List() {
|
||||||
dnsRoute := dnsname.FQDN(fmt.Sprintf("%s.%s", namespace.(Namespace).Name, h.cfg.BaseDomain))
|
dnsRoute := dnsname.FQDN(fmt.Sprintf("%s.%s", namespace.(Namespace).Name, baseDomain))
|
||||||
dnsConfig.Routes[dnsRoute.WithoutTrailingDot()] = nil
|
dnsConfig.Routes[dnsRoute.WithoutTrailingDot()] = nil
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dnsConfig = h.cfg.DNSConfig
|
dnsConfig = dnsConfigOrig
|
||||||
}
|
}
|
||||||
return dnsConfig, nil
|
return dnsConfig, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user