1
0
mirror of https://github.com/juanfont/headscale.git synced 2024-10-17 20:05:55 +02:00
juanfont.headscale/dns.go

31 lines
757 B
Go
Raw Normal View History

package headscale
import (
"fmt"
"tailscale.com/util/dnsname"
)
func (h *Headscale) generateMagicDNSRootDomains() (*[]dnsname.FQDN, error) {
base, err := dnsname.ToFQDN(h.cfg.BaseDomain)
if err != nil {
return nil, err
}
// TODO(juanfont): we are not handing out IPv6 addresses yet
// 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}
2021-10-05 19:01:56 +02:00
// TODO(juanfont): This only works for the 100.64.0.0/10 range.
for i := 64; i <= 127; i++ {
fqdn, err := dnsname.ToFQDN(fmt.Sprintf("%d.100.in-addr.arpa.", i))
if err != nil {
continue
}
fqdns = append(fqdns, fqdn)
}
return &fqdns, nil
}