[xiph-cvs] cvs commit: icecast/src admin.c

Michael Smith msmith at xiph.org
Sun Mar 9 06:12:24 PST 2003



msmith      03/03/09 09:12:24

  Modified:    src      admin.c
  Log:
  Listing of current mountpoints in admin interface.

Revision  Changes    Path
1.3       +62 -14    icecast/src/admin.c

Index: admin.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/admin.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- admin.c	7 Mar 2003 14:57:36 -0000	1.2
+++ admin.c	9 Mar 2003 14:12:24 -0000	1.3
@@ -19,24 +19,31 @@
 
 #define CATMODULE "admin"
 
-#define COMMAND_ERROR           (-1)
-#define COMMAND_FALLBACK          1
-#define COMMAND_RAW_STATS         2
-#define COMMAND_METADATA_UPDATE   3
-#define COMMAND_SHOW_LISTENERS    4
+#define COMMAND_ERROR             (-1)
+
+/* Mount-specific commands */
+#define COMMAND_FALLBACK            1
+#define COMMAND_METADATA_UPDATE     2
+#define COMMAND_SHOW_LISTENERS      3
+
+/* Global commands */
+#define COMMAND_LIST_MOUNTS       101
+#define COMMAND_RAW_STATS         102
 
 int admin_get_command(char *command)
 {
     if(!strcmp(command, "fallbacks"))
         return COMMAND_FALLBACK;
-    else if(!strcmp(command, "rawstats"))
-        return COMMAND_RAW_STATS;
-    else if(!strcmp(command, "stats.xml")) /* The old way */
-        return COMMAND_RAW_STATS;
     else if(!strcmp(command, "metadata"))
         return COMMAND_METADATA_UPDATE;
     else if(!strcmp(command, "listclients"))
         return COMMAND_SHOW_LISTENERS;
+    else if(!strcmp(command, "rawstats"))
+        return COMMAND_RAW_STATS;
+    else if(!strcmp(command, "stats.xml")) /* The old way */
+        return COMMAND_RAW_STATS;
+    else if(!strcmp(command, "listmounts"))
+        return COMMAND_LIST_MOUNTS;
     else
         return COMMAND_ERROR;
 }
@@ -46,6 +53,7 @@
 static void command_show_listeners(client_t *client, source_t *source);
 
 static void command_raw_stats(client_t *client);
+static void command_list_mounts(client_t *client);
 
 static void admin_handle_mount_request(client_t *client, source_t *source,
         int command);
@@ -79,11 +87,13 @@
         source_t *source;
 
         /* This is a mount request, handle it as such */
-        if(!connection_check_source_pass(client->parser, mount)) {
-		    INFO1("Bad or missing password on mount modification admin "
-                  "request (command: %s)", command_string);
-            client_send_401(client);
-            return;
+        if(!connection_check_admin_pass(client->parser)) {
+            if(!connection_check_source_pass(client->parser, mount)) {
+	    	    INFO1("Bad or missing password on mount modification admin "
+                      "request (command: %s)", command_string);
+                client_send_401(client);
+                return;
+            }
         }
         
         avl_tree_rlock(global.source_tree);
@@ -121,6 +131,9 @@
         case COMMAND_RAW_STATS:
             command_raw_stats(client);
             break;
+        case COMMAND_LIST_MOUNTS:
+            command_list_mounts(client);
+            break;
         default:
             WARN0("General admin request not recognised");
             client_send_400(client, "Unknown admin request");
@@ -283,6 +296,41 @@
     DEBUG0("Stats request, sending xml stats");
 
     stats_sendxml(client);
+    client_destroy(client);
+    return;
+}
+
+static void command_list_mounts(client_t *client) {
+    avl_node *node;
+    source_t *source;
+
+    DEBUG0("List mounts request");
+
+    html_head(client);
+
+    html_write(client, 
+            "<table><tr><td>Mountpoint</td><td>Fallback</td>"
+            "<td>Format</td><td>Listeners</td></tr>");
+
+    avl_tree_rlock(global.source_tree);
+
+    node = avl_get_first(global.source_tree);
+    while(node) {
+        source = (source_t *)node->key;
+
+        html_write(client, 
+                "<tr><td>%s</td><td>%s</td><td>%s</td><td>%ld</td></tr>",
+                source->mount, (source->fallback_mount != NULL)?
+                source->fallback_mount:"", source->format->format_description,
+                source->listeners);
+
+        node = avl_get_next(node);
+    }
+
+    avl_tree_unlock(global.source_tree);
+
+    html_write(client, "</table></body></html>");
+
     client_destroy(client);
     return;
 }

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list