mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 02:33:14 -04:00
plugin/rewrite: fix domain length validation (#2995)
* unit test * fix domain length validation * code optimization * remove unit test
This commit is contained in:
committed by
Miek Gieben
parent
a5c405f6d7
commit
69a2397bf5
@@ -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, ".") {
|
||||
|
||||
Reference in New Issue
Block a user