From: Amaury Denoyelle Date: Wed, 27 Mar 2024 09:50:21 +0000 (+0100) Subject: MINOR: server: allow cookie for dynamic servers X-Git-Tag: v3.0-dev7~66 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6333e6ec8e35f4e531c46a835fbc0fd121768d32;p=thirdparty%2Fhaproxy.git MINOR: server: allow cookie for dynamic servers This commit allows "cookie" keyword for dynamic servers. After code review, nothing was found which could prevent a dynamic server to use it. An extra warning is added under cli_parse_add_server() if cookie value is ignored due to a non HTTP backend. This patch is not considered a bugfix. However, it may backported if needed as its impact seems minimal. --- diff --git a/doc/management.txt b/doc/management.txt index d5d2636b74..9ddf103f2a 100644 --- a/doc/management.txt +++ b/doc/management.txt @@ -1692,6 +1692,7 @@ add server / [args]* - check-via-socks4 - ciphers - ciphersuites + - cookie - crl-file - crt - disabled diff --git a/src/server.c b/src/server.c index 008335bfe0..ea93e1ff4f 100644 --- a/src/server.c +++ b/src/server.c @@ -2216,7 +2216,7 @@ void srv_compute_all_admin_states(struct proxy *px) */ static struct srv_kw_list srv_kws = { "ALL", { }, { { "backup", srv_parse_backup, 0, 1, 1 }, /* Flag as backup server */ - { "cookie", srv_parse_cookie, 1, 1, 0 }, /* Assign a cookie to the server */ + { "cookie", srv_parse_cookie, 1, 1, 1 }, /* Assign a cookie to the server */ { "disabled", srv_parse_disabled, 0, 1, 1 }, /* Start the server in 'disabled' state */ { "enabled", srv_parse_enabled, 0, 1, 0 }, /* Start the server in 'enabled' state */ { "error-limit", srv_parse_error_limit, 1, 1, 1 }, /* Configure the consecutive count of check failures to consider a server on error */ @@ -5758,6 +5758,9 @@ static int cli_parse_add_server(char **args, char *payload, struct appctx *appct ha_alert("System might be unstable, consider to execute a reload\n"); } + if (srv->cklen && be->mode != PR_MODE_HTTP) + ha_warning("Ignoring cookie as HTTP mode is disabled.\n"); + ha_notice("New server registered.\n"); cli_umsg(appctx, LOG_INFO);