Commit f8a02aaf authored by Chris O'Haver's avatar Chris O'Haver Committed by GitHub

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

Signed-off-by: default avatarChris O'Haver <cohaver@infoblox.com>
parent 5bb89473
...@@ -94,6 +94,9 @@ func parseStanza(c *caddy.Controller) (*Forward, error) { ...@@ -94,6 +94,9 @@ func parseStanza(c *caddy.Controller) (*Forward, error) {
} }
origFrom := f.from origFrom := f.from
zones := plugin.Host(f.from).NormalizeExact() 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 f.from = zones[0] // there can only be one here, won't work with non-octet reverse
if len(zones) > 1 { if len(zones) > 1 {
......
...@@ -38,6 +38,7 @@ func TestSetup(t *testing.T) { ...@@ -38,6 +38,7 @@ func TestSetup(t *testing.T) {
{`forward . ::1 {`forward . ::1
forward com ::2`, true, "", nil, 0, options{hcRecursionDesired: true}, "plugin"}, 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 . 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 { for i, test := range tests {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment