mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2025-01-03 14:56:34 -05:00
merge per-mount hidden setting. prevent specific mountpoints being listed
on status.xsl and streamlist svn path=/icecast/trunk/icecast/; revision=8245
This commit is contained in:
parent
2b4ee737db
commit
a521d15d74
@ -91,6 +91,7 @@
|
||||
<burst-size>65536</burst-size>
|
||||
<fallback-mount>/example2.ogg</fallback-mount>
|
||||
<fallback-override>1</fallback-override>
|
||||
<hidden>1</hidden>
|
||||
<no-yp>1</no-yp>
|
||||
<authentication type="htpasswd">
|
||||
<option name="filename" value="myauth"/>
|
||||
|
@ -321,6 +321,7 @@ If you are relaying a Shoutcast stream, you need to specify this indicator to al
|
||||
<fallback-mount>/example2.ogg</fallback-mount>
|
||||
<fallback-override>1</fallback-override>
|
||||
<no-yp>1</no-yp>
|
||||
<hidden>1</hidden>
|
||||
<burst-size>65536</burst-size>
|
||||
<authentication type="htpasswd">
|
||||
<option name="filename" value="myauth"/>
|
||||
@ -379,6 +380,12 @@ to a local relay instead
|
||||
This optional setting allows for providing a burst size which overrides the default burst size
|
||||
as defined in limits. The value is in bytes.
|
||||
</div>
|
||||
<h4>hidden</h4>
|
||||
<div class="indentedbox">
|
||||
Enable this to prevent this mount from being shown on the xsl pages. This is mainly
|
||||
for cases where a local relay is configured and you do not want the source of the local
|
||||
relay to be shown
|
||||
</div>
|
||||
<h4>authentication</h4>
|
||||
<div class="indentedbox">
|
||||
This specifies that the named mount point will require listener authentication. Currently, we only support a file-based authentication scheme (type=htpasswd). Users and encrypted password are placed in this file (separated by a :) and all requests for this mountpoint will require that a user and password be supplied for authentication purposes. These values are passed in via normal HTTP Basic Authentication means (i.e. http://user:password@stream:port/mountpoint.ogg). Users and Passwords are maintained via the web admin interface. A mountpoint configured with an authenticator will display a red key next to the mount point name on the admin screens. You can read more about listener authentication <a href="icecast2_listenerauth.html">here</a>.
|
||||
|
21
src/admin.c
21
src/admin.c
@ -904,7 +904,7 @@ static void command_stats(client_t *client, int response) {
|
||||
|
||||
DEBUG0("Stats request, sending xml stats");
|
||||
|
||||
stats_get_xml(&doc);
|
||||
stats_get_xml(&doc, 1);
|
||||
admin_send_response(doc, client, response, STATS_TRANSFORMED_REQUEST);
|
||||
xmlFreeDoc(doc);
|
||||
client_destroy(client);
|
||||
@ -913,31 +913,30 @@ static void command_stats(client_t *client, int response) {
|
||||
|
||||
static void command_list_mounts(client_t *client, int response)
|
||||
{
|
||||
avl_node *node;
|
||||
source_t *source;
|
||||
|
||||
DEBUG0("List mounts request");
|
||||
|
||||
avl_tree_rlock (global.source_tree);
|
||||
if (response == PLAINTEXT)
|
||||
{
|
||||
char buffer [4096], *buf = buffer;
|
||||
unsigned remaining = sizeof (buffer);
|
||||
int ret = sprintf (buffer,
|
||||
unsigned int remaining = sizeof (buffer);
|
||||
int ret = snprintf (buffer, remaining,
|
||||
"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n");
|
||||
|
||||
node = avl_get_first(global.source_tree);
|
||||
while (node && ret > 0 && ret < remaining)
|
||||
avl_node *node = avl_get_first(global.source_tree);
|
||||
while (node && ret > 0 && (unsigned)ret < remaining)
|
||||
{
|
||||
source_t *source = (source_t *)node->key;
|
||||
node = avl_get_next(node);
|
||||
if (source->hidden)
|
||||
continue;
|
||||
remaining -= ret;
|
||||
buf += ret;
|
||||
source = (source_t *)node->key;
|
||||
ret = snprintf (buf, remaining, "%s\n", source->mount);
|
||||
node = avl_get_next(node);
|
||||
}
|
||||
avl_tree_unlock (global.source_tree);
|
||||
/* handle last line */
|
||||
if (ret > 0 && ret < remaining)
|
||||
if (ret > 0 && (unsigned)ret < remaining)
|
||||
{
|
||||
remaining -= ret;
|
||||
buf += ret;
|
||||
|
@ -558,6 +558,11 @@ static void _parse_mount(xmlDocPtr doc, xmlNodePtr node,
|
||||
mount->no_yp = atoi(tmp);
|
||||
if(tmp) xmlFree(tmp);
|
||||
}
|
||||
else if (strcmp(node->name, "hidden") == 0) {
|
||||
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
|
||||
mount->hidden = atoi(tmp);
|
||||
if(tmp) xmlFree(tmp);
|
||||
}
|
||||
else if (strcmp(node->name, "authentication") == 0) {
|
||||
mount->auth_type = xmlGetProp(node, "type");
|
||||
option = node->xmlChildrenNode;
|
||||
|
@ -58,6 +58,7 @@ typedef struct _mount_proxy {
|
||||
* from global setting */
|
||||
unsigned int queue_size_limit;
|
||||
int no_yp; /* Do we prevent YP on this mount */
|
||||
int hidden; /* Do we list this on the xsl pages */
|
||||
unsigned int source_timeout; /* source timeout in seconds */
|
||||
|
||||
char *auth_type; /* Authentication type */
|
||||
|
@ -243,6 +243,7 @@ void source_clear_source (source_t *source)
|
||||
source->max_listeners = -1;
|
||||
source->yp_public = 0;
|
||||
source->yp_prevent = 0;
|
||||
source->hidden = 0;
|
||||
util_dict_free (source->audio_info);
|
||||
source->audio_info = NULL;
|
||||
|
||||
@ -855,6 +856,9 @@ void source_apply_mount (source_t *source, mount_proxy *mountinfo)
|
||||
source->max_listeners = mountinfo->max_listeners;
|
||||
source->fallback_override = mountinfo->fallback_override;
|
||||
source->no_mount = mountinfo->no_mount;
|
||||
source->hidden = mountinfo->hidden;
|
||||
stats_event_hidden (source->mount, NULL, source->hidden);
|
||||
|
||||
if (mountinfo->fallback_mount)
|
||||
{
|
||||
source->fallback_mount = strdup (mountinfo->fallback_mount);
|
||||
|
@ -66,6 +66,7 @@ typedef struct source_tag
|
||||
unsigned int queue_size_limit;
|
||||
|
||||
unsigned timeout; /* source timeout in seconds */
|
||||
int hidden;
|
||||
time_t last_read;
|
||||
int short_delay;
|
||||
|
||||
|
73
src/stats.c
73
src/stats.c
@ -48,6 +48,7 @@
|
||||
#define STATS_EVENT_DEC 2
|
||||
#define STATS_EVENT_ADD 3
|
||||
#define STATS_EVENT_REMOVE 4
|
||||
#define STATS_EVENT_HIDDEN 5
|
||||
|
||||
typedef struct _event_listener_tag
|
||||
{
|
||||
@ -207,6 +208,22 @@ void stats_event(const char *source, const char *name, const char *value)
|
||||
queue_global_event (event);
|
||||
}
|
||||
|
||||
/* make stat hidden (non-zero). name can be NULL if it applies to a whole
|
||||
* source stats tree. */
|
||||
void stats_event_hidden (const char *source, const char *name, int hidden)
|
||||
{
|
||||
stats_event_t *event;
|
||||
const char *str = NULL;
|
||||
|
||||
if (hidden)
|
||||
str = "";
|
||||
event = build_event (source, name, str);
|
||||
if (event)
|
||||
{
|
||||
event->action = STATS_EVENT_HIDDEN;
|
||||
queue_global_event (event);
|
||||
}
|
||||
}
|
||||
|
||||
/* printf style formatting for stat create/update */
|
||||
void stats_event_args(const char *source, char *name, char *format, ...)
|
||||
@ -362,6 +379,7 @@ static stats_event_t *_copy_event(stats_event_t *event)
|
||||
copy->value = (char *)strdup(event->value);
|
||||
else
|
||||
copy->value = NULL;
|
||||
copy->hidden = event->hidden;
|
||||
copy->next = NULL;
|
||||
|
||||
return copy;
|
||||
@ -373,6 +391,14 @@ static void modify_node_event (stats_node_t *node, stats_event_t *event)
|
||||
{
|
||||
char *str;
|
||||
|
||||
if (event->action == STATS_EVENT_HIDDEN)
|
||||
{
|
||||
if (event->value)
|
||||
node->hidden = 1;
|
||||
else
|
||||
node->hidden = 0;
|
||||
return;
|
||||
}
|
||||
if (event->action != STATS_EVENT_SET)
|
||||
{
|
||||
int value = 0;
|
||||
@ -445,6 +471,10 @@ static void process_source_event (stats_event_t *event)
|
||||
DEBUG1 ("new source stat %s", event->source);
|
||||
snode->source = (char *)strdup(event->source);
|
||||
snode->stats_tree = avl_tree_new(_compare_stats, NULL);
|
||||
if (event->action == STATS_EVENT_HIDDEN)
|
||||
snode->hidden = 1;
|
||||
else
|
||||
snode->hidden = 0;
|
||||
|
||||
avl_insert(_stats.source_tree, (void *)snode);
|
||||
}
|
||||
@ -462,6 +492,7 @@ static void process_source_event (stats_event_t *event)
|
||||
node = (stats_node_t *)calloc(1,sizeof(stats_node_t));
|
||||
node->name = (char *)strdup(event->name);
|
||||
node->value = (char *)strdup(event->value);
|
||||
node->hidden = snode->hidden;
|
||||
|
||||
avl_insert(snode->stats_tree, (void *)node);
|
||||
}
|
||||
@ -476,6 +507,22 @@ static void process_source_event (stats_event_t *event)
|
||||
modify_node_event (node, event);
|
||||
return;
|
||||
}
|
||||
if (event->action == STATS_EVENT_HIDDEN)
|
||||
{
|
||||
avl_node *node = avl_get_first (snode->stats_tree);
|
||||
|
||||
if (event->value)
|
||||
snode->hidden = 1;
|
||||
else
|
||||
snode->hidden = 0;
|
||||
while (node)
|
||||
{
|
||||
stats_node_t *stats = (stats_node_t*)node->key;
|
||||
stats->hidden = snode->hidden;
|
||||
node = avl_get_next (node);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (event->action == STATS_EVENT_REMOVE)
|
||||
{
|
||||
DEBUG1 ("delete source node %s", event->source);
|
||||
@ -579,6 +626,7 @@ static stats_event_t *_make_event_from_node(stats_node_t *node, char *source)
|
||||
event->source = NULL;
|
||||
event->name = (char *)strdup(node->name);
|
||||
event->value = (char *)strdup(node->value);
|
||||
event->hidden = node->hidden;
|
||||
event->action = STATS_EVENT_SET;
|
||||
event->next = NULL;
|
||||
|
||||
@ -798,14 +846,14 @@ void stats_transform_xslt(client_t *client, char *xslpath)
|
||||
{
|
||||
xmlDocPtr doc;
|
||||
|
||||
stats_get_xml(&doc);
|
||||
stats_get_xml(&doc, 0);
|
||||
|
||||
xslt_transform(doc, xslpath, client);
|
||||
|
||||
xmlFreeDoc(doc);
|
||||
}
|
||||
|
||||
void stats_get_xml(xmlDocPtr *doc)
|
||||
void stats_get_xml(xmlDocPtr *doc, int show_hidden)
|
||||
{
|
||||
stats_event_t *event;
|
||||
stats_event_t *queue;
|
||||
@ -824,16 +872,19 @@ void stats_get_xml(xmlDocPtr *doc)
|
||||
event = _get_event_from_queue(&queue);
|
||||
while (event)
|
||||
{
|
||||
xmlChar *name, *value;
|
||||
name = xmlEncodeEntitiesReentrant (*doc, event->name);
|
||||
value = xmlEncodeEntitiesReentrant (*doc, event->value);
|
||||
srcnode = node;
|
||||
if (event->source) {
|
||||
srcnode = _find_xml_node(event->source, &src_nodes, node);
|
||||
if (event->hidden <= show_hidden)
|
||||
{
|
||||
xmlChar *name, *value;
|
||||
name = xmlEncodeEntitiesReentrant (*doc, event->name);
|
||||
value = xmlEncodeEntitiesReentrant (*doc, event->value);
|
||||
srcnode = node;
|
||||
if (event->source) {
|
||||
srcnode = _find_xml_node(event->source, &src_nodes, node);
|
||||
}
|
||||
xmlNewChild(srcnode, NULL, name, value);
|
||||
xmlFree (value);
|
||||
xmlFree (name);
|
||||
}
|
||||
xmlNewChild(srcnode, NULL, name, value);
|
||||
xmlFree (value);
|
||||
xmlFree (name);
|
||||
|
||||
_free_event(event);
|
||||
event = _get_event_from_queue(&queue);
|
||||
|
@ -31,6 +31,7 @@ typedef struct _stats_node_tag
|
||||
{
|
||||
char *name;
|
||||
char *value;
|
||||
int hidden;
|
||||
} stats_node_t;
|
||||
|
||||
typedef struct _stats_event_tag
|
||||
@ -38,6 +39,7 @@ typedef struct _stats_event_tag
|
||||
char *source;
|
||||
char *name;
|
||||
char *value;
|
||||
int hidden;
|
||||
int action;
|
||||
|
||||
struct _stats_event_tag *next;
|
||||
@ -46,6 +48,7 @@ typedef struct _stats_event_tag
|
||||
typedef struct _stats_source_tag
|
||||
{
|
||||
char *source;
|
||||
int hidden;
|
||||
avl_tree *stats_tree;
|
||||
} stats_source_t;
|
||||
|
||||
@ -83,13 +86,14 @@ void stats_event_args(const char *source, char *name, char *format, ...);
|
||||
void stats_event_inc(const char *source, const char *name);
|
||||
void stats_event_add(const char *source, const char *name, unsigned long value);
|
||||
void stats_event_dec(const char *source, const char *name);
|
||||
void stats_event_hidden (const char *source, const char *name, int hidden);
|
||||
|
||||
void *stats_connection(void *arg);
|
||||
void *stats_callback(void *arg);
|
||||
|
||||
void stats_transform_xslt(client_t *client, char *xslpath);
|
||||
void stats_sendxml(client_t *client);
|
||||
void stats_get_xml(xmlDocPtr *doc);
|
||||
void stats_get_xml(xmlDocPtr *doc, int show_hidden);
|
||||
char *stats_get_value(char *source, char *name);
|
||||
|
||||
#endif /* __STATS_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user