[MINOR] adjust error messages about conflicting proxies
It's not easy to report useful information to help the user quickly fix a configuration. This patch : - removes the word "listener" in favor of "proxy" as it has been used since the beginning ; - ensures that the same function (hence the same words) will be used to report capabilities of a proxy being declared and an existing proxy ; - avoid the term "conflicting capabilities" in favor of "overlapping capabilities" which is more exact. - just report that the same name is reused in case of warnings
This commit is contained in:
parent
6eb730ded9
commit
816eb54e9b
|
@ -33,10 +33,19 @@ void pause_proxy(struct proxy *p);
|
||||||
void pause_proxies(void);
|
void pause_proxies(void);
|
||||||
void listen_proxies(void);
|
void listen_proxies(void);
|
||||||
|
|
||||||
const char *proxy_type_str(struct proxy *proxy);
|
const char *proxy_cap_str(int cap);
|
||||||
const char *proxy_mode_str(int mode);
|
const char *proxy_mode_str(int mode);
|
||||||
struct proxy *findproxy(const char *name, int mode, int cap);
|
struct proxy *findproxy(const char *name, int mode, int cap);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function returns a string containing the type of the proxy in a format
|
||||||
|
* suitable for error messages, from its capabilities.
|
||||||
|
*/
|
||||||
|
static inline const char *proxy_type_str(struct proxy *proxy)
|
||||||
|
{
|
||||||
|
return proxy_cap_str(proxy->cap);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* _PROTO_PROXY_H */
|
#endif /* _PROTO_PROXY_H */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -539,8 +539,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args)
|
||||||
if (!strcmp(curproxy->id, args[1]) &&
|
if (!strcmp(curproxy->id, args[1]) &&
|
||||||
(rc!=(PR_CAP_FE|PR_CAP_RS) || curproxy->cap!=(PR_CAP_BE|PR_CAP_RS)) &&
|
(rc!=(PR_CAP_FE|PR_CAP_RS) || curproxy->cap!=(PR_CAP_BE|PR_CAP_RS)) &&
|
||||||
(rc!=(PR_CAP_BE|PR_CAP_RS) || curproxy->cap!=(PR_CAP_FE|PR_CAP_RS))) {
|
(rc!=(PR_CAP_BE|PR_CAP_RS) || curproxy->cap!=(PR_CAP_FE|PR_CAP_RS))) {
|
||||||
Warning("Parsing [%s:%d]: duplicated proxy '%s' with conflicting capabilities: %s/%s!\n",
|
Warning("Parsing [%s:%d]: %s '%s' has same name as another %s.\n",
|
||||||
file, linenum, args[1], proxy_type_str(curproxy), args[0]);
|
file, linenum, proxy_cap_str(rc), args[1], proxy_type_str(curproxy));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
31
src/proxy.c
31
src/proxy.c
|
@ -37,29 +37,28 @@ int listeners; /* # of listeners */
|
||||||
struct proxy *proxy = NULL; /* list of all existing proxies */
|
struct proxy *proxy = NULL; /* list of all existing proxies */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function returns a string containing the type of the proxy in a format
|
* This function returns a string containing a name describing capabilities to
|
||||||
* suitable for error messages, from its capabilities.
|
* report comprehensible error messages. Specifically, it will return the words
|
||||||
|
* "frontend", "backend", "ruleset" when appropriate, or "proxy" for all other
|
||||||
|
* cases including the proxies declared in "listen" mode.
|
||||||
*/
|
*/
|
||||||
const char *proxy_type_str(struct proxy *proxy)
|
const char *proxy_cap_str(int cap)
|
||||||
{
|
{
|
||||||
int cap = proxy->cap;
|
if ((cap & PR_CAP_LISTEN) != PR_CAP_LISTEN) {
|
||||||
if ((cap & PR_CAP_LISTEN) == PR_CAP_LISTEN)
|
if (cap & PR_CAP_FE)
|
||||||
return "listener";
|
return "frontend";
|
||||||
else if (cap & PR_CAP_FE)
|
else if (cap & PR_CAP_BE)
|
||||||
return "frontend";
|
return "backend";
|
||||||
else if (cap & PR_CAP_BE)
|
else if (cap & PR_CAP_RS)
|
||||||
return "backend";
|
return "ruleset";
|
||||||
else if (cap & PR_CAP_RS)
|
}
|
||||||
return "ruleset";
|
return "proxy";
|
||||||
else
|
|
||||||
return "proxy";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function returns a string containing the mode of the proxy in a format
|
* This function returns a string containing the mode of the proxy in a format
|
||||||
* suitable for error messages.
|
* suitable for error messages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const char *proxy_mode_str(int mode) {
|
const char *proxy_mode_str(int mode) {
|
||||||
|
|
||||||
if (mode == PR_MODE_TCP)
|
if (mode == PR_MODE_TCP)
|
||||||
|
@ -98,7 +97,7 @@ struct proxy *findproxy(const char *name, int mode, int cap) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Alert("Refusing to use duplicated proxy '%s' with conflicting capabilities: %s/%s!\n",
|
Alert("Refusing to use duplicated proxy '%s' with overlapping capabilities: %s/%s!\n",
|
||||||
name, proxy_type_str(curproxy), proxy_type_str(target));
|
name, proxy_type_str(curproxy), proxy_type_str(target));
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue