plugin/proxy: max the number of upstreams (#1359)

* plugin/proxy: max the number of upstreams

Put a max of 15 on the number of upstreams.
This commit is contained in:
Miek Gieben
2018-01-08 15:03:42 +00:00
committed by GitHub
parent dd37627e8e
commit a7590897fb
2 changed files with 17 additions and 1 deletions

View File

@@ -53,6 +53,10 @@ func NewStaticUpstreams(c *caddyfile.Dispenser) ([]Upstream, error) {
return upstreams, err
}
if len(toHosts) > max {
return upstreams, fmt.Errorf("more than %d TOs configured: %d", max, len(toHosts))
}
for c.NextBlock() {
if err := parseBlock(c, upstream); err != nil {
return upstreams, err
@@ -192,3 +196,5 @@ func (u *staticUpstream) IsAllowedDomain(name string) bool {
func (u *staticUpstream) Exchanger() Exchanger { return u.ex }
func (u *staticUpstream) From() string { return u.from }
const max = 15