From e1d0b63e3fade23864b0937300d637f6fa8bc56b Mon Sep 17 00:00:00 2001 From: Chris O'Haver Date: Sat, 1 Jun 2019 03:40:12 -0400 Subject: [PATCH] allow an empty response (#2855) --- plugin/template/setup.go | 4 ---- plugin/template/setup_test.go | 14 +++++++------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/plugin/template/setup.go b/plugin/template/setup.go index 9f122277a..33eeb086f 100644 --- a/plugin/template/setup.go +++ b/plugin/template/setup.go @@ -155,10 +155,6 @@ func templateParse(c *caddy.Controller) (handler Handler, err error) { t.regex = append(t.regex, regexp.MustCompile(".*")) } - 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) - } - handler.Templates = append(handler.Templates, t) } diff --git a/plugin/template/setup_test.go b/plugin/template/setup_test.go index 64afac32a..f0eb33be1 100644 --- a/plugin/template/setup_test.go +++ b/plugin/template/setup_test.go @@ -36,13 +36,6 @@ func TestSetupParse(t *testing.T) { {`template X`, true}, {`template ANY`, true}, {`template ANY X`, true}, - {`template ANY ANY (?P`, true}, - { - `template ANY ANY { - - }`, - true, - }, { `template ANY ANY .* { notavailable @@ -92,6 +85,13 @@ func TestSetupParse(t *testing.T) { true, }, // examples + {`template ANY ANY (?P`, false}, + { + `template ANY ANY { + + }`, + false, + }, { `template ANY A example.com { match ip-(?P[0-9]*)-(?P[0-9]*)-(?P[0-9]*)-(?P[0-9]*)[.]example[.]com