Files
coredns/middleware/zone.go

28 lines
591 B
Go
Raw Normal View History

2016-03-18 20:57:35 +00:00
package middleware
import "github.com/miekg/dns"
2016-03-18 20:57:35 +00:00
type Zones []string
// 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.
2016-03-18 20:57:35 +00:00
func (z Zones) Matches(qname string) string {
zone := ""
for _, zname := range z {
if dns.IsSubDomain(zname, qname) {
2016-03-18 20:57:35 +00:00
if len(zname) > len(zone) {
zone = zname
}
}
}
return zone
}
2016-03-22 22:44:50 +00:00
// FullyQualify fully qualifies all zones in z.
2016-03-22 22:44:50 +00:00
func (z Zones) FullyQualify() {
for i, _ := range z {
z[i] = dns.Fqdn(z[i])
}
}