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.
diff --git a/include/haproxy/proxy-t.h b/include/haproxy/proxy-t.h
index 2470284..3fdd09d 100644
--- a/include/haproxy/proxy-t.h
+++ b/include/haproxy/proxy-t.h
@@ -66,6 +66,7 @@
#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 ffe7931..1760259 100644
--- a/src/cfgparse-listen.c
+++ b/src/cfgparse-listen.c
@@ -192,10 +192,12 @@
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 @@
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 370e759..a0aaa5c 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -116,11 +116,15 @@
/*
* 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";