Fix NODATA/NXDOMAIN for unknown types in etcd (#113)
* Finish the nodata stuff. See issue #9 * middleware/etc: add response to SOA queries * Remove and add a few TODOs
This commit is contained in:
parent
25cf16af0e
commit
a441f93e0c
5 changed files with 47 additions and 24 deletions
|
@ -2,7 +2,6 @@ package etcd
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/miekg/coredns/middleware"
|
||||
|
||||
|
@ -22,8 +21,7 @@ func (e Etcd) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (i
|
|||
name := state.Name()
|
||||
if e.Stubmap != nil && len(*e.Stubmap) > 0 {
|
||||
for zone, _ := range *e.Stubmap {
|
||||
// TODO(miek): use the Match function.
|
||||
if strings.HasSuffix(name, zone) {
|
||||
if middleware.Name(zone).Matches(name) {
|
||||
stub := Stub{Etcd: e, Zone: zone}
|
||||
return stub.ServeDNS(ctx, w, r)
|
||||
}
|
||||
|
@ -56,15 +54,15 @@ func (e Etcd) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (i
|
|||
records, extra, err = e.MX(zone, state)
|
||||
case "SRV":
|
||||
records, extra, err = e.SRV(zone, state)
|
||||
case "SOA":
|
||||
records = []dns.RR{e.SOA(zone, state)}
|
||||
case "NS":
|
||||
//TODO(miek): skydns had a thing that you specify this, should look for
|
||||
//records otherwise synthesise them.
|
||||
//records = e.NS(zone, state)
|
||||
default:
|
||||
// For SOA and NS we might still want this
|
||||
// and use dns.<zones> as the name to put these
|
||||
// also for stub
|
||||
// rwrite and return
|
||||
// Nodata response
|
||||
// also catch other types, so that they return NODATA
|
||||
// TODO(miek) nodata function see below
|
||||
return 0, nil
|
||||
// Do a fake A lookup, so we can distinguish betwen NODATA and NXDOMAIN
|
||||
_, err = e.A(zone, state, nil)
|
||||
}
|
||||
if isEtcdNameError(err) {
|
||||
return e.Err(zone, dns.RcodeNameError, state)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue