[xiph-commits] r9318 - in icecast/branches/kh/icecast: admin src

karl at motherfish-iii.xiph.org karl at motherfish-iii.xiph.org
Fri May 27 10:34:53 PDT 2005


Author: karl
Date: 2005-05-27 10:34:46 -0700 (Fri, 27 May 2005)
New Revision: 9318

Added:
   icecast/branches/kh/icecast/admin/managerelays.xsl
Modified:
   icecast/branches/kh/icecast/admin/Makefile.am
   icecast/branches/kh/icecast/admin/listclients.xsl
   icecast/branches/kh/icecast/admin/listmounts.xsl
   icecast/branches/kh/icecast/admin/manageauth.xsl
   icecast/branches/kh/icecast/admin/response.xsl
   icecast/branches/kh/icecast/admin/stats.xsl
   icecast/branches/kh/icecast/admin/updatemetadata.xsl
   icecast/branches/kh/icecast/src/admin.c
Log:
rename the relay admin handler now that the admin pages are updated


Modified: icecast/branches/kh/icecast/admin/Makefile.am
===================================================================
--- icecast/branches/kh/icecast/admin/Makefile.am	2005-05-27 12:56:07 UTC (rev 9317)
+++ icecast/branches/kh/icecast/admin/Makefile.am	2005-05-27 17:34:46 UTC (rev 9318)
@@ -4,5 +4,5 @@
 
 admindir = $(pkgdatadir)/admin
 dist_admin_DATA = listclients.xsl listmounts.xsl moveclients.xsl response.xsl \
-	stats.xsl manageauth.xsl updatemetadata.xsl
+	stats.xsl manageauth.xsl updatemetadata.xsl managerelays.xsl
 

Modified: icecast/branches/kh/icecast/admin/listclients.xsl
===================================================================
--- icecast/branches/kh/icecast/admin/listclients.xsl	2005-05-27 12:56:07 UTC (rev 9317)
+++ icecast/branches/kh/icecast/admin/listclients.xsl	2005-05-27 17:34:46 UTC (rev 9318)
@@ -13,6 +13,7 @@
 	    <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="managerelays.xsl">Manage Relays</a> |
         	<a class="nav" href="stats.xsl">Stats</a> | 
         	<a class="nav" href="/status.xsl">Status Page</a>
 	    </td></tr>

Modified: icecast/branches/kh/icecast/admin/listmounts.xsl
===================================================================
--- icecast/branches/kh/icecast/admin/listmounts.xsl	2005-05-27 12:56:07 UTC (rev 9317)
+++ icecast/branches/kh/icecast/admin/listmounts.xsl	2005-05-27 17:34:46 UTC (rev 9318)
@@ -13,6 +13,7 @@
 	    <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="managerelays.xsl">Manage Relays</a> |
         	<a class="nav" href="stats.xsl">Stats</a> | 
         	<a class="nav" href="/status.xsl">Status Page</a>
 	    </td></tr>

Modified: icecast/branches/kh/icecast/admin/manageauth.xsl
===================================================================
--- icecast/branches/kh/icecast/admin/manageauth.xsl	2005-05-27 12:56:07 UTC (rev 9317)
+++ icecast/branches/kh/icecast/admin/manageauth.xsl	2005-05-27 17:34:46 UTC (rev 9318)
@@ -13,6 +13,7 @@
 	    <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="managerelays.xsl">Manage Relays</a> |
         	<a class="nav" href="stats.xsl">Stats</a> | 
         	<a class="nav" href="/status.xsl">Status Page</a>
 	    </td></tr>

Added: icecast/branches/kh/icecast/admin/managerelays.xsl
===================================================================
--- icecast/branches/kh/icecast/admin/managerelays.xsl	2005-05-27 12:56:07 UTC (rev 9317)
+++ icecast/branches/kh/icecast/admin/managerelays.xsl	2005-05-27 17:34:46 UTC (rev 9318)
@@ -0,0 +1,60 @@
+<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 = "/icerelaystats" >
+<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="managerelays.xsl">Manage Relays</a> |
+      <a class="nav" href="stats.xsl">Stats</a> | 
+      <a class="nav" href="/status.xsl">Status Page</a>
+    </td></tr>
+  </table>
+</center>
+<h2>Manage relays</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="relay">
+<h3>
+<xsl:value-of select="localmount" />
+<xsl:choose>
+<xsl:when test = "enable!='0'">
+    (<a href="managerelays.xsl?relay={localmount}&amp;enable=0">click to disable</a>)
+</xsl:when>
+<xsl:otherwise>
+    (<a href="managerelays.xsl?relay={localmount}&amp;enable=1">click to enable</a>)
+</xsl:otherwise>
+</xsl:choose>
+</h3>
+<table border="0" cellpadding="4">
+    <tr> <td>server</td> <td class="streamdata"> <xsl:value-of select="server" /></td> </tr>
+    <tr> <td>port</td> <td class="streamdata"> <xsl:value-of select="port" /></td> </tr>
+    <tr> <td>mountpoint</td> <td class="streamdata"> <xsl:value-of select="mount" /></td> </tr>
+    <tr> <td>on demand</td> <td class="streamdata"> <xsl:value-of select="on_demand" /></td> </tr>
+</table>
+<br />
+<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/branches/kh/icecast/admin/response.xsl
===================================================================
--- icecast/branches/kh/icecast/admin/response.xsl	2005-05-27 12:56:07 UTC (rev 9317)
+++ icecast/branches/kh/icecast/admin/response.xsl	2005-05-27 17:34:46 UTC (rev 9318)
@@ -13,6 +13,7 @@
 	    <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="managerelays.xsl">Manage Relays</a> | 
         	<a class="nav" href="stats.xsl">Stats</a> | 
         	<a class="nav" href="/status.xsl">Status Page</a>
 	    </td></tr>

Modified: icecast/branches/kh/icecast/admin/stats.xsl
===================================================================
--- icecast/branches/kh/icecast/admin/stats.xsl	2005-05-27 12:56:07 UTC (rev 9317)
+++ icecast/branches/kh/icecast/admin/stats.xsl	2005-05-27 17:34:46 UTC (rev 9318)
@@ -13,6 +13,7 @@
 	    <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="managerelays.xsl">Manage Relays</a> |
         	<a class="nav" href="stats.xsl">Stats</a> | 
         	<a class="nav" href="/status.xsl">Status Page</a>
 	    </td></tr>

Modified: icecast/branches/kh/icecast/admin/updatemetadata.xsl
===================================================================
--- icecast/branches/kh/icecast/admin/updatemetadata.xsl	2005-05-27 12:56:07 UTC (rev 9317)
+++ icecast/branches/kh/icecast/admin/updatemetadata.xsl	2005-05-27 17:34:46 UTC (rev 9318)
@@ -13,6 +13,7 @@
 	    <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="managerelays.xsl">Manage Relays</a> |
         	<a class="nav" href="stats.xsl">Stats</a> | 
         	<a class="nav" href="/status.xsl">Status Page</a>
 	    </td></tr>

Modified: icecast/branches/kh/icecast/src/admin.c
===================================================================
--- icecast/branches/kh/icecast/src/admin.c	2005-05-27 12:56:07 UTC (rev 9317)
+++ icecast/branches/kh/icecast/src/admin.c	2005-05-27 17:34:46 UTC (rev 9318)
@@ -67,12 +67,12 @@
 #define COMMAND_RAW_LISTSTREAM              103
 #define COMMAND_PLAINTEXT_LISTSTREAM        104
 #define COMMAND_RAW_ADMIN_FUNCTION          105
-#define COMMAND_RAW_UPDATE_RELAY            106
+#define COMMAND_RAW_MANAGE_RELAY            106
 #define COMMAND_TRANSFORMED_LIST_MOUNTS     201
 #define COMMAND_TRANSFORMED_STATS           202
 #define COMMAND_TRANSFORMED_LISTSTREAM      203
 #define COMMAND_TRANSFORMED_ADMIN_FUNCTION  204
-#define COMMAND_TRANSFORMED_UPDATE_RELAY    205
+#define COMMAND_TRANSFORMED_MANAGE_RELAY    205
 
 /* Client management commands */
 #define COMMAND_RAW_KILL_CLIENT             301
@@ -108,8 +108,8 @@
 #define MANAGEAUTH_TRANSFORMED_REQUEST "manageauth.xsl"
 #define UPDATEMETADATA_RAW_REQUEST "updatemetadata"
 #define UPDATEMETADATA_TRANSFORMED_REQUEST "updatemetadata.xsl"
-#define UPDATE_RELAY_RAW_REQUEST "updaterelay"
-#define UPDATE_RELAY_TRANSFORMED_REQUEST "updaterelay.xsl"
+#define MANAGE_RELAY_RAW_REQUEST "managerelays"
+#define MANAGE_RELAY_TRANSFORMED_REQUEST "managerelays.xsl"
 #define ADM_FUNCTION_RAW_REQUEST "function"
 #define ADM_FUNCTION_TRANSFORMED_REQUEST "function.xsl"
 #define DEFAULT_RAW_REQUEST ""
@@ -172,10 +172,10 @@
         return COMMAND_TRANSFORMED_UPDATEMETADATA;
     else if(!strcmp(command, BUILDM3U_RAW_REQUEST))
         return COMMAND_BUILDM3U;
