mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-22 05:36:56 +00:00
MINOR: cfgparse: suggest correct spelling for unknown words in proxy sections
Let's start by the largest keyword list, the listeners. Many keywords were still not part of a list, so a common_kw_list array was added to list the not enumerated ones. Now for example, typing "tmout" properly suggests "timeout": $ printf "frontend f\ntmout client 10s\n" | ./haproxy -c -f /dev/stdin [NOTICE] 070/091355 (22545) : haproxy version is 2.4-dev11-3b728a-21 [NOTICE] 070/091355 (22545) : path to executable is ./haproxy [ALERT] 070/091355 (22545) : parsing [/dev/stdin:2] : unknown keyword 'tmout' in 'frontend' section; did you mean 'timeout' maybe ? [ALERT] 070/091355 (22545) : Error(s) found in configuration file : /dev/stdin [ALERT] 070/091355 (22545) : Fatal errors found in configuration.
This commit is contained in:
parent
e2afcc4509
commit
c0ff679481
@ -33,6 +33,26 @@
|
||||
#include <haproxy/tcpcheck.h>
|
||||
#include <haproxy/uri_auth.h>
|
||||
|
||||
/* some keywords that are still being parsed using strcmp() and are not
|
||||
* registered anywhere. They are used as suggestions for mistyped words.
|
||||
*/
|
||||
static const char *common_kw_list[] = {
|
||||
"listen", "frontend", "backend", "defaults", "server",
|
||||
"default-server", "server-template", "bind", "monitor-net",
|
||||
"monitor-uri", "mode", "id", "description", "disabled", "enabled",
|
||||
"bind-process", "acl", "dynamic-cookie-key", "cookie", "email-alert",
|
||||
"persist", "appsession", "load-server-state-from-file",
|
||||
"server-state-file-name", "max-session-srv-conns", "capture",
|
||||
"retries", "http-request", "http-response", "http-after-response",
|
||||
"http-send-name-header", "block", "redirect", "use_backend",
|
||||
"use-server", "force-persist", "ignore-persist", "force-persist",
|
||||
"stick-table", "stick", "stats", "option", "default_backend",
|
||||
"http-reuse", "monitor", "transparent", "maxconn", "backlog",
|
||||
"fullconn", "grace", "dispatch", "balance", "hash-type",
|
||||
"hash-balance-factor", "unique-id-format", "unique-id-header",
|
||||
"log-format", "log-format-sd", "log-tag", "log", "source", "usesrc",
|
||||
NULL /* must be last */
|
||||
};
|
||||
|
||||
/* Report a warning if a rule is placed after a 'tcp-request session' rule.
|
||||
* Return 1 if the warning has been emitted, otherwise 0.
|
||||
@ -2917,6 +2937,7 @@ stats_error_parsing:
|
||||
}
|
||||
else {
|
||||
struct cfg_kw_list *kwl;
|
||||
const char *best;
|
||||
int index;
|
||||
|
||||
list_for_each_entry(kwl, &cfg_keywords.list, list) {
|
||||
@ -2941,7 +2962,11 @@ stats_error_parsing:
|
||||
}
|
||||
}
|
||||
|
||||
ha_alert("parsing [%s:%d] : unknown keyword '%s' in '%s' section\n", file, linenum, args[0], cursection);
|
||||
best = cfg_find_best_match(args[0], &cfg_keywords.list, CFG_LISTEN, common_kw_list);
|
||||
if (best)
|
||||
ha_alert("parsing [%s:%d] : unknown keyword '%s' in '%s' section; did you mean '%s' maybe ?\n", file, linenum, args[0], cursection, best);
|
||||
else
|
||||
ha_alert("parsing [%s:%d] : unknown keyword '%s' in '%s' section\n", file, linenum, args[0], cursection);
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user