mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 15:47:01 +02:00
MINOR: proxy: add a new capability PR_CAP_DEF
In order to more easily distinguish a default proxy from a standard one, let's introduce a new capability PR_CAP_DEF.
This commit is contained in:
parent
7d0c143185
commit
80dc6fea59
@ -66,6 +66,7 @@ enum PR_SRV_STATE_FILE {
|
||||
#define PR_CAP_FE 0x0001
|
||||
#define PR_CAP_BE 0x0002
|
||||
#define PR_CAP_LISTEN (PR_CAP_FE|PR_CAP_BE)
|
||||
#define PR_CAP_DEF 0x0004 /* defaults section */
|
||||
|
||||
/* bits for proxy->options */
|
||||
#define PR_O_REDISP 0x00000001 /* allow reconnection to dispatch in case of errors */
|
||||
|
@ -192,10 +192,12 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||
rc = PR_CAP_FE;
|
||||
else if (strcmp(args[0], "backend") == 0)
|
||||
rc = PR_CAP_BE;
|
||||
else if (strcmp(args[0], "defaults") == 0)
|
||||
rc = PR_CAP_DEF;
|
||||
else
|
||||
rc = PR_CAP_NONE;
|
||||
|
||||
if (rc != PR_CAP_NONE) { /* new proxy */
|
||||
if (rc & PR_CAP_LISTEN) { /* new proxy */
|
||||
if (!*args[1]) {
|
||||
ha_alert("parsing [%s:%d] : '%s' expects an <id> argument\n",
|
||||
file, linenum, args[0]);
|
||||
@ -257,7 +259,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||
curproxy = &defproxy;
|
||||
curproxy->conf.args.file = curproxy->conf.file = strdup(file);
|
||||
curproxy->conf.args.line = curproxy->conf.line = linenum;
|
||||
defproxy.cap = PR_CAP_LISTEN; /* all caps for now */
|
||||
defproxy.cap = PR_CAP_DEF | PR_CAP_LISTEN; /* all caps for now */
|
||||
goto out;
|
||||
}
|
||||
else if (curproxy == NULL) {
|
||||
|
@ -116,11 +116,15 @@ const struct cfg_opt cfg_opts2[] =
|
||||
/*
|
||||
* This function returns a string containing a name describing capabilities to
|
||||
* report comprehensible error messages. Specifically, it will return the words
|
||||
* "frontend", "backend" when appropriate, or "proxy" for all other
|
||||
* cases including the proxies declared in "listen" mode.
|
||||
* "frontend", "backend" when appropriate, "defaults" if it corresponds to a
|
||||
* defaults section, or "proxy" for all other cases including the proxies
|
||||
* declared in "listen" mode.
|
||||
*/
|
||||
const char *proxy_cap_str(int cap)
|
||||
{
|
||||
if (cap & PR_CAP_DEF)
|
||||
return "defaults";
|
||||
|
||||
if ((cap & PR_CAP_LISTEN) != PR_CAP_LISTEN) {
|
||||
if (cap & PR_CAP_FE)
|
||||
return "frontend";
|
||||
|
Loading…
Reference in New Issue
Block a user