aboutsummaryrefslogtreecommitdiff
path: root/plugin/rewrite
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/rewrite')
-rw-r--r--plugin/rewrite/name.go15
-rw-r--r--plugin/rewrite/rewrite.go7
2 files changed, 3 insertions, 19 deletions
diff --git a/plugin/rewrite/name.go b/plugin/rewrite/name.go
index 86a5f1ecd..e1c2a1114 100644
--- a/plugin/rewrite/name.go
+++ b/plugin/rewrite/name.go
@@ -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, ".") {
diff --git a/plugin/rewrite/rewrite.go b/plugin/rewrite/rewrite.go
index 906523326..e72e975b2 100644
--- a/plugin/rewrite/rewrite.go
+++ b/plugin/rewrite/rewrite.go
@@ -44,11 +44,10 @@ func (rw Rewrite) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
for _, rule := range rw.Rules {
switch result := rule.Rewrite(ctx, state); result {
case RewriteDone:
- if !validName(state.Req.Question[0].Name) {
- x := state.Req.Question[0].Name
- log.Errorf("Invalid name after rewrite: %s", x)
+ if _, ok := dns.IsDomainName(state.Req.Question[0].Name); !ok {
+ err := fmt.Errorf("invalid name after rewrite: %s", state.Req.Question[0].Name)
state.Req.Question[0] = wr.originalQuestion
- return dns.RcodeServerFailure, fmt.Errorf("invalid name after rewrite: %s", x)
+ return dns.RcodeServerFailure, err
}
respRule := rule.GetResponseRule()
if respRule.Active {