plugin/forward: crash if using https (#3817)
Signed-off-by: kadern0 <kaderno@gmail.com>
This commit is contained in:
parent
08120096eb
commit
e410760a49
2 changed files with 6 additions and 0 deletions
|
@ -99,8 +99,13 @@ func parseStanza(c *caddy.Controller) (*Forward, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
transports := make([]string, len(toHosts))
|
transports := make([]string, len(toHosts))
|
||||||
|
allowedTrans := map[string]bool{"dns": true, "tls": true}
|
||||||
for i, host := range toHosts {
|
for i, host := range toHosts {
|
||||||
trans, h := parse.Transport(host)
|
trans, h := parse.Transport(host)
|
||||||
|
|
||||||
|
if !allowedTrans[trans] {
|
||||||
|
return f, fmt.Errorf("'%s' is not supported as a destination protocol in forward: %s", trans, host)
|
||||||
|
}
|
||||||
p := NewProxy(h, trans)
|
p := NewProxy(h, trans)
|
||||||
f.proxies = append(f.proxies, p)
|
f.proxies = append(f.proxies, p)
|
||||||
transports[i] = trans
|
transports[i] = trans
|
||||||
|
|
|
@ -37,6 +37,7 @@ func TestSetup(t *testing.T) {
|
||||||
{"forward . 127.0.0.1 {\nblaatl\n}\n", true, "", nil, 0, options{hcRecursionDesired: true}, "unknown property"},
|
{"forward . 127.0.0.1 {\nblaatl\n}\n", true, "", nil, 0, options{hcRecursionDesired: true}, "unknown property"},
|
||||||
{`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"},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue