mirror of
https://github.com/haproxy/haproxy.git
synced 2026-06-11 01:41:49 -04:00
[PATCH]: Check for duplicated conflicting proxies
Currently haproxy accepts a config with duplicated proxies
(listen/fronted/backed/ruleset). This patch fix this, so the application
will complain when there is an error.
With this modification it is still possible to use the same name for two
proxies (for example frontend&backend) as long there is no conflict:
listen backend frontend ruleset
listen - - - -
backend - - OK -
frontend - OK - -
ruleset - - - -
Best regards,
Krzysztof Oledzki
(cherry picked from commit 365d1cd84c)
This commit is contained in:
parent
feb628b3b1
commit
9dbe41b7d5
1 changed files with 22 additions and 1 deletions
|
|
@ -523,7 +523,28 @@ int cfg_parse_listen(const char *file, int linenum, char **args)
|
|||
file, linenum, args[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
for (curproxy = proxy; curproxy != NULL; curproxy = curproxy->next) {
|
||||
/*
|
||||
* If there are two proxies with the same name only following
|
||||
* combinations are allowed:
|
||||
*
|
||||
* listen backend frontend ruleset
|
||||
* listen - - - -
|
||||
* backend - - OK -
|
||||
* frontend - OK - -
|
||||
* ruleset - - - -
|
||||
*/
|
||||
|
||||
if (!strcmp(curproxy->id, args[1]) &&
|
||||
(rc!=(PR_CAP_FE|PR_CAP_RS) || curproxy->cap!=(PR_CAP_BE|PR_CAP_RS)) &&
|
||||
(rc!=(PR_CAP_BE|PR_CAP_RS) || curproxy->cap!=(PR_CAP_FE|PR_CAP_RS))) {
|
||||
Alert("parsing %s: duplicated proxy %s with conflicting capabilities: %X/%X!\n",
|
||||
file, args[1], curproxy->cap, rc);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((curproxy = (struct proxy *)calloc(1, sizeof(struct proxy))) == NULL) {
|
||||
Alert("parsing [%s:%d] : out of memory.\n", file, linenum);
|
||||
return -1;
|
||||
|
|
|
|||
Loading…
Reference in a new issue