aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorGravatar Chris O'Haver <cohaver@infoblox.com> 2022-05-13 23:23:28 -0400
committerGravatar GitHub <noreply@github.com> 2022-05-13 23:23:28 -0400
commit4d1d9adb0ec125097466a4831f57a22069a0d638 (patch)
tree9a0c5c6f3fd8370a2f88c4c1bad3226ae28dc203 /plugin
parentdbb8a12394e3c8a58c87d5da8a02be981c11a121 (diff)
downloadcoredns-4d1d9adb0ec125097466a4831f57a22069a0d638.tar.gz
coredns-4d1d9adb0ec125097466a4831f57a22069a0d638.tar.zst
coredns-4d1d9adb0ec125097466a4831f57a22069a0d638.zip
fix and document zone-match regex-no-match case (#5180)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
Diffstat (limited to 'plugin')
-rw-r--r--plugin/template/README.md17
-rw-r--r--plugin/template/template.go2
-rw-r--r--plugin/template/template_test.go4
3 files changed, 12 insertions, 11 deletions
diff --git a/plugin/template/README.md b/plugin/template/README.md
index bb7698b3c..5ac0c1995 100644
--- a/plugin/template/README.md
+++ b/plugin/template/README.md
@@ -17,23 +17,24 @@ template CLASS TYPE [ZONE...] {
additional RR
authority RR
rcode CODE
- fallthrough [ZONE...]
+ fallthrough [FALLTHROUGH-ZONE...]
}
~~~
* **CLASS** the query class (usually IN or ANY).
* **TYPE** the query type (A, PTR, ... can be ANY to match all types).
* **ZONE** the zone scope(s) for this template. Defaults to the server zones.
-* **REGEX** [Go regexp](https://golang.org/pkg/regexp/) that are matched against the incoming question name. Specifying no regex matches everything (default: `.*`). First matching regex wins.
+* `match` **REGEX** [Go regexp](https://golang.org/pkg/regexp/) that are matched against the incoming question name.
+ Specifying no regex matches everything (default: `.*`). First matching regex wins.
* `answer|additional|authority` **RR** A [RFC 1035](https://tools.ietf.org/html/rfc1035#section-5) style resource record fragment
- built by a [Go template](https://golang.org/pkg/text/template/) that contains the reply.
+ built by a [Go template](https://golang.org/pkg/text/template/) that contains the reply. Specifying no answer will result
+ in a response with an empty answer section.
* `rcode` **CODE** A response code (`NXDOMAIN, SERVFAIL, ...`). The default is `NOERROR`. Valid response code values are
per the `RcodeToString` map defined by the `miekg/dns` package in `msg.go`.
-* `fallthrough` Continue with the next plugin if the zone matched but no regex matched.
- If specific zones are listed (for example `in-addr.arpa` and `ip6.arpa`), then only queries for
- those zones will be subject to fallthrough.
-
-At least one `answer` or `rcode` directive is needed (e.g. `rcode NXDOMAIN`).
+* `fallthrough` Continue with the next _template_ instance if the _template_'s **ZONE** matches a query name but no regex match.
+ If there is no next _template_, continue resolution with the next plugin. If **[FALLTHROUGH-ZONE...]** are listed (for example
+ `in-addr.arpa` and `ip6.arpa`), then only queries for those zones will be subject to fallthrough. Without
+ `fallthrough`, when the _template_'s **ZONE** matches a query but no regex match then a `SERVFAIL` response is returned.
[Also see](#also-see) contains an additional reading list.
diff --git a/plugin/template/template.go b/plugin/template/template.go
index 148346823..abeadf05d 100644
--- a/plugin/template/template.go
+++ b/plugin/template/template.go
@@ -81,7 +81,7 @@ func (h Handler) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
data, match, fthrough := template.match(ctx, state)
if !match {
if !fthrough {
- return dns.RcodeNameError, nil
+ return dns.RcodeServerFailure, nil
}
continue
}
diff --git a/plugin/template/template_test.go b/plugin/template/template_test.go
index 8ceb83697..25e8df748 100644
--- a/plugin/template/template_test.go
+++ b/plugin/template/template_test.go
@@ -587,8 +587,8 @@ func TestMultiSection(t *testing.T) {
if code == rcodeFallthrough {
t.Fatalf("TestMultiSection expected no fall through resolving something.example. IN MX")
}
- if code != dns.RcodeNameError {
- t.Fatalf("TestMultiSection expected NXDOMAIN resolving something.example. IN MX, got %v, %v", code, dns.RcodeToString[code])
+ if code != dns.RcodeServerFailure {
+ t.Fatalf("TestMultiSection expected SERVFAIL resolving something.example. IN MX, got %v, %v", code, dns.RcodeToString[code])
}
}