Files
coredns/middleware/name.go

26 lines
548 B
Go
Raw Normal View History

2016-03-19 11:16:08 +00:00
package middleware
import (
"strings"
"github.com/miekg/dns"
)
2016-03-19 11:16:08 +00:00
// Name represents a domain name.
type Name string
// Matches checks to see if other is a subdomain (or the same domain) of n.
// This method assures that names can be easily and consistently matched.
func (n Name) Matches(child string) bool {
if dns.Name(n) == dns.Name(child) {
return true
}
return dns.IsSubDomain(string(n), child)
2016-03-19 11:16:08 +00:00
}
// Normalize lowercases and makes n fully qualified.
func (n Name) Normalize() string {
return strings.ToLower(dns.Fqdn(string(n)))
}