middleware/file: proper support for wildcard (#323)
Add support for wildcard records, while taking care of wildcard-cnames and DNSSEC. Add enough tests to check all the corner cases.
This commit is contained in:
parent
b44d82839f
commit
e43384b501
13 changed files with 437 additions and 187 deletions
|
@ -179,12 +179,22 @@ func (t *Tree) SearchGlue(qname string) (*Elem, Result) {
|
|||
}
|
||||
|
||||
// search searches the tree for qname and type. If glue is true the search *does* not
|
||||
// spot when hitting NS records, but descends in search of glue. The qtype for this
|
||||
// stop when hitting NS records, but descends in search of glue. The qtype for this
|
||||
// kind of search can only be AAAA or A.
|
||||
func (n *Node) search(qname string, qtype uint16, glue bool) (*Node, Result) {
|
||||
old := n
|
||||
|
||||
var wild *Node
|
||||
|
||||
for n != nil {
|
||||
|
||||
// Is this a wildcard that applies to us
|
||||
if n.Elem.IsWildcard() {
|
||||
if dns.IsSubDomain(n.Elem.Name()[2:], qname) {
|
||||
wild = n
|
||||
}
|
||||
}
|
||||
|
||||
switch c := Less(n.Elem, qname); {
|
||||
case c == 0:
|
||||
return n, Found
|
||||
|
@ -200,6 +210,13 @@ func (n *Node) search(qname string, qtype uint16, glue bool) (*Node, Result) {
|
|||
n = n.Right
|
||||
}
|
||||
}
|
||||
|
||||
// If we have seen a wildcard "on-the-way-to-here", we should return this wildcard
|
||||
// instead. This is to be able to have a more specific RR defined *under* the wildcard.
|
||||
if wild != nil {
|
||||
return wild, Found
|
||||
}
|
||||
|
||||
if dns.CountLabel(qname) < dns.CountLabel(old.Elem.Name()) {
|
||||
return n, EmptyNonTerminal
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue