aboutsummaryrefslogtreecommitdiff
path: root/middleware/file/lookup.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2016-11-09 21:26:49 +0000
committerGravatar Miek Gieben <miek@miek.nl> 2016-11-09 21:26:49 +0000
commit0919216d3ca513d6ae18ffb0ed35b6a89fd393c6 (patch)
tree4dc5882a582b17778869428c707d6ab671c26065 /middleware/file/lookup.go
parenta8287bb04dc7861f349c96ba790e4a007dc7657c (diff)
downloadcoredns-0919216d3ca513d6ae18ffb0ed35b6a89fd393c6.tar.gz
coredns-0919216d3ca513d6ae18ffb0ed35b6a89fd393c6.tar.zst
coredns-0919216d3ca513d6ae18ffb0ed35b6a89fd393c6.zip
middleware/{file, auto}: resolve external CNAMEs
Do the same thing as in etcd and give the option of externally resolving CNAME. This is needed when CoreDNS is a proxy as well is serving zones.
Diffstat (limited to 'middleware/file/lookup.go')
-rw-r--r--middleware/file/lookup.go19
1 files changed, 16 insertions, 3 deletions
diff --git a/middleware/file/lookup.go b/middleware/file/lookup.go
index c47f1f5fa..50c99afb0 100644
--- a/middleware/file/lookup.go
+++ b/middleware/file/lookup.go
@@ -2,6 +2,7 @@ package file
import (
"github.com/miekg/coredns/middleware/file/tree"
+ "github.com/miekg/coredns/request"
"github.com/miekg/dns"
)
@@ -118,7 +119,7 @@ func (z *Zone) Lookup(qname string, qtype uint16, do bool) ([]dns.RR, []dns.RR,
// Found entire name.
if found && shot {
- // DNAME...
+ // DNAME...?
if rrs := elem.Types(dns.TypeCNAME); len(rrs) > 0 && qtype != dns.TypeCNAME {
return z.searchCNAME(elem, rrs, qtype, do)
}
@@ -260,8 +261,16 @@ func (z *Zone) searchCNAME(elem *tree.Elem, rrs []dns.RR, qtype uint16, do bool)
}
}
- elem, _ = z.Tree.Search(rrs[0].(*dns.CNAME).Target)
+ targetName := rrs[0].(*dns.CNAME).Target
+ elem, _ = z.Tree.Search(targetName)
+ println(targetName)
if elem == nil {
+ if !dns.IsSubDomain(z.origin, targetName) {
+ println(targetName, "is not a child of", z.origin)
+ }
+ st := request.Request{}
+ z.Proxy.Lookup(st, targetName, qtype)
+
return rrs, nil, nil, Success
}
@@ -279,8 +288,12 @@ Redo:
rrs = append(rrs, sigs...)
}
}
- elem, _ = z.Tree.Search(cname[0].(*dns.CNAME).Target)
+ targetName := cname[0].(*dns.CNAME).Target
+ elem, _ = z.Tree.Search(targetName)
if elem == nil {
+ if !dns.IsSubDomain(z.origin, targetName) {
+ println(targetName, "is not a child of", z.origin)
+ }
return rrs, nil, nil, Success
}