plugin/rewrite: fix domain length validation (#2995)

* unit test

* fix domain length validation

* code optimization

* remove unit test
This commit is contained in:
Ruslan Drozhdzh
2019-07-12 15:22:45 +03:00
committed by Miek Gieben
parent a5c405f6d7
commit 69a2397bf5
2 changed files with 3 additions and 19 deletions

View File

@@ -9,8 +9,6 @@ import (
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/request"
"github.com/miekg/dns"
)
type exactNameRule struct {
@@ -264,19 +262,6 @@ func (rule *substringNameRule) GetResponseRule() ResponseRule { return ResponseR
// GetResponseRule return a rule to rewrite the response with.
func (rule *regexNameRule) GetResponseRule() ResponseRule { return rule.ResponseRule }
// validName returns true if s is valid domain name and shorter than 256 characters.
func validName(s string) bool {
_, ok := dns.IsDomainName(s)
if !ok {
return false
}
if len(dns.Name(s).String()) > 255 {
return false
}
return true
}
// hasClosingDot return true if s has a closing dot at the end.
func hasClosingDot(s string) bool {
if strings.HasSuffix(s, ".") {