[xiph-commits] r18798 - icecast/trunk/icecast/src

ph3-der-loewe at svn.xiph.org ph3-der-loewe at svn.xiph.org
Sat Feb 23 09:51:16 PST 2013


Author: ph3-der-loewe
Date: 2013-02-23 09:51:16 -0800 (Sat, 23 Feb 2013)
New Revision: 18798

Modified:
   icecast/trunk/icecast/src/auth_url.c
Log:
Updated listener_remove handler:
 * added ip= and agent=,
 * Some cleanup && made code more uniform,
 * avoid int for size_t vars.
actions: close #1422


Modified: icecast/trunk/icecast/src/auth_url.c
===================================================================
--- icecast/trunk/icecast/src/auth_url.c	2013-02-23 17:05:54 UTC (rev 18797)
+++ icecast/trunk/icecast/src/auth_url.c	2013-02-23 17:51:16 UTC (rev 18798)
@@ -189,14 +189,23 @@
     ice_config_t *config;
     int port;
     char *userpwd = NULL, post [4096];
+    const char *agent;
+    char *user_agent, *ipaddr;
 
     if (url->removeurl == NULL)
         return AUTH_OK;
+
     config = config_get_config ();
     server = util_url_escape (config->hostname);
     port = config->port;
     config_release_config ();
 
+    agent = httpp_getvar (client->parser, "user-agent");
+    if (agent)
+        user_agent = util_url_escape (agent);
+    else
+        user_agent = strdup ("-");
+
     if (client->username)
         username = util_url_escape (client->username);
     else
@@ -212,16 +221,19 @@
     if (mountreq == NULL)
         mountreq = httpp_getvar (client->parser, HTTPP_VAR_URI);
     mount = util_url_escape (mountreq);
+    ipaddr = util_url_escape (client->con->ip);
 
     snprintf (post, sizeof (post),
             "action=listener_remove&server=%s&port=%d&client=%lu&mount=%s"
-            "&user=%s&pass=%s&duration=%lu",
+            "&user=%s&pass=%s&duration=%lu&ip=%s&agent=%s",
             server, port, client->con->id, mount, username,
-            password, (long unsigned)duration);
+            password, (long unsigned)duration, ipaddr, user_agent);
     free (server);
     free (mount);
     free (username);
     free (password);
+    free (ipaddr);
+    free (user_agent);
 
     if (strchr (url->removeurl, '@') == NULL)
     {
@@ -232,7 +244,7 @@
             /* auth'd requests may not have a user/pass, but may use query args */
             if (client->username && client->password)
             {
-                int len = strlen (client->username) + strlen (client->password) + 2;
+                size_t len = strlen (client->username) + strlen (client->password) + 2;
                 userpwd = malloc (len);
                 snprintf (userpwd, len, "%s:%s", client->username, client->password);
                 curl_easy_setopt (url->handle, CURLOPT_USERPWD, userpwd);
@@ -283,16 +295,20 @@
     server = util_url_escape (config->hostname);
     port = config->port;
     config_release_config ();
+
     agent = httpp_getvar (client->parser, "user-agent");
-    if (agent == NULL)
-        agent = "-";
-    user_agent = util_url_escape (agent);
+    if (agent)
+        user_agent = util_url_escape (agent);
+    else
+        user_agent = strdup ("-");
+
     if (client->username)
-        username  = util_url_escape (client->username);
+        username = util_url_escape (client->username);
     else
         username = strdup ("");
+
     if (client->password)
-        password  = util_url_escape (client->password);
+        password = util_url_escape (client->password);
     else
         password = strdup ("");
 
@@ -353,7 +369,7 @@
             /* auth'd requests may not have a user/pass, but may use query args */
             if (client->username && client->password)
             {
-                int len = strlen (client->username) + strlen (client->password) + 2;
+                size_t len = strlen (client->username) + strlen (client->password) + 2;
                 userpwd = malloc (len);
                 snprintf (userpwd, len, "%s:%s", client->username, client->password);
                 curl_easy_setopt (url->handle, CURLOPT_USERPWD, userpwd);



More information about the commits mailing list