diff options
author | 2016-04-12 22:34:44 +0100 | |
---|---|---|
committer | 2016-04-12 22:34:44 +0100 | |
commit | 25cf16af0e816a2b321cf9ed46e91c1ef067927e (patch) | |
tree | a786606d66313a136e03275db59e7efd1e3ef285 /middleware/zone.go | |
parent | 842953f17936ac02a7d9c82cb31ef70b5bcc1dc5 (diff) | |
download | coredns-25cf16af0e816a2b321cf9ed46e91c1ef067927e.tar.gz coredns-25cf16af0e816a2b321cf9ed46e91c1ef067927e.tar.zst coredns-25cf16af0e816a2b321cf9ed46e91c1ef067927e.zip |
Use dns.IsSubDomain (#112)
For the match function use the proper thing from go dns. Fix all
callers and tests to use this.
Fixes: #107
Diffstat (limited to 'middleware/zone.go')
-rw-r--r-- | middleware/zone.go | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/middleware/zone.go b/middleware/zone.go index 46c17b62d..0f3cd0edc 100644 --- a/middleware/zone.go +++ b/middleware/zone.go @@ -1,21 +1,16 @@ package middleware -import ( - "strings" - - "github.com/miekg/dns" -) +import "github.com/miekg/dns" type Zones []string -// Matches checks to see if other matches p. The match will return the most -// specific zones that matches other. The empty string signals a not found -// condition. +// Matches checks is qname is a subdomain of any of the zones in z. The match +// will return the most specific zones that matches other. The empty string +// signals a not found condition. func (z Zones) Matches(qname string) string { zone := "" - // TODO(miek): use IsSubDomain here? for _, zname := range z { - if strings.HasSuffix(qname, zname) { + if dns.IsSubDomain(zname, qname) { if len(zname) > len(zone) { zone = zname } |