Index: main/manager.c =================================================================== --- main/manager.c (revision 231431) +++ main/manager.c (working copy) @@ -731,12 +731,17 @@ static AST_LIST_HEAD_STATIC(all_events, eventqent); +static struct ast_tls_config ami_tls_cfg; +static struct ast_tcptls_session_args ami_desc; +static struct ast_tcptls_session_args amis_desc; + static int displayconnects = 1; static int allowmultiplelogin = 1; static int timestampevents; static int httptimeout = 60; static int manager_enabled = 0; static int webmanager_enabled = 0; +static char* manager_channelvars = ""; #define DEFAULT_REALM "asterisk" static char global_realm[MAXHOSTNAMELEN]; /*!< Default realm */ @@ -886,6 +891,16 @@ static void ref_event(struct eventqent *e); static void free_channelvars(void); +/*! \brief return Yes or No depending on the argument. + * This is used in many places in CLI command, having a function to generate + * this helps maintaining a consistent output (and possibly emitting the + * output in other languages, at some point). + */ +static const char *cli_yesno(int x) +{ + return x ? "Yes" : "No"; +} + /*! \brief Add a custom hook to be called when an event is fired */ void ast_manager_register_hook(struct manager_custom_hook *hook) { @@ -1143,7 +1158,6 @@ return inuse; } - /*! * lookup an entry in the list of registered users. * must be called with the list lock held. @@ -1179,6 +1193,8 @@ return ret; } + + static char *handle_showmancmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct manager_action *cur; @@ -1503,7 +1519,46 @@ return CLI_SUCCESS; } +/*! \brief CLI command manager show settings */ +static char *handle_manager_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +{ + switch (cmd) { + case CLI_INIT: + e->command = "manager show settings"; + e->usage = + "Usage: manager show settings\n" + " Provides detailed list of the configuration of the Manager.\n"; + return NULL; + case CLI_GENERATE: + return NULL; + } + if (a->argc != 3) { + return CLI_SHOWUSAGE; + } + ast_cli(a->fd, "\nGlobal Settings:\n"); + ast_cli(a->fd, "----------------\n"); + ast_cli(a->fd, " Manager (AMI): %s\n", cli_yesno(manager_enabled)); + ast_cli(a->fd, " Web Manager (AMI/HTTP): %s\n", cli_yesno(webmanager_enabled)); + ast_cli(a->fd, " TCP Bindaddress: %s\n", ast_inet_ntoa(ami_desc.local_address.sin_addr)); + ast_cli(a->fd, " TCP Port: %d\n", ntohs(ami_desc.local_address.sin_port)); + ast_cli(a->fd, " HTTP Timeout (minutes): %d\n", httptimeout); + ast_cli(a->fd, " TLS Enable: %s\n", cli_yesno(ami_tls_cfg.enabled)); + ast_cli(a->fd, " TLS Bindaddress: %s\n", ast_inet_ntoa(amis_desc.local_address.sin_addr)); + ast_cli(a->fd, " TLS Port: %d\n", ntohs(amis_desc.local_address.sin_port)); + ast_cli(a->fd, " TLS Certfile: %s\n", ami_tls_cfg.certfile); + ast_cli(a->fd, " TLS Privatekey: %s\n", ami_tls_cfg.pvtfile); + ast_cli(a->fd, " TLS Cipher: %s\n", ami_tls_cfg.cipher); + ast_cli(a->fd, " Allow multiple login: %s\n", cli_yesno(allowmultiplelogin)); + ast_cli(a->fd, " Display connects: %s\n", cli_yesno(displayconnects)); + ast_cli(a->fd, " Timestamp events: %s\n", cli_yesno(timestampevents)); + ast_cli(a->fd, " Channel vars: %s\n", manager_channelvars); + ast_cli(a->fd, " Debug: %s\n", cli_yesno(manager_debug)); + ast_cli(a->fd, " Block sockets: %s\n", cli_yesno(block_sockets)); + + return CLI_SUCCESS; +} + static struct ast_cli_entry cli_manager[] = { AST_CLI_DEFINE(handle_showmancmd, "Show a manager interface command"), AST_CLI_DEFINE(handle_showmancmds, "List manager interface commands"), @@ -1513,6 +1568,7 @@ AST_CLI_DEFINE(handle_showmanager, "Display information on a specific manager user"), AST_CLI_DEFINE(handle_mandebug, "Show, enable, disable debugging of the manager code"), AST_CLI_DEFINE(handle_manager_reload, "Reload manager configurations"), + AST_CLI_DEFINE(handle_manager_show_settings, "Show manager global settings"), }; static struct eventqent *unref_event(struct eventqent *e) @@ -5486,7 +5542,6 @@ purge_events(); } -static struct ast_tls_config ami_tls_cfg; static struct ast_tcptls_session_args ami_desc = { .accept_fd = -1, .master = AST_PTHREADT_NULL, @@ -5627,6 +5682,7 @@ } else if (!strcasecmp(var->name, "httptimeout")) { newhttptimeout = atoi(val); } else if (!strcasecmp(var->name, "channelvars")) { + manager_channelvars = ast_strdup(val); struct manager_channel_variable *mcv; char *remaining = ast_strdupa(val), *next; AST_RWLIST_WRLOCK(&channelvars);