Skip to content
Snippets Groups Projects
Commit 12b7e8ac authored by ale's avatar ale
Browse files

Ensure that NS records are dot-terminated

parent 35ec85f2
Branches
No related tags found
No related merge requests found
......@@ -19,9 +19,7 @@ const (
)
func newDNSHandler(n *Node, origin string, nameservers []string) dns.Handler {
if !strings.HasSuffix(origin, ".") {
origin += "."
}
origin = ensureFinalDot(origin)
dnsz := newDNSZone(n.lb, origin, nameservers)
mux := dns.NewServeMux()
......@@ -90,7 +88,7 @@ func (d *dnsZone) ServeDNS(w dns.ResponseWriter, req *dns.Msg) {
Class: dns.ClassINET,
Ttl: nsTTL,
},
Ns: ns,
Ns: ensureFinalDot(ns),
})
}
......@@ -238,3 +236,11 @@ func runDNSServerWithContext(ctx context.Context, srv *dns.Server) error {
}()
return srv.ListenAndServe()
}
func ensureFinalDot(s string) string {
if !strings.HasSuffix(s, ".") {
return s + "."
}
return s
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment