dont panic when from-zone cannot be normalized (#5170)

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
Chris O'Haver
2022-02-17 15:13:18 -05:00
committed by GitHub
parent 5bb8947309
commit f8a02aaf58
2 changed files with 4 additions and 0 deletions

View File

@@ -94,6 +94,9 @@ func parseStanza(c *caddy.Controller) (*Forward, error) {
}
origFrom := f.from
zones := plugin.Host(f.from).NormalizeExact()
if len(zones) == 0 {
return f, fmt.Errorf("unable to normalize '%s'", f.from)
}
f.from = zones[0] // there can only be one here, won't work with non-octet reverse
if len(zones) > 1 {

View File

@@ -38,6 +38,7 @@ func TestSetup(t *testing.T) {
{`forward . ::1
forward com ::2`, true, "", nil, 0, options{hcRecursionDesired: true}, "plugin"},
{"forward . https://127.0.0.1 \n", true, ".", nil, 2, options{hcRecursionDesired: true}, "'https' is not supported as a destination protocol in forward: https://127.0.0.1"},
{"forward xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 127.0.0.1 \n", true, ".", nil, 2, options{hcRecursionDesired: true}, "unable to normalize 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'"},
}
for i, test := range tests {