MINOR: backend/balance: "balance" requires TCP or HTTP mode

Prevent the use of "balance" and associated keywords when proxy is neither
in tcp or http mode.
This commit is contained in:
Aurelien DARRAGON 2023-09-19 17:39:25 +02:00 committed by Christopher Faulet
parent f9422551cd
commit 1e0093a317
1 changed files with 18 additions and 0 deletions

View File

@ -2502,6 +2502,12 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL))
err_code |= ERR_WARN;
if (curproxy->mode != PR_MODE_TCP && curproxy->mode != PR_MODE_HTTP) {
ha_alert("parsing [%s:%d] : '%s' requires TCP or HTTP mode.\n", file, linenum, args[0]);
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}
if (backend_parse_balance((const char **)args + 1, &errmsg, curproxy) < 0) {
ha_alert("parsing [%s:%d] : %s %s\n", file, linenum, args[0], errmsg);
err_code |= ERR_ALERT | ERR_FATAL;
@ -2517,6 +2523,12 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
*/
curproxy->lbprm.algo &= ~(BE_LB_HASH_TYPE | BE_LB_HASH_FUNC | BE_LB_HASH_MOD);
if (curproxy->mode != PR_MODE_TCP && curproxy->mode != PR_MODE_HTTP) {
ha_alert("parsing [%s:%d] : '%s' requires TCP or HTTP mode.\n", file, linenum, args[0]);
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}
if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL))
err_code |= ERR_WARN;
@ -2577,6 +2589,12 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
}
}
else if (strcmp(args[0], "hash-balance-factor") == 0) {
if (curproxy->mode != PR_MODE_TCP && curproxy->mode != PR_MODE_HTTP) {
ha_alert("parsing [%s:%d] : '%s' requires TCP or HTTP mode.\n", file, linenum, args[0]);
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}
if (*(args[1]) == 0) {
ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]);
err_code |= ERR_ALERT | ERR_FATAL;