40 "Usage: ari show status\n"
41 " Shows all ARI settings\n";
56 ast_cli(a->fd,
"Error getting ARI configuration\n");
60 ast_cli(a->fd,
"ARI Status:\n");
62 ast_cli(a->fd,
"Output format: ");
64 ast_cli(a->fd,
"pretty");
66 ast_cli(a->fd,
"compact");
69 ast_cli(a->fd,
"Auth realm: %s\n",
conf->
general->auth_realm);
70 ast_cli(a->fd,
"Allowed Origins: %s\n",
conf->
general->allowed_origins);
75 static int show_users_cb(
void *obj,
void *arg,
int flags)
80 ast_cli(a->fd,
"%-4s %s\n",
95 "Usage: ari show users\n"
96 " Shows all ARI users\n";
105 return CLI_SHOWUSAGE;
110 ast_cli(a->fd,
"Error getting ARI configuration\n");
114 ast_cli(a->fd,
"r/o? Username\n");
115 ast_cli(a->fd,
"---- --------\n");
129 static int complete_ari_user_search(
void *obj,
void *arg,
void *data,
int flags)
150 ast_cli(a->fd,
"Error getting ARI configuration\n");
154 user = ao2_callback_data(
conf->users,
156 complete_ari_user_search, (
char*)a->word, &search);
161 static char *complete_ari_show_user(
struct ast_cli_args *a)
164 return complete_ari_user(a);
179 "Usage: ari show user <username>\n"
180 " Shows a specific ARI user\n";
183 return complete_ari_show_user(a);
189 return CLI_SHOWUSAGE;
195 ast_cli(a->fd,
"Error getting ARI configuration\n");
201 ast_cli(a->fd,
"User '%s' not found\n", a->argv[3]);
205 ast_cli(a->fd,
"Username: %s\n", user->
username);
213 RAII_VAR(
char *, crypted, NULL, ast_free);
219 "Usage: ari mkpasswd <password>\n"
220 " Encrypts a password for use in ari.conf\n"
221 " Be aware that the password will be shown in the\n"
222 " command line history. The mkpasswd shell command\n"
223 " may be preferable.\n"
233 return CLI_SHOWUSAGE;
238 ast_cli(a->fd,
"Failed to encrypt password\n");
243 "; Copy the following two lines into ari.conf\n");
244 ast_cli(a->fd,
"password_format = crypt\n");
245 ast_cli(a->fd,
"password = %s\n", crypted);
260 "Usage: ari show apps\n"
261 " Lists all registered applications.\n"
271 return CLI_SHOWUSAGE;
276 ast_cli(a->fd,
"Unable to retrieve registered applications!\n");
280 ast_cli(a->fd,
"Application Name \n");
281 ast_cli(a->fd,
"=========================\n");
283 while ((app = ao2_iterator_next(&it_apps))) {
284 ast_cli(a->fd,
"%-25.25s\n", app);
301 static int complete_ari_app_search(
void *obj,
void *arg,
void *data,
int flags)
311 static char *complete_ari_app(
struct ast_cli_args *a,
int include_all)
314 RAII_VAR(
char *, app, NULL, ao2_cleanup);
325 ast_cli(a->fd,
"Error getting ARI applications\n");
329 if (include_all && ast_strlen_zero(a->word)) {
333 app = ao2_callback_data(apps,
335 complete_ari_app_search, (
char*)a->word, &search);
348 "Usage: ari show app <application>\n"
349 " Provide detailed information about a registered application.\n"
353 return complete_ari_app(a, 0);
359 return CLI_SHOWUSAGE;
383 "Usage: ari set debug <application|all> <on|off>\n"
384 " Enable or disable debugging on a specific application.\n"
388 return complete_ari_app(a, 1);
394 return CLI_SHOWUSAGE;
397 debug = !strcmp(a->argv[4],
"on");
399 if (!strcmp(a->argv[3],
"all")) {
401 ast_cli(a->fd,
"Debugging on all applications %s\n",
402 debug ?
"enabled" :
"disabled");
412 ast_cli(a->fd,
"Debugging on '%s' %s\n",
414 debug ?
"enabled" :
"disabled");
422 AST_CLI_DEFINE(ari_show,
"Show ARI settings"),
423 AST_CLI_DEFINE(ari_show_users,
"List ARI users"),
424 AST_CLI_DEFINE(ari_show_user,
"List single ARI user"),
425 AST_CLI_DEFINE(ari_mkpasswd,
"Encrypts a password"),
426 AST_CLI_DEFINE(ari_show_apps,
"List registered ARI applications"),
427 AST_CLI_DEFINE(ari_show_app,
"Display details of a registered ARI application"),
428 AST_CLI_DEFINE(ari_set_debug,
"Enable/disable debugging of an ARI application"),
struct stasis_app * stasis_app_get_by_name(const char *name)
Retrieve a handle to a Stasis application by its name.
Asterisk main include file. File version handling, generic pbx functions.
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Registered applications container.
struct ast_ari_conf * ast_ari_config_get(void)
Get the current ARI configuration.
descriptor for a cli entry.
static int debug
Global debug status.
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container, as described below.
All configuration options for ARI.
void stasis_app_to_cli(const struct stasis_app *app, struct ast_cli_args *a)
Dump properties of a stasis_app to the CLI.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ast_strdup(str)
A wrapper for strdup()
All configuration options for http media cache.
struct conf_general_options * general
The arg parameter is a partial search key similar to OBJ_SEARCH_KEY.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
const char * stasis_app_name(const struct stasis_app *app)
Retrieve an application's name.
int ast_ari_cli_register(void)
Register CLI commands for ARI.
Per-user configuration options.
Internal API's for res_ari.
void stasis_app_set_global_debug(int debug)
Enable/disable request/response and event logging on all applications.
struct ao2_container * stasis_app_get_all(void)
Gets the names of all registered Stasis applications.
structure to hold users read from users.conf
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Standard Command Line Interface.
void ast_ari_cli_unregister(void)
Unregister CLI commands for ARI.
void stasis_app_set_debug(struct stasis_app *app, int debug)
Enable/disable request/response and event logging on an application.
Stasis Application API. See Stasis Application API for detailed documentation.
#define AST_CLI_YESNO(x)
Return Yes or No depending on the argument.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
int ast_str_container_add(struct ao2_container *str_container, const char *add)
Adds a string to a string container allocated by ast_str_container_alloc.
char * ast_crypt_encrypt(const char *key)
Asterisk wrapper around crypt(3) for encrypting passwords.