[xiph-commits] r8245 - in icecast/trunk/icecast: conf doc src

karl at motherfish-iii.xiph.org karl at motherfish-iii.xiph.org
Mon Nov 22 10:21:49 PST 2004


Author: karl
Date: 2004-11-22 10:21:48 -0800 (Mon, 22 Nov 2004)
New Revision: 8245

Modified:
   icecast/trunk/icecast/conf/icecast.xml.in
   icecast/trunk/icecast/doc/icecast2_config_file.html
   icecast/trunk/icecast/src/admin.c
   icecast/trunk/icecast/src/cfgfile.c
   icecast/trunk/icecast/src/cfgfile.h
   icecast/trunk/icecast/src/source.c
   icecast/trunk/icecast/src/source.h
   icecast/trunk/icecast/src/stats.c
   icecast/trunk/icecast/src/stats.h
Log:
merge per-mount hidden setting. prevent specific mountpoints being listed
on status.xsl and streamlist


Modified: icecast/trunk/icecast/conf/icecast.xml.in
===================================================================
--- icecast/trunk/icecast/conf/icecast.xml.in	2004-11-22 17:09:42 UTC (rev 8244)
+++ icecast/trunk/icecast/conf/icecast.xml.in	2004-11-22 18:21:48 UTC (rev 8245)
@@ -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"/>

Modified: icecast/trunk/icecast/doc/icecast2_config_file.html
===================================================================
--- icecast/trunk/icecast/doc/icecast2_config_file.html	2004-11-22 17:09:42 UTC (rev 8244)
+++ icecast/trunk/icecast/doc/icecast2_config_file.html	2004-11-22 18:21:48 UTC (rev 8245)
@@ -321,6 +321,7 @@
         &lt;fallback-mount&gt;/example2.ogg&lt;/fallback-mount&gt;
         &lt;fallback-override&gt;1&lt;/fallback-override&gt;
         &lt;no-yp&gt;1&lt;/no-yp&gt;
+        &lt;hidden&gt;1&lt;/hidden&gt;
         &lt;burst-size&gt;65536&lt;/burst-size&gt;
         &lt;authentication type="htpasswd"&gt;
                 &lt;option name="filename" value="myauth"/&gt;
@@ -379,6 +380,12 @@
 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>.

Modified: icecast/trunk/icecast/src/admin.c
===================================================================
--- icecast/trunk/icecast/src/admin.c	2004-11-22 17:09:42 UTC (rev 8244)
+++ icecast/trunk/icecast/src/admin.c	2004-11-22 18:21:48 UTC (rev 8245)
@@ -904,7 +904,7 @@
 
     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_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;

Modified: icecast/trunk/icecast/src/cfgfile.c
===================================================================
--- icecast/trunk/icecast/src/cfgfile.c	2004-11-22 17:09:42 UTC (rev 8244)
+++ icecast/trunk/icecast/src/cfgfile.c	2004-11-22 18:21:48 UTC (rev 8245)
@@ -558,6 +558,11 @@
             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;

Modified: icecast/trunk/icecast/src/cfgfile.h
===================================================================
--- icecast/trunk/icecast/src/cfgfile.h	2004-11-22 17:09:42 UTC (rev 8244)
+++ icecast/trunk/icecast/src/cfgfile.h	2004-11-22 18:21:48 UTC (rev 8245)
@@ -58,6 +58,7 @@
                      * 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 */

Modified: icecast/trunk/icecast/src/source.c
===================================================================
--- icecast/trunk/icecast/src/source.c	2004-11-22 17:09:42 UTC (rev 8244)
+++ icecast/trunk/icecast/src/source.c	2004-11-22 18:21:48 UTC (rev 8245)
@@ -243,6 +243,7 @@
     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 @@
     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);

Modified: icecast/trunk/icecast/src/source.h
===================================================================
--- icecast/trunk/icecast/src/source.h	2004-11-22 17:09:42 UTC (rev 8244)
+++ icecast/trunk/icecast/src/source.h	2004-11-22 18:21:48 UTC (rev 8245)
@@ -66,6 +66,7 @@
     unsigned int queue_size_limit;
 
     unsigned timeout;  /* source timeout in seconds */
+    int hidden;
     time_t last_read;
     int short_delay;
 

Modified: icecast/trunk/icecast/src/stats.c
===================================================================
--- icecast/trunk/icecast/src/stats.c	2004-11-22 17:09:42 UTC (rev 8244)
+++ icecast/trunk/icecast/src/stats.c	2004-11-22 18:21:48 UTC (rev 8245)
@@ -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,7 +208,23 @@
         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 @@
         copy->value = (char *)strdup(event->value);
     else
         copy->value = NULL;
+    copy->hidden = event->hidden;
     copy->next = NULL;
 
     return copy;
@@ -373,6 +391,14 @@
 {
     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 @@
         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 @@
                 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 @@
         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 @@
         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 @@
 {
     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 @@
     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);

Modified: icecast/trunk/icecast/src/stats.h
===================================================================
--- icecast/trunk/icecast/src/stats.h	2004-11-22 17:09:42 UTC (rev 8244)
+++ icecast/trunk/icecast/src/stats.h	2004-11-22 18:21:48 UTC (rev 8245)
@@ -31,6 +31,7 @@
 {
     char *name;
     char *value;
+    int hidden;
 } stats_node_t;
 
 typedef struct _stats_event_tag
@@ -38,6 +39,7 @@
     char *source;
     char *name;
     char *value;
+    int  hidden;
     int  action;
 
     struct _stats_event_tag *next;
@@ -46,6 +48,7 @@
 typedef struct _stats_source_tag
 {
     char *source;
+    int  hidden;
     avl_tree *stats_tree;
 } stats_source_t;
 
@@ -83,13 +86,14 @@
 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__ */



More information about the commits mailing list