2016-03-19 11:16:08 +00:00
|
|
|
package middleware
|
|
|
|
|
|
2016-03-20 10:44:03 +00:00
|
|
|
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 matches n.
|
|
|
|
|
//
|
|
|
|
|
// Name matching will probably not always be a direct
|
|
|
|
|
// comparison; this method assures that names can be
|
|
|
|
|
// easily and consistently matched.
|
|
|
|
|
func (n Name) Matches(other string) bool {
|
|
|
|
|
return strings.HasSuffix(string(n), other)
|
|
|
|
|
}
|
2016-03-20 10:44:03 +00:00
|
|
|
|
|
|
|
|
// Normalize lowercases and makes n fully qualified.
|
|
|
|
|
func (n Name) Normalize() string {
|
|
|
|
|
return strings.ToLower(dns.Fqdn(string(n)))
|
|
|
|
|
}
|