mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 10:43:17 -04:00
only rewrite types when they are given in uppercase
This commit is contained in:
@@ -30,7 +30,7 @@ func rewriteParse(c *Controller) ([]rewrite.Rule, error) {
|
|||||||
for c.Next() {
|
for c.Next() {
|
||||||
var rule rewrite.Rule
|
var rule rewrite.Rule
|
||||||
var err error
|
var err error
|
||||||
var base = "/"
|
var base = "."
|
||||||
var pattern, to string
|
var pattern, to string
|
||||||
var status int
|
var status int
|
||||||
var ext []string
|
var ext []string
|
||||||
@@ -57,7 +57,7 @@ func rewriteParse(c *Controller) ([]rewrite.Rule, error) {
|
|||||||
return nil, c.ArgErr()
|
return nil, c.ArgErr()
|
||||||
}
|
}
|
||||||
to = strings.Join(args1, " ")
|
to = strings.Join(args1, " ")
|
||||||
case "ext":
|
case "ext": // TODO(miek): fix or remove
|
||||||
args1 := c.RemainingArgs()
|
args1 := c.RemainingArgs()
|
||||||
if len(args1) == 0 {
|
if len(args1) == 0 {
|
||||||
return nil, c.ArgErr()
|
return nil, c.ArgErr()
|
||||||
@@ -73,7 +73,7 @@ func rewriteParse(c *Controller) ([]rewrite.Rule, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ifs = append(ifs, ifCond)
|
ifs = append(ifs, ifCond)
|
||||||
case "status":
|
case "status": // TODO(miek): fix or remove
|
||||||
if !c.NextArg() {
|
if !c.NextArg() {
|
||||||
return nil, c.ArgErr()
|
return nil, c.ArgErr()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
package rewrite
|
package rewrite
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/miekg/coredns/middleware"
|
"github.com/miekg/coredns/middleware"
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
@@ -64,7 +66,15 @@ type SimpleRule struct {
|
|||||||
func NewSimpleRule(from, to string) SimpleRule {
|
func NewSimpleRule(from, to string) SimpleRule {
|
||||||
tpf := dns.StringToType[from]
|
tpf := dns.StringToType[from]
|
||||||
tpt := dns.StringToType[to]
|
tpt := dns.StringToType[to]
|
||||||
|
// It's only a type if uppercase is used.
|
||||||
|
if from != strings.ToUpper(from) {
|
||||||
|
tpf = 0
|
||||||
|
}
|
||||||
|
if to != strings.ToUpper(to) {
|
||||||
|
tpt = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// lowercase and fully qualify the others here? TODO(miek)
|
||||||
return SimpleRule{From: from, To: to, fromType: tpf, toType: tpt}
|
return SimpleRule{From: from, To: to, fromType: tpf, toType: tpt}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user