Improve conformance with DNS behavior
This commit is contained in:
parent
b79df4bf1d
commit
07da2a1269
6 changed files with 96 additions and 50 deletions
|
|
@ -78,11 +78,10 @@ func setup(c *caddy.Controller) error {
|
|||
func init() { plugin.Register("yaml", setup) }
|
||||
|
||||
func (y YamlPlugin) lookupRRs(qname string, qtype string, reply *dns.Msg) (int, error) {
|
||||
var rcode int
|
||||
res, ok := y.Zone.LookupType(qname, qtype)
|
||||
if !ok {
|
||||
// NXDOMAIN
|
||||
rcode = dns.RcodeNameError
|
||||
reply.Rcode = dns.RcodeNameError
|
||||
}
|
||||
if res.IsReferral {
|
||||
reply.Authoritative = false
|
||||
|
|
@ -101,12 +100,14 @@ func (y YamlPlugin) lookupRRs(qname string, qtype string, reply *dns.Msg) (int,
|
|||
if ttl == 0 {
|
||||
ttl = y.Config.DefaultTtl
|
||||
}
|
||||
rr, err := dns.NewRR(fmt.Sprintf("%s %d %s %s", record.Name, ttl, record.Record.Type, record.Record.Value))
|
||||
rrString := fmt.Sprintf("%s %d %s %s", record.Name, ttl, record.Record.Type, record.Record.Value)
|
||||
rr, err := dns.NewRR(rrString)
|
||||
if err != nil {
|
||||
return rcode, fmt.Errorf("failed to generate RR for %s %s %s: %w", record.Name, record.Record.Type, record.Record.Value, err)
|
||||
log.Errorf("Failed to parse RR string: %q", rrString)
|
||||
return reply.Rcode, fmt.Errorf("failed to generate RR for %s %s %s: %w", record.Name, record.Record.Type, record.Record.Value, err)
|
||||
}
|
||||
*section.dest = append(*section.dest, rr)
|
||||
}
|
||||
}
|
||||
return rcode, nil
|
||||
return reply.Rcode, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue