[xiph-commits] r8345 - in icecast/trunk/icecast: admin conf src

oddsock at motherfish-iii.xiph.org oddsock at motherfish-iii.xiph.org
Tue Dec 7 14:29:47 PST 2004


Author: oddsock
Date: 2004-12-07 14:29:46 -0800 (Tue, 07 Dec 2004)
New Revision: 8345

Added:
   icecast/trunk/icecast/admin/updatemetadata.xsl
Modified:
   icecast/trunk/icecast/admin/Makefile.am
   icecast/trunk/icecast/admin/listclients.xsl
   icecast/trunk/icecast/admin/listmounts.xsl
   icecast/trunk/icecast/admin/manageauth.xsl
   icecast/trunk/icecast/admin/stats.xsl
   icecast/trunk/icecast/conf/icecast_minimal.xml.in
   icecast/trunk/icecast/src/admin.c
   icecast/trunk/icecast/src/cfgfile.c
   icecast/trunk/icecast/src/cfgfile.h
   icecast/trunk/icecast/src/yp.c
   icecast/trunk/icecast/src/yp.h
Log:
add a new web admin feature which allows the updating of metadata (now that we support metadata updates for most stream types).  This is an new admin feature.

add cluster-password to the config to allow for future clustering of relays on the xiph stream directory.


Modified: icecast/trunk/icecast/admin/Makefile.am
===================================================================
--- icecast/trunk/icecast/admin/Makefile.am	2004-12-07 21:50:23 UTC (rev 8344)
+++ icecast/trunk/icecast/admin/Makefile.am	2004-12-07 22:29:46 UTC (rev 8345)
@@ -4,5 +4,5 @@
 
 admindir = $(pkgdatadir)/admin
 dist_admin_DATA = listclients.xsl listmounts.xsl moveclients.xsl response.xsl \
-	stats.xsl manageauth.xsl
+	stats.xsl manageauth.xsl updatemetadata.xsl
 

Modified: icecast/trunk/icecast/admin/listclients.xsl
===================================================================
--- icecast/trunk/icecast/admin/listclients.xsl	2004-12-07 21:50:23 UTC (rev 8344)
+++ icecast/trunk/icecast/admin/listclients.xsl	2004-12-07 22:29:46 UTC (rev 8345)
@@ -33,6 +33,7 @@
 	    <td align="center">
 		<a class="nav2" href="listclients.xsl?mount={@mount}">Show Listeners</a> | 
         	<a class="nav2" href="moveclients.xsl?mount={@mount}">Move Listeners</a> | 
+		<a class="nav2" href="updatemetadata.xsl?mount={@mount}">Update Metadata</a> |
         	<a class="nav2" href="killsource.xsl?mount={@mount}">Kill Source</a>
 	    </td></tr>
 	</table>

Modified: icecast/trunk/icecast/admin/listmounts.xsl
===================================================================
--- icecast/trunk/icecast/admin/listmounts.xsl	2004-12-07 21:50:23 UTC (rev 8344)
+++ icecast/trunk/icecast/admin/listmounts.xsl	2004-12-07 22:29:46 UTC (rev 8345)
@@ -35,6 +35,7 @@
 	    <td align="center">
 		<a class="nav2" href="listclients.xsl?mount={@mount}">Show Listeners</a> | 
         	<a class="nav2" href="moveclients.xsl?mount={@mount}">Move Listeners</a> | 
+		<a class="nav2" href="updatemetadata.xsl?mount={@mount}">Update Metadata</a> |
         	<a class="nav2" href="killsource.xsl?mount={@mount}">Kill Source</a>
                 <xsl:if test="authenticator"> | <a class="nav2" href="manageauth.xsl?mount={@mount}">Manage Authentication</a></xsl:if>
 	    </td></tr>

Modified: icecast/trunk/icecast/admin/manageauth.xsl
===================================================================
--- icecast/trunk/icecast/admin/manageauth.xsl	2004-12-07 21:50:23 UTC (rev 8344)
+++ icecast/trunk/icecast/admin/manageauth.xsl	2004-12-07 22:29:46 UTC (rev 8345)
@@ -36,6 +36,7 @@
 	    <td align="center">
 		<a class="nav2" href="listclients.xsl?mount={@mount}">Show Listeners</a> | 
         	<a class="nav2" href="moveclients.xsl?mount={@mount}">Move Listeners</a> | 
+		<a class="nav2" href="updatemetadata.xsl?mount={@mount}">Update Metadata</a> |
         	<a class="nav2" href="killsource.xsl?mount={@mount}">Kill Source</a>
 	    </td></tr>
 	</table>

Modified: icecast/trunk/icecast/admin/stats.xsl
===================================================================
--- icecast/trunk/icecast/admin/stats.xsl	2004-12-07 21:50:23 UTC (rev 8344)
+++ icecast/trunk/icecast/admin/stats.xsl	2004-12-07 22:29:46 UTC (rev 8345)
@@ -62,6 +62,7 @@
 	    <td align="center">
 		<a class="nav2" href="listclients.xsl?mount={@mount}">List Clients</a> | 
         	<a class="nav2" href="moveclients.xsl?mount={@mount}">Move MountPoints</a> | 
+        	<a class="nav2" href="updatemetadata.xsl?mount={@mount}">Update Metadata</a> |
         	<a class="nav2" href="killsource.xsl?mount={@mount}">Kill Source</a>
                 <xsl:if test="authenticator"> | <a class="nav2" href="manageauth.xsl?mount={@mount}">Manage Authentication</a></xsl:if>
 	    </td></tr>

Added: icecast/trunk/icecast/admin/updatemetadata.xsl
===================================================================
--- icecast/trunk/icecast/admin/updatemetadata.xsl	2004-12-07 21:50:23 UTC (rev 8344)
+++ icecast/trunk/icecast/admin/updatemetadata.xsl	2004-12-07 22:29:46 UTC (rev 8345)
@@ -0,0 +1,55 @@
+<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" >
+<xsl:output omit-xml-declaration="no" method="xml" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent="yes" encoding="UTF-8" />
+<xsl:template match = "/icestats" >
+<html>
+<head>
+<title>Icecast Streaming Media Server</title>
+<link rel="stylesheet" type="text/css" href="/style.css" />
+</head>
+<body>
+	<center>
+	<table border="0" cellpadding="1" cellspacing="3">
+	<tr>        
+	    <td align="center">
+		<a class="nav" href="listmounts.xsl">List MountPoints</a> | 
+        	<a class="nav" href="moveclients.xsl">Move Listeners</a> | 
+        	<a class="nav" href="stats.xsl">Stats</a> | 
+        	<a class="nav" href="/status.xsl">Status Page</a>
+	    </td></tr>
+	</table>
+	</center>
+<h2>Update Metadata</h2>
+<div class="roundcont">
+<div class="roundtop">
+<img src="/corner_topleft.jpg" class="corner" style="display: none" />
+</div>
+<div class="newscontent">
+<xsl:for-each select="source">
+<h3>
+<xsl:if test="server_name"><xsl:value-of select="server_name" /> </xsl:if>
+(<xsl:value-of select="@mount" />)</h3>
+
+<form method="GET" action="/admin/metadata.xsl">
+<table border="0" cellpadding="4">
+<tr><td>Metadata : <input type="text" name="song"/></td></tr>
+<tr><td><input type="Submit" value="Update"/></td></tr>
+</table>
+<input type="hidden" name="mount" value="{@mount}"/>
+<input type="hidden" name="mode" value="updinfo"/>
+</form>
+
+<br />
+<br />
+</xsl:for-each>
+<xsl:text disable-output-escaping="yes">&amp;</xsl:text>nbsp;
+</div>
+<div class="roundbottom">
+<img src="/corner_bottomleft.jpg" class="corner" style="display: none" />
+</div>
+</div>
+<div class="poster">
+<img align="left" src="/icecast.png" />Support icecast development at <a class="nav" href="http://www.icecast.org">www.icecast.org</a></div>
+</body>
+</html>
+</xsl:template>
+</xsl:stylesheet>

Modified: icecast/trunk/icecast/conf/icecast_minimal.xml.in
===================================================================
--- icecast/trunk/icecast/conf/icecast_minimal.xml.in	2004-12-07 21:50:23 UTC (rev 8344)
+++ icecast/trunk/icecast/conf/icecast_minimal.xml.in	2004-12-07 22:29:46 UTC (rev 8345)
@@ -25,13 +25,11 @@
         <logdir>@localstatedir@/log/@PACKAGE@</logdir>
         <webroot>@pkgdatadir@/web</webroot>
         <adminroot>@pkgdatadir@/admin</adminroot>
+        <alias source="/" dest="/status.xsl"/>
     </paths>
     <logging>
         <accesslog>access.log</accesslog>
         <errorlog>error.log</errorlog>
       	<loglevel>3</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error -->
     </logging>
-    <security>
-        <chroot>0</chroot>
-    </security>
 </icecast>

Modified: icecast/trunk/icecast/src/admin.c
===================================================================
--- icecast/trunk/icecast/src/admin.c	2004-12-07 21:50:23 UTC (rev 8344)
+++ icecast/trunk/icecast/src/admin.c	2004-12-07 22:29:46 UTC (rev 8345)
@@ -48,16 +48,19 @@
 
 /* Mount-specific commands */
 #define COMMAND_RAW_FALLBACK        1
-#define COMMAND_METADATA_UPDATE     2
+#define COMMAND_RAW_METADATA_UPDATE     2
 #define COMMAND_RAW_SHOW_LISTENERS  3
 #define COMMAND_RAW_MOVE_CLIENTS    4
 #define COMMAND_RAW_MANAGEAUTH      5
 #define COMMAND_SHOUTCAST_METADATA_UPDATE     6
+#define COMMAND_RAW_UPDATEMETADATA      7
 
 #define COMMAND_TRANSFORMED_FALLBACK        50
 #define COMMAND_TRANSFORMED_SHOW_LISTENERS  53
 #define COMMAND_TRANSFORMED_MOVE_CLIENTS    54
 #define COMMAND_TRANSFORMED_MANAGEAUTH      55
+#define COMMAND_TRANSFORMED_UPDATEMETADATA  56
+#define COMMAND_TRANSFORMED_METADATA_UPDATE 57
 
 /* Global commands */
 #define COMMAND_RAW_LIST_MOUNTS             101
@@ -80,7 +83,8 @@
 #define FALLBACK_RAW_REQUEST "fallbacks"
 #define FALLBACK_TRANSFORMED_REQUEST "fallbacks.xsl"
 #define SHOUTCAST_METADATA_REQUEST "admin.cgi"
-#define METADATA_REQUEST "metadata"
+#define METADATA_RAW_REQUEST "metadata"
+#define METADATA_TRANSFORMED_REQUEST "metadata.xsl"
 #define LISTCLIENTS_RAW_REQUEST "listclients"
 #define LISTCLIENTS_TRANSFORMED_REQUEST "listclients.xsl"
 #define STATS_RAW_REQUEST "stats"
@@ -99,6 +103,8 @@
 #define ADMIN_XSL_RESPONSE "response.xsl"
 #define MANAGEAUTH_RAW_REQUEST "manageauth"
 #define MANAGEAUTH_TRANSFORMED_REQUEST "manageauth.xsl"
+#define UPDATEMETADATA_RAW_REQUEST "updatemetadata"
+#define UPDATEMETADATA_TRANSFORMED_REQUEST "updatemetadata.xsl"
 #define DEFAULT_RAW_REQUEST ""
 #define DEFAULT_TRANSFORMED_REQUEST ""
 #define BUILDM3U_RAW_REQUEST "buildm3u"
@@ -112,8 +118,10 @@
         return COMMAND_RAW_FALLBACK;
     else if(!strcmp(command, FALLBACK_TRANSFORMED_REQUEST))
         return COMMAND_TRANSFORMED_FALLBACK;
-    else if(!strcmp(command, METADATA_REQUEST))
-        return COMMAND_METADATA_UPDATE;
+    else if(!strcmp(command, METADATA_RAW_REQUEST))
+        return COMMAND_RAW_METADATA_UPDATE;
+    else if(!strcmp(command, METADATA_TRANSFORMED_REQUEST))
+        return COMMAND_TRANSFORMED_METADATA_UPDATE;
     else if(!strcmp(command, SHOUTCAST_METADATA_REQUEST))
         return COMMAND_SHOUTCAST_METADATA_UPDATE;
     else if(!strcmp(command, LISTCLIENTS_RAW_REQUEST))
@@ -150,6 +158,10 @@
         return COMMAND_RAW_MANAGEAUTH;
     else if(!strcmp(command, MANAGEAUTH_TRANSFORMED_REQUEST))
         return COMMAND_TRANSFORMED_MANAGEAUTH;
+    else if(!strcmp(command, UPDATEMETADATA_RAW_REQUEST))
+        return COMMAND_RAW_UPDATEMETADATA;
+    else if(!strcmp(command, UPDATEMETADATA_TRANSFORMED_REQUEST))
+        return COMMAND_TRANSFORMED_UPDATEMETADATA;
     else if(!strcmp(command, BUILDM3U_RAW_REQUEST))
         return COMMAND_BUILDM3U;
     else if(!strcmp(command, DEFAULT_TRANSFORMED_REQUEST))
@@ -161,7 +173,7 @@
 }
 
 static void command_fallback(client_t *client, source_t *source, int response);
-static void command_metadata(client_t *client, source_t *source);
+static void command_metadata(client_t *client, source_t *source, int response);
 static void command_shoutcast_metadata(client_t *client, source_t *source);
 static void command_show_listeners(client_t *client, source_t *source,
         int response);
@@ -177,6 +189,8 @@
         int response);
 static void command_kill_source(client_t *client, source_t *source,
         int response);
+static void command_updatemetadata(client_t *client, source_t *source,
+        int response);
 static void admin_handle_mount_request(client_t *client, source_t *source,
         int command);
 static void admin_handle_general_request(client_t *client, int command);
@@ -446,9 +460,12 @@
         case COMMAND_RAW_FALLBACK:
             command_fallback(client, source, RAW);
             break;
-        case COMMAND_METADATA_UPDATE:
-            command_metadata(client, source);
+        case COMMAND_RAW_METADATA_UPDATE:
+            command_metadata(client, source, RAW);
             break;
+        case COMMAND_TRANSFORMED_METADATA_UPDATE:
+            command_metadata(client, source, TRANSFORMED);
+            break;
         case COMMAND_SHOUTCAST_METADATA_UPDATE:
             command_shoutcast_metadata(client, source);
             break;
@@ -485,6 +502,12 @@
         case COMMAND_RAW_MANAGEAUTH:
             command_manageauth(client, source, RAW);
             break;
+        case COMMAND_TRANSFORMED_UPDATEMETADATA:
+            command_updatemetadata(client, source, TRANSFORMED);
+            break;
+        case COMMAND_RAW_UPDATEMETADATA:
+            command_updatemetadata(client, source, RAW);
+            break;
         case COMMAND_BUILDM3U:
             command_buildm3u(client, source, RAW);
             break;
@@ -822,12 +845,20 @@
     html_success(client, "Fallback configured");
 }
 
-static void command_metadata(client_t *client, source_t *source)
+static void command_metadata(client_t *client, source_t *source,
+    int response)
 {
     char *action;
     char *song, *title, *artist;
     format_plugin_t *plugin;
+    xmlDocPtr doc;
+    xmlNodePtr node;
+    int ok = 1;
 
+    doc = xmlNewDoc("1.0");
+    node = xmlNewDocNode(doc, NULL, "iceresponse", NULL);
+    xmlDocSetRootElement(doc, node);
+
     DEBUG0("Got metadata update request");
 
     COMMAND_REQUIRE(client, "mode", action);
@@ -837,7 +868,12 @@
 
     if (strcmp (action, "updinfo") != 0)
     {
-        client_send_400 (client, "No such action");
+        xmlNewChild(node, NULL, "message", "No such action");
+        xmlNewChild(node, NULL, "return", "0");
+        admin_send_response(doc, client, response, 
+            ADMIN_XSL_RESPONSE);
+        xmlFreeDoc(doc);
+        client_destroy(client);
         return;
     }
 
@@ -860,13 +896,25 @@
                         source->mount, artist, title);
             }
         }
-
-        html_success(client, "Metadata update successful");
     }
     else
     {
-        client_send_400 (client, "mountpoint will not accept URL updates");
+        xmlNewChild(node, NULL, "message", 
+            "Mountpoint will not accept URL updates");
+        xmlNewChild(node, NULL, "return", "1");
+        admin_send_response(doc, client, response, 
+            ADMIN_XSL_RESPONSE);
+        xmlFreeDoc(doc);
+        client_destroy(client);
+        return;
     }
+
+    xmlNewChild(node, NULL, "message", "Metadata update successful");
+    xmlNewChild(node, NULL, "return", "1");
+    admin_send_response(doc, client, response, 
+        ADMIN_XSL_RESPONSE);
+    xmlFreeDoc(doc);
+    client_destroy(client);
 }
 
 static void command_shoutcast_metadata(client_t *client, source_t *source)
@@ -960,3 +1008,20 @@
     return;
 }
 
+static void command_updatemetadata(client_t *client, source_t *source,
+    int response)
+{
+    xmlDocPtr doc;
+    xmlNodePtr node, srcnode;
+
+    doc = xmlNewDoc("1.0");
+    node = xmlNewDocNode(doc, NULL, "icestats", NULL);
+    srcnode = xmlNewChild(node, NULL, "source", NULL);
+    xmlSetProp(srcnode, "mount", source->mount);
+    xmlDocSetRootElement(doc, node);
+
+    admin_send_response(doc, client, response, 
+        UPDATEMETADATA_TRANSFORMED_REQUEST);
+    xmlFreeDoc(doc);
+    client_destroy(client);
+}

Modified: icecast/trunk/icecast/src/cfgfile.c
===================================================================
--- icecast/trunk/icecast/src/cfgfile.c	2004-12-07 21:50:23 UTC (rev 8344)
+++ icecast/trunk/icecast/src/cfgfile.c	2004-12-07 22:29:46 UTC (rev 8345)
@@ -188,6 +188,9 @@
         xmlFree(mount->password);
         xmlFree(mount->dumpfile);
         xmlFree(mount->fallback_mount);
+        if (mount->cluster_password) {
+            xmlFree(mount->cluster_password);
+        }
 
         xmlFree(mount->auth_type);
         option = mount->auth_options;
@@ -610,6 +613,10 @@
             tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
             mount->burst_size = atoi(tmp);
             if (tmp) xmlFree(tmp);
+        } else if (strcmp(node->name, "cluster-password") == 0) {
+            tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+            mount->cluster_password = (char *)xmlNodeListGetString(
+                    doc, node->xmlChildrenNode, 1);
         }
     } while ((node = node->next));
 }

Modified: icecast/trunk/icecast/src/cfgfile.h
===================================================================
--- icecast/trunk/icecast/src/cfgfile.h	2004-12-07 21:50:23 UTC (rev 8344)
+++ icecast/trunk/icecast/src/cfgfile.h	2004-12-07 22:29:46 UTC (rev 8345)
@@ -62,6 +62,7 @@
     unsigned int source_timeout;  /* source timeout in seconds */
 
     char *auth_type; /* Authentication type */
+    char *cluster_password;
     config_options_t *auth_options; /* Options for this type */
     struct _mount_proxy *next;
 } mount_proxy;

Modified: icecast/trunk/icecast/src/yp.c
===================================================================
--- icecast/trunk/icecast/src/yp.c	2004-12-07 21:50:23 UTC (rev 8344)
+++ icecast/trunk/icecast/src/yp.c	2004-12-07 22:29:46 UTC (rev 8345)
@@ -458,6 +458,7 @@
         unsigned len = 512;
         int ret;
         char *url;
+        mount_proxy *mountproxy = NULL;
         ice_config_t *config;
 
         if (yp == NULL)
@@ -486,6 +487,18 @@
             if (s) url = s;
             snprintf (url, ret, "http://%s:%d%s", config->hostname, config->port, source->mount);
         }
+
+        mountproxy = config->mounts;
+        while (mountproxy) {
+            if (strcmp (mountproxy->mountname, source->mount) == 0) {
+                if (mountproxy->cluster_password) {
+                   add_yp_info (yp, "cluster_password", 
+                       mountproxy->cluster_password, YP_CLUSTER_PASSWORD);
+                }
+                break;
+            }
+            mountproxy = mountproxy->next;
+        }
         config_release_config();
         yp->listen_url = util_url_escape (url);
         free (url);
@@ -813,6 +826,15 @@
                 stats_event (yp->mount, "yp_currently_playing", (char *)info);
             }
             break;
+        case YP_CLUSTER_PASSWORD:
+            escaped = util_url_escape(info);
+            if (escaped)
+            {
+                if (yp->cluster_password)
+                    free (yp->cluster_password);
+                yp->cluster_password = escaped;
+            }
+            break;
     }
 }
 

Modified: icecast/trunk/icecast/src/yp.h
===================================================================
--- icecast/trunk/icecast/src/yp.h	2004-12-07 21:50:23 UTC (rev 8344)
+++ icecast/trunk/icecast/src/yp.h	2004-12-07 22:29:46 UTC (rev 8345)
@@ -22,6 +22,7 @@
 #define  YP_AUDIO_INFO 6
 #define  YP_SERVER_TYPE 7
 #define  YP_CURRENT_SONG 8
+#define  YP_CLUSTER_PASSWORD 9
 
 struct source_tag;
 



More information about the commits mailing list