mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 10:43:17 -04:00
plugin/rewrite: fix flow control logic for all rule types (#1308)
Resolves: #1307
This commit is contained in:
committed by
John Belamaric
parent
671d170619
commit
3125381f2d
@@ -8,19 +8,22 @@ import (
|
||||
)
|
||||
|
||||
type classRule struct {
|
||||
fromClass, toClass uint16
|
||||
fromClass uint16
|
||||
toClass uint16
|
||||
NextAction string
|
||||
}
|
||||
|
||||
func newClassRule(fromS, toS string) (Rule, error) {
|
||||
// newClassRule creates a class matching rule
|
||||
func newClassRule(nextAction string, args ...string) (Rule, error) {
|
||||
var from, to uint16
|
||||
var ok bool
|
||||
if from, ok = dns.StringToClass[strings.ToUpper(fromS)]; !ok {
|
||||
return nil, fmt.Errorf("invalid class %q", strings.ToUpper(fromS))
|
||||
if from, ok = dns.StringToClass[strings.ToUpper(args[0])]; !ok {
|
||||
return nil, fmt.Errorf("invalid class %q", strings.ToUpper(args[0]))
|
||||
}
|
||||
if to, ok = dns.StringToClass[strings.ToUpper(toS)]; !ok {
|
||||
return nil, fmt.Errorf("invalid class %q", strings.ToUpper(toS))
|
||||
if to, ok = dns.StringToClass[strings.ToUpper(args[1])]; !ok {
|
||||
return nil, fmt.Errorf("invalid class %q", strings.ToUpper(args[1]))
|
||||
}
|
||||
return &classRule{fromClass: from, toClass: to}, nil
|
||||
return &classRule{from, to, nextAction}, nil
|
||||
}
|
||||
|
||||
// Rewrite rewrites the the current request.
|
||||
@@ -36,5 +39,5 @@ func (rule *classRule) Rewrite(w dns.ResponseWriter, r *dns.Msg) Result {
|
||||
|
||||
// Mode returns the processing mode
|
||||
func (rule *classRule) Mode() string {
|
||||
return Stop
|
||||
return rule.NextAction
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user