mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-29 08:02:08 +00:00
MINOR: config: use the new bind_parse_args_list() to parse a "bind" line
This now makes sure that both the peers' "bind" line and the regular one will use the exact same parser with the exact same behavior. Note that the parser applies after the address and that it could be factored further, since the peers one still does quite a bit of duplicated work.
This commit is contained in:
parent
3882d2a96c
commit
55f0f7bb54
@ -507,59 +507,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||
}
|
||||
|
||||
cur_arg = 2;
|
||||
while (*(args[cur_arg])) {
|
||||
struct bind_kw *kw;
|
||||
const char *best;
|
||||
|
||||
kw = bind_find_kw(args[cur_arg]);
|
||||
if (kw) {
|
||||
char *err = NULL;
|
||||
int code;
|
||||
|
||||
if (!kw->parse) {
|
||||
ha_alert("parsing [%s:%d] : '%s %s' : '%s' option is not implemented in this version (check build options).\n",
|
||||
file, linenum, args[0], args[1], args[cur_arg]);
|
||||
cur_arg += 1 + kw->skip ;
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
code = kw->parse(args, cur_arg, curproxy, bind_conf, &err);
|
||||
err_code |= code;
|
||||
|
||||
if (code) {
|
||||
if (err && *err) {
|
||||
indent_msg(&err, 2);
|
||||
if (((code & (ERR_WARN|ERR_ALERT)) == ERR_WARN))
|
||||
ha_warning("parsing [%s:%d] : '%s %s' : %s\n", file, linenum, args[0], args[1], err);
|
||||
else
|
||||
ha_alert("parsing [%s:%d] : '%s %s' : %s\n", file, linenum, args[0], args[1], err);
|
||||
}
|
||||
else
|
||||
ha_alert("parsing [%s:%d] : '%s %s' : error encountered while processing '%s'.\n",
|
||||
file, linenum, args[0], args[1], args[cur_arg]);
|
||||
if (code & ERR_FATAL) {
|
||||
free(err);
|
||||
cur_arg += 1 + kw->skip;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
free(err);
|
||||
cur_arg += 1 + kw->skip;
|
||||
continue;
|
||||
}
|
||||
|
||||
best = bind_find_best_kw(args[cur_arg]);
|
||||
if (best)
|
||||
ha_alert("parsing [%s:%d] : '%s %s' unknown keyword '%s'; did you mean '%s' maybe ?\n",
|
||||
file, linenum, args[0], args[1], args[cur_arg], best);
|
||||
else
|
||||
ha_alert("parsing [%s:%d] : '%s %s' unknown keyword '%s'.\n",
|
||||
file, linenum, args[0], args[1], args[cur_arg]);
|
||||
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
err_code |= bind_parse_args_list(bind_conf, args, cur_arg, cursection, file, linenum);
|
||||
goto out;
|
||||
}
|
||||
else if (strcmp(args[0], "monitor-net") == 0) { /* set the range of IPs to ignore */
|
||||
|
@ -693,7 +693,7 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
|
||||
if (strcmp(args[0], "bind") == 0 || strcmp(args[0], "default-bind") == 0) {
|
||||
int cur_arg;
|
||||
struct bind_conf *bind_conf;
|
||||
struct bind_kw *kw;
|
||||
int ret;
|
||||
|
||||
cur_arg = 1;
|
||||
|
||||
@ -752,35 +752,10 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
|
||||
cur_arg++;
|
||||
}
|
||||
|
||||
while (*args[cur_arg] && (kw = bind_find_kw(args[cur_arg]))) {
|
||||
int ret;
|
||||
|
||||
ret = kw->parse(args, cur_arg, curpeers->peers_fe, bind_conf, &errmsg);
|
||||
err_code |= ret;
|
||||
if (ret) {
|
||||
if (errmsg && *errmsg) {
|
||||
indent_msg(&errmsg, 2);
|
||||
ha_alert("parsing [%s:%d] : %s\n", file, linenum, errmsg);
|
||||
}
|
||||
else
|
||||
ha_alert("parsing [%s:%d]: error encountered while processing '%s'\n",
|
||||
file, linenum, args[cur_arg]);
|
||||
if (ret & ERR_FATAL)
|
||||
goto out;
|
||||
}
|
||||
cur_arg += 1 + kw->skip;
|
||||
}
|
||||
if (*args[cur_arg] != 0) {
|
||||
const char *best = bind_find_best_kw(args[cur_arg]);
|
||||
if (best)
|
||||
ha_alert("parsing [%s:%d] : unknown keyword '%s' in '%s' section; did you mean '%s' maybe ?\n",
|
||||
file, linenum, args[cur_arg], cursection, best);
|
||||
else
|
||||
ha_alert("parsing [%s:%d] : unknown keyword '%s' in '%s' section.\n",
|
||||
file, linenum, args[cur_arg], cursection);
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
ret = bind_parse_args_list(bind_conf, args, cur_arg, cursection, file, linenum);
|
||||
err_code |= ret;
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
else if (strcmp(args[0], "default-server") == 0) {
|
||||
if (init_peers_frontend(file, -1, NULL, curpeers) != 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user