Hi Willy,

I've made a quick pass on the "defaults" column in the Proxy keywords matrix 
(chapter 4.1. in the documentation).
This patch resyncs the code and the documentation. I let you decide if some 
keywords that still work in the "defaults" section should be forbidden.

- default_backend : in the matrix, "defaults" was not supported but the keyword 
details say it is.
Tests also shows it works, then I've updated the matrix.

- capture cookie : in the keyword details, we can read `It is not possible to 
specify a capture in a "defaults" section.'.
Ok, even if the tests worked, I've added an alert in the configuration parser 
(as it is for capture request/response header).

- description : not supported in "defaults", I added an alert in the parser.
I've also noticed that this keyword doesn't appear in the documentation.
There's one "description" entry, but for the "global" section, which is for a 
different use (the patch doesn't update the documentation).

- grace : even if this is maybe useless, it works in "defaults". Documentation 
is updated.
- redirect : alert is added in the parser.
- rsprep : alert added in the parser.

-- 
Cyril Bonté
diff -Naur haproxy-ss-20100123/doc/configuration.txt haproxy-ss-20100123-defaults/doc/configuration.txt
--- haproxy-ss-20100123/doc/configuration.txt	2010-01-22 19:10:05.000000000 +0100
+++ haproxy-ss-20100123-defaults/doc/configuration.txt	2010-01-24 17:34:49.000000000 +0100
@@ -752,7 +752,7 @@
 contimeout                  X          -         X         X  (deprecated)
 cookie                      X          -         X         X
 default-server              X          -         X         X
-default_backend             -          X         X         -
+default_backend             X          X         X         -
 description                 -          X         X         X
 disabled                    X          X         X         X
 dispatch                    -          -         X         X
@@ -762,7 +762,7 @@
 errorloc302                 X          X         X         X
 errorloc303                 X          X         X         X
 fullconn                    X          -         X         X
-grace                       -          X         X         X
+grace                       X          X         X         X
 hash-type                   X          -         X         X
 http-check disable-on-404   X          -         X         X
 id                          -          X         X         X
@@ -1865,7 +1865,7 @@
 grace <time>
   Maintain a proxy operational for some time after a soft stop
   May be used in sections :   defaults | frontend | listen | backend
-                                  no   |    yes   |   yes  |   yes
+                                 yes   |    yes   |   yes  |   yes
   Arguments :
     <time>    is the time (by default in milliseconds) for which the instance
               will remain operational with the frontend sockets still listening
Seulement dans haproxy-ss-20100123-defaults/: haproxy.sock
diff -Naur haproxy-ss-20100123/src/cfgparse.c haproxy-ss-20100123-defaults/src/cfgparse.c
--- haproxy-ss-20100123/src/cfgparse.c	2010-01-22 19:10:05.000000000 +0100
+++ haproxy-ss-20100123-defaults/src/cfgparse.c	2010-01-24 17:40:17.000000000 +0100
@@ -1408,6 +1408,13 @@
 		int i, len=0;
 		char *d;
 
+		if (curproxy == &defproxy) {
+			Alert("parsing [%s:%d]: '%s' not allowed in 'defaults' section.\n",
+				 file, linenum, args[0]);
+			err_code |= ERR_ALERT | ERR_FATAL;
+			goto out;
+		}
+
 		if (!*args[1]) {
 			Alert("parsing [%s:%d]: '%s' expects a string argument.\n",
 				file, linenum, args[0]);
@@ -1710,6 +1717,12 @@
 			err_code |= ERR_WARN;
 
 		if (!strcmp(args[1], "cookie")) {  /* name of a cookie to capture */
+			if (curproxy == &defproxy) {
+				Alert("parsing [%s:%d] : '%s %s' not allowed in 'defaults' section.\n", file, linenum, args[0], args[1]);
+				err_code |= ERR_ALERT | ERR_FATAL;
+				goto out;
+			}
+
 			if (*(args[4]) == 0) {
 				Alert("parsing [%s:%d] : '%s' expects 'cookie' <cookie_name> 'len' <len>.\n",
 				      file, linenum, args[0]);
@@ -1844,6 +1857,12 @@
 		int cookie_set = 0;
 		unsigned int flags = REDIRECT_FLAG_NONE;
 
+		if (curproxy == &defproxy) {
+			Alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]);
+			err_code |= ERR_ALERT | ERR_FATAL;
+			goto out;
+		}
+
 		cur_arg = 1;
 		while (*(args[cur_arg])) {
 			if (!strcmp(args[cur_arg], "location")) {
@@ -3978,6 +3997,11 @@
 	}
 	else if (!strcmp(args[0], "srvexp") || !strcmp(args[0], "rsprep")) {  /* replace response header from a regex */
 		regex_t *preg;
+		if (curproxy == &defproxy) {
+			Alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]);
+			err_code |= ERR_ALERT | ERR_FATAL;
+			goto out;
+		}
 	
 		if (*(args[1]) == 0 || *(args[2]) == 0) {
 			Alert("parsing [%s:%d] : '%s' expects <search> and <replace> as arguments.\n",

Reply via email to