-    else if(!strcmp(command, UPDATE_RELAY_RAW_REQUEST))
-        return COMMAND_RAW_UPDATE_RELAY;
-    else if(!strcmp(command, UPDATE_RELAY_TRANSFORMED_REQUEST))
-        return COMMAND_TRANSFORMED_UPDATE_RELAY;
+    else if(!strcmp(command, MANAGE_RELAY_RAW_REQUEST))
+        return COMMAND_RAW_MANAGE_RELAY;
+    else if(!strcmp(command, MANAGE_RELAY_TRANSFORMED_REQUEST))
+        return COMMAND_TRANSFORMED_MANAGE_RELAY;
     else if(!strcmp(command, ADM_FUNCTION_RAW_REQUEST))
         return COMMAND_RAW_ADMIN_FUNCTION;
     else if(!strcmp(command, ADM_FUNCTION_TRANSFORMED_REQUEST))
@@ -208,7 +208,7 @@
 static void command_updatemetadata(client_t *client, source_t *source,
         int response);
 static void command_admin_function (client_t *client, int response);
-static void command_update_relay (client_t *client, int response);
+static void command_manage_relay (client_t *client, int response);
 
 static void admin_handle_mount_request(client_t *client, source_t *source,
         int command);
@@ -297,7 +297,8 @@
 
     client->respcode = 200;
     if (response == RAW) {
-        xmlDocDumpMemory(doc, &buff, &len);
+        // xmlDocDumpMemory(doc, &buff, &len);
+        xmlDocDumpFormatMemoryEnc (doc, &buff, &len, NULL, 1);
         html_write(client, "HTTP/1.0 200 OK\r\n"
                "Content-Length: %d\r\n"
                "Content-Type: text/xml\r\n"
@@ -465,8 +466,8 @@
         case COMMAND_RAW_LISTSTREAM:
             command_list_mounts(client, RAW);
             break;
-        case COMMAND_RAW_UPDATE_RELAY:
-            command_update_relay (client, RAW);
+        case COMMAND_RAW_MANAGE_RELAY:
+            command_manage_relay (client, RAW);
             break;
         case COMMAND_RAW_ADMIN_FUNCTION:
             command_admin_function(client, RAW);
@@ -486,8 +487,8 @@
         case COMMAND_TRANSFORMED_MOVE_CLIENTS:
             command_list_mounts(client, TRANSFORMED);
             break;
-        case COMMAND_TRANSFORMED_UPDATE_RELAY:
-            command_update_relay (client, TRANSFORMED);
+        case COMMAND_TRANSFORMED_MANAGE_RELAY:
+            command_manage_relay (client, TRANSFORMED);
             break;
         case COMMAND_TRANSFORMED_ADMIN_FUNCTION:
             command_admin_function(client, TRANSFORMED);
@@ -709,19 +710,53 @@
 }
 
 
-static void command_update_relay (client_t *client, int response)
+static void add_relay_xmlnode (xmlNodePtr node, relay_server *relay, int master)
 {
+    xmlNodePtr relaynode = xmlNewChild (node, NULL, "relay", NULL);
+    char str [20];
+    xmlNewChild (relaynode, NULL, "server", relay->server);
+    xmlNewChild (relaynode, NULL, "mount", relay->mount);
+    snprintf (str, sizeof (str), "%d", relay->port);
+    xmlNewChild (relaynode, NULL, "port", str);
+    xmlNewChild (relaynode, NULL, "localmount", relay->localmount);
+    snprintf (str, sizeof (str), "%d", relay->enable);
+    xmlNewChild (relaynode, NULL, "enable", str);
+    snprintf (str, sizeof (str), "%d", relay->on_demand);
+    xmlNewChild (relaynode, NULL, "on_demand", str);
+    snprintf (str, sizeof (str), "%d", master);
+    xmlNewChild (relaynode, NULL, "master", str);
+}
+
+
+static void command_manage_relay (client_t *client, int response)
+{
     char *relay_mount, *enable;
     const char *msg;
     relay_server *relay;
     xmlDocPtr doc;
     xmlNodePtr node;
 
-    COMMAND_REQUIRE (client, "relay", relay_mount);
-    COMMAND_REQUIRE (client, "enable", enable);
+    COMMAND_OPTIONAL (client, "relay", relay_mount);
+    COMMAND_OPTIONAL (client, "enable", enable);
 
-    if (relay_mount == NULL)
+    if (relay_mount == NULL || enable == NULL)
+    {
+        doc = xmlNewDoc ("1.0");
+        node = xmlNewDocNode (doc, NULL, "icerelaystats", NULL);
+        xmlDocSetRootElement(doc, node);
+        thread_mutex_lock (&(config_locks()->relay_lock));
+
+        for (relay = global.relays; relay; relay=relay->next)
+            add_relay_xmlnode (node, relay, 0);
+        for (relay = global.master_relays; relay; relay=relay->next)
+            add_relay_xmlnode (node, relay, 1);
+
+        thread_mutex_unlock (&(config_locks()->relay_lock));
+        admin_send_response (doc, client, response, MANAGE_RELAY_TRANSFORMED_REQUEST);
+        xmlFreeDoc (doc);
+        client_destroy (client);
         return;
+    }
 
     thread_mutex_lock (&(config_locks()->relay_lock));
 



More information about the commits mailing list