Files
coredns/middleware/zone.go

22 lines
462 B
Go
Raw Normal View History

2016-03-18 20:57:35 +00:00
package middleware
import "strings"
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
2016-03-18 20:57:35 +00:00
// condition.
func (z Zones) Matches(qname string) string {
zone := ""
// TODO(miek): use IsSubDomain here?
2016-03-18 20:57:35 +00:00
for _, zname := range z {
if strings.HasSuffix(qname, zname) {
if len(zname) > len(zone) {
zone = zname
}
}
}
return zone
}