Skip to content

Commit cc13739

Browse files
return the correct SOA record when no records are found
1 parent 1d1ebf5 commit cc13739

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

handler.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,15 @@ func (handler *CoreDNSMySql) ServeDNS(ctx context.Context, w dns.ResponseWriter,
4949
return handler.errorResponse(state, dns.RcodeServerFailure, err)
5050
}
5151

52+
var appendSOA bool
5253
if len(records) == 0 {
54+
appendSOA = true
5355
// no record found but we are going to return a SOA
54-
rec := &Record{
55-
Name: qName,
56-
RecordType: "SOA",
57-
Content: "{}",
56+
recs, err := handler.findRecord(qZone, "", "SOA")
57+
if err != nil {
58+
return handler.errorResponse(state, dns.RcodeServerFailure, err)
5859
}
59-
records = append(records, rec)
60+
records = append(records, recs...)
6061
}
6162

6263
if qType == "AXFR" {
@@ -105,7 +106,11 @@ func (handler *CoreDNSMySql) ServeDNS(ctx context.Context, w dns.ResponseWriter,
105106
m.RecursionAvailable = false
106107
m.Compress = true
107108

108-
m.Answer = append(m.Answer, answers...)
109+
if !appendSOA {
110+
m.Answer = append(m.Answer, answers...)
111+
} else {
112+
m.Ns = append(m.Ns, answers...)
113+
}
109114
m.Extra = append(m.Extra, extras...)
110115

111116
state.SizeAndDo(m)

0 commit comments

Comments
 (0)