plugin/hosts: Modifies NODATA handling (#3536)

* Modifies NODATA handling

Signed-off-by: ykhr53 <ykhr53@yokohei.com>

* fix some comments

Signed-off-by: ykhr53 <ykhr53@yokohei.com>

* fix test code to take care NODATA

Signed-off-by: ykhr53 <ykhr53@yokohei.com>

* add if statement to avoid nil pointer

Signed-off-by: ykhr53 <ykhr53@yokohei.com>

* Modifies NODATA handling

Signed-off-by: ykhr53 <ykhr53@yokohei.com>

* fix some comments

Signed-off-by: ykhr53 <ykhr53@yokohei.com>

* fix test code to take care NODATA

Signed-off-by: ykhr53 <ykhr53@yokohei.com>

* add if statement to avoid nil pointer

Signed-off-by: ykhr53 <ykhr53@yokohei.com>
This commit is contained in:
Kohei Yoshida
2020-02-24 19:03:53 +00:00
committed by GitHub
parent 1b9936b592
commit 813cc5d08e
2 changed files with 42 additions and 22 deletions

View File

@@ -52,15 +52,15 @@ func (h Hosts) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (
answers = aaaa(qname, h.options.ttl, ips)
}
if len(answers) == 0 {
// Only on NXDOMAIN we will fallthrough.
if len(answers) == 0 && !h.otherRecordsExist(qname) {
if h.Fall.Through(qname) {
return plugin.NextOrFailure(h.Name(), h.Next, ctx, w, r)
}
// We want to send an NXDOMAIN, but because of /etc/hosts' setup we don't have a SOA, so we make it REFUSED
// We want to send an NXDOMAIN, but because of /etc/hosts' setup we don't have a SOA, so we make it SERVFAIL
// to at least give an answer back to signals we're having problems resolving this.
if !h.otherRecordsExist(qname) {
return dns.RcodeServerFailure, nil
}
return dns.RcodeServerFailure, nil
}
m := new(dns.Msg)