[xiph-commits] r18800 - icecast/branches/ph3/icecast/src

ph3-der-loewe at svn.xiph.org ph3-der-loewe at svn.xiph.org
Sat Feb 23 15:25:52 PST 2013


Author: ph3-der-loewe
Date: 2013-02-23 15:25:52 -0800 (Sat, 23 Feb 2013)
New Revision: 18800

Modified:
   icecast/branches/ph3/icecast/src/auth_url.c
   icecast/branches/ph3/icecast/src/cfgfile.c
   icecast/branches/ph3/icecast/src/cfgfile.h
   icecast/branches/ph3/icecast/src/slave.c
Log:
sync with master

Modified: icecast/branches/ph3/icecast/src/auth_url.c
===================================================================
--- icecast/branches/ph3/icecast/src/auth_url.c	2013-02-23 20:55:58 UTC (rev 18799)
+++ icecast/branches/ph3/icecast/src/auth_url.c	2013-02-23 23:25:52 UTC (rev 18800)
@@ -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);

Modified: icecast/branches/ph3/icecast/src/cfgfile.c
===================================================================
--- icecast/branches/ph3/icecast/src/cfgfile.c	2013-02-23 20:55:58 UTC (rev 18799)
+++ icecast/branches/ph3/icecast/src/cfgfile.c	2013-02-23 23:25:52 UTC (rev 18800)
@@ -313,13 +313,11 @@
     node = xmlDocGetRootElement(doc);
     if (node == NULL) {
         xmlFreeDoc(doc);
-        xmlCleanupParser();
         return CONFIG_ENOROOT;
     }
 
     if (xmlStrcmp (node->name, XMLSTR("icecast")) != 0) {
         xmlFreeDoc(doc);
-        xmlCleanupParser();
         return CONFIG_EBADROOT;
     }
 

Modified: icecast/branches/ph3/icecast/src/cfgfile.h
===================================================================
--- icecast/branches/ph3/icecast/src/cfgfile.h	2013-02-23 20:55:58 UTC (rev 18799)
+++ icecast/branches/ph3/icecast/src/cfgfile.h	2013-02-23 23:25:52 UTC (rev 18800)
@@ -98,7 +98,7 @@
     int port;
     char *bind_address;
     struct _aliases *next;
-}aliases;
+} aliases;
 
 typedef struct _listener_t {
     struct _listener_t *next;

Modified: icecast/branches/ph3/icecast/src/slave.c
===================================================================
--- icecast/branches/ph3/icecast/src/slave.c	2013-02-23 20:55:58 UTC (rev 18799)
+++ icecast/branches/ph3/icecast/src/slave.c	2013-02-23 23:25:52 UTC (rev 18800)
@@ -39,6 +39,7 @@
 
 #include "compat.h"
 
+#include <libxml/uri.h>
 #include "thread/thread.h"
 #include "avl/avl.h"
 #include "net/sock.h"
@@ -666,18 +667,37 @@
             if (!strlen(buf))
                 continue;
             DEBUG2 ("read %d from master \"%s\"", count++, buf);
+            xmlURIPtr parsed_uri = xmlParseURI(buf);
+            if (parsed_uri == NULL) {
+                DEBUG0("Error while parsing line from master. Ignoring line.");
+                continue;
+            }
             r = calloc (1, sizeof (relay_server));
             if (r)
             {
-                r->server = (char *)xmlCharStrdup (master);
-                r->port = port;
-                r->mount = (char *)xmlCharStrdup (buf);
-                r->localmount = (char *)xmlCharStrdup (buf);
+                if (parsed_uri->server != NULL)
+                {
+                  r->server = strdup(parsed_uri->server);
+                  if (parsed_uri->port == 0)
+                    r->port = 80;
+                  else
+                    r->port = parsed_uri->port;
+                }
+                else
+                {
+                  r->server = (char *)xmlCharStrdup (master);
+                  r->port = port;
+                }
+
+                r->mount = strdup(parsed_uri->path);
+                r->localmount = strdup(parsed_uri->path);
                 r->mp3metadata = 1;
                 r->on_demand = on_demand;
                 r->next = new_relays;
+                DEBUG3 ("Added relay host=\"%s\", port=%d, mount=\"%s\"", r->server, r->port, r->mount);
                 new_relays = r;
             }
+            xmlFreeURI(parsed_uri);
         }
         sock_close (mastersock);
 



More information about the commits mailing list