mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-01-30 06:22:00 +01:00
MINOR: proxy/checks: Register a keyword to parse external-check rules
The keyword 'external-check' is now parsed in a dedicated callback function. Thus the code to parse these rules is now located in checks.c.
This commit is contained in:
parent
6f5579160a
commit
e9111b6892
@ -1150,45 +1150,6 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||
/* Indicate that the email_alert is at least partially configured */
|
||||
curproxy->email_alert.set = 1;
|
||||
}/* end else if (!strcmp(args[0], "email-alert")) */
|
||||
else if (!strcmp(args[0], "external-check")) {
|
||||
if (*(args[1]) == 0) {
|
||||
ha_alert("parsing [%s:%d] : missing argument after '%s'.\n",
|
||||
file, linenum, args[0]);
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!strcmp(args[1], "command")) {
|
||||
if (alertif_too_many_args(2, file, linenum, args, &err_code))
|
||||
goto out;
|
||||
if (*(args[2]) == 0) {
|
||||
ha_alert("parsing [%s:%d] : missing argument after '%s'.\n",
|
||||
file, linenum, args[1]);
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
free(curproxy->check_command);
|
||||
curproxy->check_command = strdup(args[2]);
|
||||
}
|
||||
else if (!strcmp(args[1], "path")) {
|
||||
if (alertif_too_many_args(2, file, linenum, args, &err_code))
|
||||
goto out;
|
||||
if (*(args[2]) == 0) {
|
||||
ha_alert("parsing [%s:%d] : missing argument after '%s'.\n",
|
||||
file, linenum, args[1]);
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
free(curproxy->check_path);
|
||||
curproxy->check_path = strdup(args[2]);
|
||||
}
|
||||
else {
|
||||
ha_alert("parsing [%s:%d] : external-check: unknown argument '%s'.\n",
|
||||
file, linenum, args[1]);
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
}/* end else if (!strcmp(args[0], "external-check")) */
|
||||
else if (!strcmp(args[0], "persist")) { /* persist */
|
||||
if (*(args[1]) == 0) {
|
||||
ha_alert("parsing [%s:%d] : missing persist method.\n",
|
||||
|
||||
50
src/checks.c
50
src/checks.c
@ -5265,6 +5265,51 @@ static int proxy_parse_httpcheck(char **args, int section, struct proxy *curpx,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Parses the "external-check" proxy keyword */
|
||||
static int proxy_parse_extcheck(char **args, int section, struct proxy *curpx,
|
||||
struct proxy *defpx, const char *file, int line,
|
||||
char **errmsg)
|
||||
{
|
||||
int cur_arg, ret = 0;
|
||||
|
||||
cur_arg = 1;
|
||||
if (!*(args[cur_arg])) {
|
||||
memprintf(errmsg, "missing argument after '%s'.\n", args[0]);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (strcmp(args[cur_arg], "command") == 0) {
|
||||
if (too_many_args(2, args, errmsg, NULL))
|
||||
goto error;
|
||||
if (!*(args[cur_arg+1])) {
|
||||
memprintf(errmsg, "missing argument after '%s'.", args[cur_arg]);
|
||||
goto error;
|
||||
}
|
||||
free(curpx->check_command);
|
||||
curpx->check_command = strdup(args[cur_arg+1]);
|
||||
}
|
||||
else if (strcmp(args[cur_arg], "path") == 0) {
|
||||
if (too_many_args(2, args, errmsg, NULL))
|
||||
goto error;
|
||||
if (!*(args[cur_arg+1])) {
|
||||
memprintf(errmsg, "missing argument after '%s'.", args[cur_arg]);
|
||||
goto error;
|
||||
}
|
||||
free(curpx->check_path);
|
||||
curpx->check_path = strdup(args[cur_arg+1]);
|
||||
}
|
||||
else {
|
||||
memprintf(errmsg, "'%s' only supports 'command' and 'path'. but got '%s'.",
|
||||
args[0], args[1]);
|
||||
goto error;
|
||||
}
|
||||
|
||||
ret = (*errmsg != NULL); /* Handle warning */
|
||||
return ret;
|
||||
|
||||
error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static struct tcpcheck_ruleset *tcpcheck_ruleset_lookup(const char *name)
|
||||
{
|
||||
@ -6886,8 +6931,9 @@ static int srv_parse_check_port(char **args, int *cur_arg, struct proxy *curpx,
|
||||
}
|
||||
|
||||
static struct cfg_kw_list cfg_kws = {ILH, {
|
||||
{ CFG_LISTEN, "tcp-check", proxy_parse_tcpcheck },
|
||||
{ CFG_LISTEN, "http-check", proxy_parse_httpcheck },
|
||||
{ CFG_LISTEN, "tcp-check", proxy_parse_tcpcheck },
|
||||
{ CFG_LISTEN, "http-check", proxy_parse_httpcheck },
|
||||
{ CFG_LISTEN, "external-check", proxy_parse_extcheck },
|
||||
{ 0, NULL, NULL },
|
||||
}};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user