aboutsummaryrefslogtreecommitdiff
path: root/plugin/file/lookup.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2019-07-18 17:44:47 +0000
committerGravatar GitHub <noreply@github.com> 2019-07-18 17:44:47 +0000
commit1d5095cf6789fc26c7eface8b68d747d85dbf02e (patch)
treebd3ced7596b054d9f056cd5ac3787a615fc66189 /plugin/file/lookup.go
parent527772fc5f27acf1b12d7012bde6c95588d79f50 (diff)
downloadcoredns-1d5095cf6789fc26c7eface8b68d747d85dbf02e.tar.gz
coredns-1d5095cf6789fc26c7eface8b68d747d85dbf02e.tar.zst
coredns-1d5095cf6789fc26c7eface8b68d747d85dbf02e.zip
plugin/file: Rename do to walk and cleanup and document (#2987)
* plugin/file: Rename do to walk, cleanup and document * This renames Do to Walk to be more inline with Go standards. Also make it return an error instead of a bool. Also give give walk access to rrs. Alternatively e.m could be exported, but just access the map of rrs should work as well. Another alternative would be adding a whole bunch of helper functions, but those need grab and return the data. Just having access to the rrs should be easiest for most Walks. * It adds Type and TypeForWildcard to show the different functions * *Removes* the identical RR check when inserting; this was only done for A, AAAA and MX and not finished; removed under the mantra garbage in garbage out. * Reuses Types to return all the types in an *tree.Elem Signed-off-by: Miek Gieben <miek@miek.nl> * better comments Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin/file/lookup.go')
-rw-r--r--plugin/file/lookup.go42
1 files changed, 21 insertions, 21 deletions
diff --git a/plugin/file/lookup.go b/plugin/file/lookup.go
index 3a72a6163..14dfb6f7d 100644
--- a/plugin/file/lookup.go
+++ b/plugin/file/lookup.go
@@ -106,14 +106,14 @@ func (z *Zone) Lookup(ctx context.Context, state request.Request, qname string)
}
// If we see DNAME records, we should return those.
- if dnamerrs := elem.Types(dns.TypeDNAME); dnamerrs != nil {
+ if dnamerrs := elem.Type(dns.TypeDNAME); dnamerrs != nil {
// Only one DNAME is allowed per name. We just pick the first one to synthesize from.
dname := dnamerrs[0]
if cname := synthesizeCNAME(state.Name(), dname.(*dns.DNAME)); cname != nil {
answer, ns, extra, rcode := z.additionalProcessing(ctx, state, elem, []dns.RR{cname})
if do {
- sigs := elem.Types(dns.TypeRRSIG)
+ sigs := elem.Type(dns.TypeRRSIG)
sigs = signatureForSubType(sigs, dns.TypeDNAME)
dnamerrs = append(dnamerrs, sigs...)
}
@@ -130,7 +130,7 @@ func (z *Zone) Lookup(ctx context.Context, state request.Request, qname string)
}
// If we see NS records, it means the name as been delegated, and we should return the delegation.
- if nsrrs := elem.Types(dns.TypeNS); nsrrs != nil {
+ if nsrrs := elem.Type(dns.TypeNS); nsrrs != nil {
// If the query is specifically for DS and the qname matches the delegated name, we should
// return the DS in the answer section and leave the rest empty, i.e. just continue the loop
@@ -160,11 +160,11 @@ func (z *Zone) Lookup(ctx context.Context, state request.Request, qname string)
// Found entire name.
if found && shot {
- if rrs := elem.Types(dns.TypeCNAME); len(rrs) > 0 && qtype != dns.TypeCNAME {
+ if rrs := elem.Type(dns.TypeCNAME); len(rrs) > 0 && qtype != dns.TypeCNAME {
return z.additionalProcessing(ctx, state, elem, rrs)
}
- rrs := elem.Types(qtype, qname)
+ rrs := elem.Type(qtype)
// NODATA
if len(rrs) == 0 {
@@ -181,7 +181,7 @@ func (z *Zone) Lookup(ctx context.Context, state request.Request, qname string)
additional := additionalProcessing(z, rrs, do)
if do {
- sigs := elem.Types(dns.TypeRRSIG)
+ sigs := elem.Type(dns.TypeRRSIG)
sigs = signatureForSubType(sigs, qtype)
rrs = append(rrs, sigs...)
}
@@ -196,11 +196,11 @@ func (z *Zone) Lookup(ctx context.Context, state request.Request, qname string)
if wildElem != nil {
auth := z.ns(do)
- if rrs := wildElem.Types(dns.TypeCNAME, qname); len(rrs) > 0 {
+ if rrs := wildElem.TypeForWildcard(dns.TypeCNAME, qname); len(rrs) > 0 {
return z.additionalProcessing(ctx, state, wildElem, rrs)
}
- rrs := wildElem.Types(qtype, qname)
+ rrs := wildElem.TypeForWildcard(qtype, qname)
// NODATA response.
if len(rrs) == 0 {
@@ -219,7 +219,7 @@ func (z *Zone) Lookup(ctx context.Context, state request.Request, qname string)
auth = append(auth, nsec...)
}
- sigs := wildElem.Types(dns.TypeRRSIG, qname)
+ sigs := wildElem.TypeForWildcard(dns.TypeRRSIG, qname)
sigs = signatureForSubType(sigs, qtype)
rrs = append(rrs, sigs...)
@@ -272,9 +272,9 @@ Out:
// Return type tp from e and add signatures (if they exists) and do is true.
func (z *Zone) typeFromElem(elem *tree.Elem, tp uint16, do bool) []dns.RR {
- rrs := elem.Types(tp)
+ rrs := elem.Type(tp)
if do {
- sigs := elem.Types(dns.TypeRRSIG)
+ sigs := elem.Type(dns.TypeRRSIG)
sigs = signatureForSubType(sigs, tp)
if len(sigs) > 0 {
rrs = append(rrs, sigs...)
@@ -306,7 +306,7 @@ func (z *Zone) additionalProcessing(ctx context.Context, state request.Request,
do := state.Do()
if do {
- sigs := elem.Types(dns.TypeRRSIG)
+ sigs := elem.Type(dns.TypeRRSIG)
sigs = signatureForSubType(sigs, dns.TypeCNAME)
if len(sigs) > 0 {
rrs = append(rrs, sigs...)
@@ -323,12 +323,12 @@ func (z *Zone) additionalProcessing(ctx context.Context, state request.Request,
i := 0
Redo:
- cname := elem.Types(dns.TypeCNAME)
+ cname := elem.Type(dns.TypeCNAME)
if len(cname) > 0 {
rrs = append(rrs, cname...)
if do {
- sigs := elem.Types(dns.TypeRRSIG)
+ sigs := elem.Type(dns.TypeRRSIG)
sigs = signatureForSubType(sigs, dns.TypeCNAME)
if len(sigs) > 0 {
rrs = append(rrs, sigs...)
@@ -354,7 +354,7 @@ Redo:
rrs = append(rrs, targets...)
if do {
- sigs := elem.Types(dns.TypeRRSIG)
+ sigs := elem.Type(dns.TypeRRSIG)
sigs = signatureForSubType(sigs, qtype)
if len(sigs) > 0 {
rrs = append(rrs, sigs...)
@@ -416,9 +416,9 @@ func (z *Zone) searchGlue(name string, do bool) []dns.RR {
// A
if elem, found := z.Tree.Search(name); found {
- glue = append(glue, elem.Types(dns.TypeA)...)
+ glue = append(glue, elem.Type(dns.TypeA)...)
if do {
- sigs := elem.Types(dns.TypeRRSIG)
+ sigs := elem.Type(dns.TypeRRSIG)
sigs = signatureForSubType(sigs, dns.TypeA)
glue = append(glue, sigs...)
}
@@ -426,9 +426,9 @@ func (z *Zone) searchGlue(name string, do bool) []dns.RR {
// AAAA
if elem, found := z.Tree.Search(name); found {
- glue = append(glue, elem.Types(dns.TypeAAAA)...)
+ glue = append(glue, elem.Type(dns.TypeAAAA)...)
if do {
- sigs := elem.Types(dns.TypeRRSIG)
+ sigs := elem.Type(dns.TypeRRSIG)
sigs = signatureForSubType(sigs, dns.TypeAAAA)
glue = append(glue, sigs...)
}
@@ -456,9 +456,9 @@ func additionalProcessing(z *Zone, answer []dns.RR, do bool) (extra []dns.RR) {
continue
}
- sigs := elem.Types(dns.TypeRRSIG)
+ sigs := elem.Type(dns.TypeRRSIG)
for _, addr := range []uint16{dns.TypeA, dns.TypeAAAA} {
- if a := elem.Types(addr); a != nil {
+ if a := elem.Type(addr); a != nil {
extra = append(extra, a...)
if do {
sig := signatureForSubType(sigs, addr)