mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-18 11:47:03 +00:00
MEDIUM: cli: disable some keywords in the master
The master process does not need all the keywords of the cli, add 2 flags to chose which keyword to use. It might be useful to activate some of them in a debug mode later...
This commit is contained in:
parent
e736115d3a
commit
14721be11f
@ -31,6 +31,7 @@ struct cli_kw {
|
||||
int (*io_handler)(struct appctx *appctx);
|
||||
void (*io_release)(struct appctx *appctx);
|
||||
void *private;
|
||||
int level; /* this is the level needed to show the keyword usage and to use it */
|
||||
};
|
||||
|
||||
struct cli_kw_list {
|
||||
|
@ -76,6 +76,8 @@
|
||||
#define ACCESS_LVL_MASK 0x3
|
||||
|
||||
#define ACCESS_FD_LISTENERS 0x4 /* expose listeners FDs on stats socket */
|
||||
#define ACCESS_MASTER 0x8 /* works with the master (and every other processes) */
|
||||
#define ACCESS_MASTER_ONLY 0x10 /* only works with the worker */
|
||||
|
||||
/* SSL server verify mode */
|
||||
enum {
|
||||
|
22
src/cli.c
22
src/cli.c
@ -93,6 +93,8 @@ static struct cli_kw_list cli_keywords = {
|
||||
|
||||
extern const char *stat_status_codes[];
|
||||
|
||||
extern int master;
|
||||
|
||||
static struct proxy *mworker_proxy; /* CLI proxy of the master */
|
||||
|
||||
static char *cli_gen_usage_msg(struct appctx *appctx)
|
||||
@ -113,8 +115,20 @@ static char *cli_gen_usage_msg(struct appctx *appctx)
|
||||
list_for_each_entry(kw_list, &cli_keywords.list, list) {
|
||||
kw = &kw_list->kw[0];
|
||||
while (kw->str_kw[0]) {
|
||||
|
||||
/* in a worker or normal process, don't display master only commands */
|
||||
if (master == 0 && (kw->level & ACCESS_MASTER_ONLY))
|
||||
goto next_kw;
|
||||
|
||||
/* in master don't displays if we don't have the master bits */
|
||||
if (master == 1 && !(kw->level & (ACCESS_MASTER_ONLY|ACCESS_MASTER)))
|
||||
goto next_kw;
|
||||
|
||||
if (kw->usage)
|
||||
chunk_appendf(tmp, " %s\n", kw->usage);
|
||||
|
||||
next_kw:
|
||||
|
||||
kw++;
|
||||
}
|
||||
}
|
||||
@ -465,6 +479,14 @@ static int cli_parse_request(struct appctx *appctx)
|
||||
if (!kw)
|
||||
return 0;
|
||||
|
||||
/* in a worker or normal process, don't display master only commands */
|
||||
if (master == 0 && (kw->level & ACCESS_MASTER_ONLY))
|
||||
return 0;
|
||||
|
||||
/* in master don't displays if we don't have the master bits */
|
||||
if (master == 1 && !(kw->level & (ACCESS_MASTER_ONLY|ACCESS_MASTER)))
|
||||
return 0;
|
||||
|
||||
appctx->io_handler = kw->io_handler;
|
||||
appctx->io_release = kw->io_release;
|
||||
/* kw->parse could set its own io_handler or ip_release handler */
|
||||
|
Loading…
Reference in New Issue
Block a user