]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: server: Make 'default-server' support 'check-send-proxy' keyword.
authorFrédéric Lécaille <flecaille@haproxy.com>
Fri, 10 Mar 2017 13:04:31 +0000 (14:04 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 27 Mar 2017 12:36:11 +0000 (14:36 +0200)
This patch makes 'default-server' directive support 'check-send-proxy' setting.
A new keyword 'no-check-send-proxy' has been added so that to disable
'check-send-proxy' setting both in 'server' and 'default-server' directives.

src/server.c

index 2b0a5dae5ba42651da92ec061a7a6958c200a22a..796ff51b997beb5fc8f85a6f6731158b68d4255b 100644 (file)
@@ -221,6 +221,14 @@ static int srv_parse_backup(char **args, int *cur_arg,
        return 0;
 }
 
+/* Parse the "check-send-proxy" server keyword */
+static int srv_parse_check_send_proxy(char **args, int *cur_arg,
+                                      struct proxy *curproxy, struct server *newsrv, char **err)
+{
+       newsrv->check.send_proxy = 1;
+       return 0;
+}
+
 /* parse the "id" server keyword */
 static int srv_parse_id(char **args, int *cur_arg, struct proxy *curproxy, struct server *newsrv, char **err)
 {
@@ -261,6 +269,14 @@ static int srv_parse_no_backup(char **args, int *cur_arg,
        return 0;
 }
 
+/* Parse the "no-check-send-proxy" server keyword */
+static int srv_parse_no_check_send_proxy(char **args, int *cur_arg,
+                                         struct proxy *curproxy, struct server *newsrv, char **err)
+{
+       newsrv->check.send_proxy = 0;
+       return 0;
+}
+
 /* Shutdown all connections of a server. The caller must pass a termination
  * code in <why>, which must be one of SF_ERR_* indicating the reason for the
  * shutdown.
@@ -871,8 +887,10 @@ void srv_compute_all_admin_states(struct proxy *px)
  */
 static struct srv_kw_list srv_kws = { "ALL", { }, {
        { "backup",       srv_parse_backup,       0,  1 }, /* Flag as backup server */
+       { "check-send-proxy",    srv_parse_check_send_proxy,    0,  1 }, /* enable PROXY protocol for health checks */
        { "id",           srv_parse_id,           1,  0 }, /* set id# of server */
        { "no-backup",    srv_parse_no_backup,    0,  1 }, /* Flag as non-backup server */
+       { "no-check-send-proxy", srv_parse_no_check_send_proxy, 0,  1 }, /* disable PROXY protol for health checks */
        { NULL, NULL, 0 },
 }};
 
@@ -1191,6 +1209,7 @@ int parse_server(const char *file, int linenum, char **args, struct proxy *curpr
                                                = curproxy->defsrv.iweight;
 
                        newsrv->check.status    = HCHK_STATUS_INI;
+                       newsrv->check.send_proxy = curproxy->defsrv.check.send_proxy;
                        newsrv->check.rise      = curproxy->defsrv.check.rise;
                        newsrv->check.fall      = curproxy->defsrv.check.fall;
                        newsrv->check.health    = newsrv->check.rise;   /* up, but will fall down at first failure */
@@ -1535,10 +1554,6 @@ int parse_server(const char *file, int linenum, char **args, struct proxy *curpr
                                newsrv->pp_opts |= SRV_PP_V2;
                                cur_arg ++;
                        }
-                       else if (!defsrv && !strcmp(args[cur_arg], "check-send-proxy")) {
-                               newsrv->check.send_proxy = 1;
-                               cur_arg ++;
-                       }
                        else if (!strcmp(args[cur_arg], "weight")) {
                                int w;
                                w = atol(args[cur_arg + 1]);