if (ret < 0) {
if (scd.sender_num < 0)
return ret;
- msg = senders[scd.sender_num].help();
+ if (strcmp(cc->argv[2], "status") == 0)
+ msg = senders[scd.sender_num].status();
+ else
+ msg = senders[scd.sender_num].help();
return send_sb(&cc->scc, msg, strlen(msg), SBD_OUTPUT, false);
}
/* server info */
static int com_si(struct command_context *cc)
{
- int i, ret;
- char *msg, *ut, *sender_info = NULL;
+ int ret;
+ char *msg, *ut;
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
mutex_lock(mmd_mutex);
- for (i = 0; senders[i].name; i++) {
- char *info = senders[i].info();
- sender_info = para_strcat(sender_info, info);
- free(info);
- }
ut = get_server_uptime_str(now);
ret = xasprintf(&msg,
"up: %s\nplayed: %u\n"
"afs_pid: %d\n"
"connections (active/accepted/total): %u/%u/%u\n"
"current loglevel: %s\n"
- "supported audio formats: %s\n"
- "%s",
+ "supported audio formats: %s\n",
ut, mmd->num_played,
(int)getppid(),
(int)mmd->afs_pid,
mmd->num_commands,
mmd->num_connects,
conf.loglevel_arg,
- AUDIO_FORMAT_HANDLERS,
- sender_info
+ AUDIO_FORMAT_HANDLERS
);
mutex_unlock(mmd_mutex);
free(ut);
- free(sender_info);
return send_sb(&cc->scc, msg, ret, SBD_OUTPUT, false);
}
return list;
}
-static char *dccp_info(void)
+static char *dccp_status(void)
{
- char *info = get_sender_info(dss, "dccp");
- char *ret = make_message("%s" "\tsupported ccids: %s\n",
- info, dccp_list_available_ccids());
- free(info);
- return ret;
+ char *status = generic_sender_status(dss, "dccp");
+ char *result = make_message("%ssupported ccids: %s\n", status,
+ dccp_list_available_ccids());
+ free(status);
+ return result;
}
/**
{
int ret, k, n;
- s->info = dccp_info;
+ s->status = dccp_status;
s->send = NULL;
s->pre_select = dccp_pre_select;
s->post_select = dccp_post_select;
return 1;
}
-static char *http_info(void)
+static char *http_status(void)
{
- return get_sender_info(hss, "http");
+ return generic_sender_status(hss, "http");
}
/**
void http_send_init(struct sender *s)
{
int ret;
- s->info = http_info;
+ s->status = http_status;
s->send = http_send;
s->pre_select = http_pre_select;
s->post_select = http_post_select;
*
* The result must be dynamically allocated and is freed by the caller.
*/
- char* (*info)(void);
+ char* (*status)(void);
/**
* The send-hook.
*
void shutdown_clients(struct sender_status *ss);
void init_sender_status(struct sender_status *ss, char **access_arg, int num_access_args,
int port, int max_clients, int default_deny);
-char *get_sender_info(struct sender_status *ss, const char *name);
+char *generic_sender_status(struct sender_status *ss, const char *name);
void generic_com_allow(struct sender_command_data *scd,
struct sender_status *ss);
*
* \return The string printed in the "si" command.
*/
-char *get_sender_info(struct sender_status *ss, const char *name)
+char *generic_sender_status(struct sender_status *ss, const char *name)
{
char *clnts = NULL, *ret;
struct sender_client *sc, *tmp_sc;
clnts = tmp;
}
ret = make_message(
- "%s sender:\n"
- "\tstatus: %s\n"
- "\tport: %s\n"
- "\tnumber of connected clients: %d\n"
- "\tmaximal number of clients: %d%s\n"
- "\tconnected clients: %s\n"
- "\taccess %s list: %s\n",
- name,
+ "status: %s\n"
+ "port: %s\n"
+ "number of connected clients: %d\n"
+ "maximal number of clients: %d%s\n"
+ "connected clients: %s\n"
+ "access %s list: %s\n",
(ss->listen_fd >= 0)? "on" : "off",
stringify_port(ss->port, strcmp(name, "http") ? "dccp" : "tcp"),
ss->num_clients,
H: Send a command to a specific sender. The following commands are available, but
H: not all senders support every command.
H:
-H: help, on, off, add, delete, allow, deny.
+H: help, on, off, add, delete, allow, deny, status.
H:
H: The help command prints the help text of the given sender. If no command is
H: given the list of compiled in senders is shown.
return ret;
}
-static char *udp_info(void)
+static char *udp_status(void)
{
struct sender_client *sc;
char *ret, *tgts = NULL;
tgts = tmp;
}
ret = make_message(
- "udp sender:\n"
- "\tstatus: %s\n"
- "\tport: %s\n"
- "\ttargets: %s\n",
+ "status: %s\n"
+ "port: %s\n"
+ "targets: %s\n",
(sender_status == SENDER_ON)? "on" : "off",
stringify_port(conf.udp_default_port_arg, "udp"),
tgts? tgts : "(none)"
void udp_send_init(struct sender *s)
{
INIT_LIST_HEAD(&targets);
- s->info = udp_info;
+ s->status = udp_status;
s->help = udp_help;
s->send = NULL;
s->pre_select = NULL;
Examples
~~~~~~~~
-The sender command of para_server allows to (de-)activate senders
-and to change the access permissions senders at runtime. The "si"
-(server info) command is used to list the streaming options of the
-currently running server as well as the various sender access lists.
+The "si" (server info) command lists some information about the
+currently running server process.
--> Show client/target/access lists:
+-> Show PIDs, number of connected clients, uptime, and more:
para_client si
+The sender command of para_server prints information about senders,
+like the various access control lists, and it allows to (de-)activate
+senders and to change the access permissions at runtime.
+
+-> List all senders
+
+ para_client sender
+
-> Obtain general help for the sender command:
para_client help sender
s=http # or dccp or udp
para_client sender $s help
+-> Show status of the http sender
+
+ para_client sender http status
+
By default para_server activates both the HTTP and th DCCP sender on
startup. This can be changed via command line options or para_server's
config file.