This commit is contained in:
Miek Gieben 2016-03-22 22:44:50 +00:00
parent a6c3719bd8
commit 8c707c8031
4 changed files with 54 additions and 36 deletions

View file

@ -1,6 +1,10 @@
package middleware
import "strings"
import (
"strings"
"github.com/miekg/dns"
)
type Zones []string
@ -11,6 +15,7 @@ func (z Zones) Matches(qname string) string {
zone := ""
// TODO(miek): use IsSubDomain here?
for _, zname := range z {
println(zname, qname)
if strings.HasSuffix(qname, zname) {
if len(zname) > len(zone) {
zone = zname
@ -19,3 +24,11 @@ func (z Zones) Matches(qname string) string {
}
return zone
}
// Fully qualify all zones in z
func (z Zones) FullyQualify() {
for i, _ := range z {
z[i] = dns.Fqdn(z[i])
}
}