diff --git a/include/haproxy/proxy-t.h b/include/haproxy/proxy-t.h index 247028460..3fdd09d62 100644 --- a/include/haproxy/proxy-t.h +++ b/include/haproxy/proxy-t.h @@ -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 */ diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c index ffe793156..176025933 100644 --- a/src/cfgparse-listen.c +++ b/src/cfgparse-listen.c @@ -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 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) { diff --git a/src/proxy.c b/src/proxy.c index 370e759e8..a0aaa5ca6 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -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";