diff options
author | 2018-05-21 08:45:45 +0200 | |
---|---|---|
committer | 2018-05-21 07:45:45 +0100 | |
commit | 0d305387f7974e3b493ef73c965795313279700b (patch) | |
tree | 29e431cb39f3e66453dcb48218fd7a33b64e1657 /plugin/template | |
parent | a40345d65fa5925d10ce38ea61a7256e6ba7a89b (diff) | |
download | coredns-0d305387f7974e3b493ef73c965795313279700b.tar.gz coredns-0d305387f7974e3b493ef73c965795313279700b.tar.zst coredns-0d305387f7974e3b493ef73c965795313279700b.zip |
plugin/template: Support NODATA responses (#1816)
A NODATA response has no answers and rcode NOERROR, but should have a
SOA record in the authority section.
Diffstat (limited to 'plugin/template')
-rw-r--r-- | plugin/template/setup.go | 2 | ||||
-rw-r--r-- | plugin/template/setup_test.go | 10 |
2 files changed, 10 insertions, 2 deletions
diff --git a/plugin/template/setup.go b/plugin/template/setup.go index a1190d481..8c55f4115 100644 --- a/plugin/template/setup.go +++ b/plugin/template/setup.go @@ -159,7 +159,7 @@ func templateParse(c *caddy.Controller) (handler Handler, err error) { t.regex = append(t.regex, regexp.MustCompile(".*")) } - if len(t.answer) == 0 && len(t.additional) == 0 && t.rcode == dns.RcodeSuccess { + if len(t.answer) == 0 && len(t.authority) == 0 && t.rcode == dns.RcodeSuccess { return handler, c.Errf("no answer section for template found: %v", handler) } diff --git a/plugin/template/setup_test.go b/plugin/template/setup_test.go index e4d4ff804..7581bd306 100644 --- a/plugin/template/setup_test.go +++ b/plugin/template/setup_test.go @@ -101,10 +101,18 @@ func TestSetupParse(t *testing.T) { false, }, { + `template ANY AAAA example.com { + match ip-(?P<a>[0-9]*)-(?P<b>[0-9]*)-(?P<c>[0-9]*)-(?P<d>[0-9]*)[.]example[.]com + authority "example.com 60 IN SOA ns.example.com hostmaster.example.com (1 60 60 60 60)" + fallthrough + }`, + false, + }, + { `template IN ANY example.com { match "[.](example[.]com[.]dc1[.]example[.]com[.])$" rcode NXDOMAIN - answer "{{ index .Match 1 }} 60 IN SOA a.{{ index .Match 1 }} b.{{ index .Match 1 }} (1 60 60 60 60)" + authority "{{ index .Match 1 }} 60 IN SOA ns.{{ index .Match 1 }} hostmaster.example.com (1 60 60 60 60)" fallthrough example.com }`, false, |