From: Amaury Denoyelle Date: Mon, 23 Nov 2026 10:04:24 +0000 (+0100) Subject: MINOR: server: report incorrect usage of "from" keyword X-Git-Url: https://git.kaiwu.me/http/control.html?a=commitdiff_plain;h=70e7227a3dd1e54d2875d0e94745fdf47a14ff23;p=haproxy.git MINOR: server: report incorrect usage of "from" keyword Define a parser for the "from" server keyword. It always returns an error reporting its invalid position as any "from" setting has already been parsed during _srv_parse_from(). Also, this prevents a later keyword list from overriding this name. --- diff --git a/src/server.c b/src/server.c index b9d7d967a..86918ce04 100644 --- a/src/server.c +++ b/src/server.c @@ -986,6 +986,15 @@ static int srv_parse_error_limit(char **args, int *cur_arg, return 0; } +/* Reports incorrect position of "from" server keyword. */ +static int srv_parse_from(char **args, int *cur_arg, + struct proxy *curproxy, struct server *newsrv, char **err) +{ + memprintf(err, "'%s' is a positional keyword. It must be specified" + " before any other server setting", args[*cur_arg]); + return ERR_ALERT | ERR_FATAL; +} + /* Parse the "guid" keyword */ static int srv_parse_guid(char **args, int *cur_arg, struct proxy *curproxy, struct server *newsrv, char **err) @@ -2502,6 +2511,7 @@ static struct srv_kw_list srv_kws = { "ALL", { }, { { "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 */ + { "from", srv_parse_from, 1, 1, 1 }, /* Not a real parser - prevent conflict with 'from' positional keyword */ { "guid", srv_parse_guid, 1, 0, 1 }, /* Set global unique ID of the server */ { "ws", srv_parse_ws, 1, 1, 1 }, /* websocket protocol */ { "hash-key", srv_parse_hash_key, 1, 1, 1 }, /* Configure how chash keys are computed */