Skip to content

Commit

Permalink
fix: return full answer for root ns lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
tinyzimmer committed Jul 28, 2023
1 parent c5d1aac commit f90d3a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions pkg/services/meshdns/default_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func (s *Server) handleDefault(ctx context.Context, w dns.ResponseWriter, r *dns
s.log.Debug("handling root NS request")
// newMsg automatically adds the NS records for the root zone
m := s.newMsg(r)
m.Answer = append(m.Answer, s.newNSRecord())
s.writeMsg(w, r, m, dns.RcodeSuccess)
return
}
Expand Down
18 changes: 14 additions & 4 deletions pkg/services/meshdns/server_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,27 @@ func (s *Server) newFQDN(id string) string {
return fmt.Sprintf("%s.%s", id, s.store.Domain())
}

func (s *Server) newNSRecord() dns.RR {
return &dns.NS{
Hdr: dns.RR_Header{
Name: s.store.Domain(),
Rrtype: dns.TypeNS,
Class: dns.ClassINET,
Ttl: 1,
Rdlength: 0,
},
Ns: fmt.Sprintf("%s.%s", s.store.ID(), s.store.Domain()),
}
}

func (s *Server) newMsg(r *dns.Msg) *dns.Msg {
m := new(dns.Msg)
m.SetReply(r)
m.Compress = s.opts.Compression
m.Authoritative = true
m.RecursionAvailable = true
// m.Response = true
m.Ns = []dns.RR{&dns.SOA{
Hdr: dns.RR_Header{Name: s.store.Domain(), Rrtype: dns.TypeSOA, Class: dns.ClassINET, Ttl: 1},
Ns: fmt.Sprintf("%s.%s", s.store.ID(), s.store.Domain()),
}}
m.Ns = []dns.RR{s.newNSRecord()}
return m
}

Expand Down

0 comments on commit f90d3a8

Please sign in to comment.