mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-18 09:24:31 +00:00
MINOR: config: Add failifnotcap() to emit an alert on proxy capabilities
This function must be used to emit an alert if a proxy does not have at least one of the requested capabilities. An additional message may be appended to the alert.
This commit is contained in:
parent
4e36682d51
commit
d4a83dd6b3
@ -141,6 +141,31 @@ static inline int warnifnotcap(struct proxy *proxy, int cap, const char *file, i
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sends an alert if proxy <proxy> does not have at least one of the
|
||||
* capabilities in <cap>. An optional <hint> may be added at the end
|
||||
* of the alert to help the user. Returns 1 if an alert was emitted
|
||||
* or 0 if the condition is valid.
|
||||
*/
|
||||
static inline int failifnotcap(struct proxy *proxy, int cap, const char *file, int line, const char *arg, const char *hint)
|
||||
{
|
||||
char *msg;
|
||||
|
||||
switch (cap) {
|
||||
case PR_CAP_BE: msg = "no backend"; break;
|
||||
case PR_CAP_FE: msg = "no frontend"; break;
|
||||
case PR_CAP_BE|PR_CAP_FE: msg = "neither frontend nor backend"; break;
|
||||
default: msg = "not enough"; break;
|
||||
}
|
||||
|
||||
if (!(proxy->cap & cap)) {
|
||||
ha_alert("parsing [%s:%d] : '%s' not allowed because %s '%s' has %s capability.%s\n",
|
||||
file, line, arg, proxy_type_str(proxy), proxy->id, msg, hint ? hint : "");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* simplified way to define a section parser */
|
||||
#define REGISTER_CONFIG_SECTION(name, parse, post) \
|
||||
INITCALL3(STG_REGISTER, cfg_register_section, (name), (parse), (post))
|
||||
|
Loading…
Reference in New Issue
Block a user