[xiph-commits] r10023 - icecast/branches/kh/icecast/src

karl at svn.xiph.org karl at svn.xiph.org
Fri Sep 16 15:13:57 PDT 2005


Author: karl
Date: 2005-09-16 15:13:49 -0700 (Fri, 16 Sep 2005)
New Revision: 10023

Modified:
   icecast/branches/kh/icecast/src/admin.c
   icecast/branches/kh/icecast/src/auth.c
   icecast/branches/kh/icecast/src/connection.c
   icecast/branches/kh/icecast/src/connection.h
   icecast/branches/kh/icecast/src/format.c
   icecast/branches/kh/icecast/src/format.h
   icecast/branches/kh/icecast/src/format_mp3.c
   icecast/branches/kh/icecast/src/format_mp3.h
   icecast/branches/kh/icecast/src/fserve.c
   icecast/branches/kh/icecast/src/logging.c
   icecast/branches/kh/icecast/src/slave.c
   icecast/branches/kh/icecast/src/source.c
   icecast/branches/kh/icecast/src/source.h
Log:
revert parser change, applied changes from rc feedback


Modified: icecast/branches/kh/icecast/src/admin.c
===================================================================
--- icecast/branches/kh/icecast/src/admin.c	2005-09-16 22:04:44 UTC (rev 10022)
+++ icecast/branches/kh/icecast/src/admin.c	2005-09-16 22:13:49 UTC (rev 10023)
@@ -272,7 +272,7 @@
 
             if (source->running)
             {
-                if (source->client->con)
+                if (source->client)
                 {
                     snprintf (buf, sizeof(buf), "%lu",
                             (unsigned long)(now - source->client->con->con_time));

Modified: icecast/branches/kh/icecast/src/auth.c
===================================================================
--- icecast/branches/kh/icecast/src/auth.c	2005-09-16 22:04:44 UTC (rev 10022)
+++ icecast/branches/kh/icecast/src/auth.c	2005-09-16 22:13:49 UTC (rev 10023)
@@ -280,17 +280,18 @@
         return -1;
 
     } while (1);
+
+    client->write_to_client = format_generic_write_to_client;
+    client->check_buffer = format_check_http_buffer;
+    client->refbuf->len = PER_CLIENT_REFBUF_SIZE;
+    memset (client->refbuf->data, 0, PER_CLIENT_REFBUF_SIZE);
+
     /* lets add the client to the active list */
     client->next = source->active_clients;
     source->active_clients = client;
     source->listeners++;
     stats_event_inc (NULL, "listener_connections");
 
-    client->write_to_client = format_generic_write_to_client;
-    client->check_buffer = format_check_http_buffer;
-    client->refbuf->len = PER_CLIENT_REFBUF_SIZE;
-    memset (client->refbuf->data, 0, PER_CLIENT_REFBUF_SIZE);
-
     thread_mutex_unlock (&source->lock);
 
     if (source->running == 0 && source->on_demand)

Modified: icecast/branches/kh/icecast/src/connection.c
===================================================================
--- icecast/branches/kh/icecast/src/connection.c	2005-09-16 22:04:44 UTC (rev 10022)
+++ icecast/branches/kh/icecast/src/connection.c	2005-09-16 22:13:49 UTC (rev 10023)
@@ -613,7 +613,7 @@
 /* Called when activating a source. Verifies that the source count is not
  * exceeded and applies any initial parameters.
  */
-int connection_complete_source (source_t *source, http_parser_t *in_parser, int response)
+int connection_complete_source (source_t *source, int response)
 {
     ice_config_t *config = config_get_config();
 
@@ -625,13 +625,9 @@
         char *contenttype;
         mount_proxy *mountinfo;
         format_type_t format_type;
-        http_parser_t *parser = in_parser;
 
         /* setup format handler */
-        if (source->client)
-            parser = source->client->parser;
-
-        contenttype = httpp_getvar (parser, "content-type");
+        contenttype = httpp_getvar (source->parser, "content-type");
         if (contenttype != NULL)
         {
             format_type = format_get_type (contenttype);
@@ -656,7 +652,7 @@
             format_type = FORMAT_TYPE_GENERIC;
         }
 
-        if (format_get_plugin (format_type, source, parser) < 0)
+        if (format_get_plugin (format_type, source) < 0)
         {
             global_unlock();
             config_release_config();
@@ -881,7 +877,8 @@
             source->shoutcast_compat = 1;
         }
         source->client = client;
-        if (connection_complete_source (source, NULL, 1) < 0)
+        source->parser = client->parser;
+        if (connection_complete_source (source, 1) < 0)
         {
             source_clear_source (source);
             source_free_source (source);

Modified: icecast/branches/kh/icecast/src/connection.h
===================================================================
--- icecast/branches/kh/icecast/src/connection.h	2005-09-16 22:04:44 UTC (rev 10022)
+++ icecast/branches/kh/icecast/src/connection.h	2005-09-16 22:13:49 UTC (rev 10023)
@@ -55,8 +55,7 @@
 void connection_accept_loop(void);
 void connection_close(connection_t *con);
 connection_t *connection_create (sock_t sock, sock_t serversock, char *ip);
-int connection_complete_source (struct source_tag *source,
-        http_parser_t *parser, int response);
+int connection_complete_source (struct source_tag *source, int response);
 
 int connection_check_source_pass(http_parser_t *parser, const char *mount);
 int connection_check_relay_pass(http_parser_t *parser);

Modified: icecast/branches/kh/icecast/src/format.c
===================================================================
--- icecast/branches/kh/icecast/src/format.c	2005-09-16 22:04:44 UTC (rev 10022)
+++ icecast/branches/kh/icecast/src/format.c	2005-09-16 22:13:49 UTC (rev 10023)
@@ -75,7 +75,7 @@
 }
 
 
-int format_get_plugin (format_type_t type, source_t *source, http_parser_t *parser)
+int format_get_plugin (format_type_t type, source_t *source)
 {
     int ret = -1;
 
@@ -84,7 +84,7 @@
         ret = format_ogg_get_plugin (source);
         break;
     case FORMAT_TYPE_GENERIC:
-        ret = format_mp3_get_plugin (source, parser);
+        ret = format_mp3_get_plugin (source);
         break;
     default:
         break;
@@ -289,8 +289,8 @@
     ptr += bytes;
 
     /* iterate through source http headers and send to client */
-    avl_tree_rlock (source->client->parser->vars);
-    node = avl_get_first (source->client->parser->vars);
+    avl_tree_rlock (source->parser->vars);
+    node = avl_get_first (source->parser->vars);
     while (node)
     {
         int next = 1;
@@ -317,7 +317,7 @@
         else
         {
             if (strcasecmp (var->name, "ice-password") &&
-                strcasecmp (var->name, "icy-metaint"))
+                    strcasecmp (var->name, "icy-metaint"))
             {
                 if (!strncasecmp ("ice-", var->name, 4))
                 {
@@ -344,7 +344,7 @@
         if (next)
             node = avl_get_next (node);
     }
-    avl_tree_unlock (source->client->parser->vars);
+    avl_tree_unlock (source->parser->vars);
 
     bytes = snprintf (ptr, remaining, "Server: %s\r\n", ICECAST_VERSION_STRING);
     remaining -= bytes;

Modified: icecast/branches/kh/icecast/src/format.h
===================================================================
--- icecast/branches/kh/icecast/src/format.h	2005-09-16 22:04:44 UTC (rev 10022)
+++ icecast/branches/kh/icecast/src/format.h	2005-09-16 22:13:49 UTC (rev 10023)
@@ -58,7 +58,7 @@
 } format_plugin_t;
 
 format_type_t format_get_type(char *contenttype);
-int format_get_plugin(format_type_t type, struct source_tag *source, http_parser_t *p);
+int format_get_plugin(format_type_t type, struct source_tag *source);
 
 int format_generic_write_to_client (client_t *client);
 int format_advance_queue (struct source_tag *source, client_t *client);

Modified: icecast/branches/kh/icecast/src/format_mp3.c
===================================================================
--- icecast/branches/kh/icecast/src/format_mp3.c	2005-09-16 22:04:44 UTC (rev 10022)
+++ icecast/branches/kh/icecast/src/format_mp3.c	2005-09-16 22:13:49 UTC (rev 10023)
@@ -73,7 +73,7 @@
    refbuf_t *associated;
 } mp3_client_data;
 
-int format_mp3_get_plugin (source_t *source, http_parser_t *parser)
+int format_mp3_get_plugin (source_t *source)
 {
     char *metadata;
     format_plugin_t *plugin;
@@ -91,7 +91,7 @@
     plugin->set_tag = mp3_set_tag;
     plugin->apply_settings = format_mp3_apply_settings;
 
-    plugin->contenttype = httpp_getvar (parser, "content-type");
+    plugin->contenttype = httpp_getvar (source->parser, "content-type");
     if (plugin->contenttype == NULL) {
         /* We default to MP3 audio for old clients without content types */
         plugin->contenttype = "audio/mpeg";
@@ -106,7 +106,7 @@
     state->metadata = meta;
     state->interval = -1;
 
-    metadata = httpp_getvar (parser, "icy-metaint");
+    metadata = httpp_getvar (source->parser, "icy-metaint");
     if (metadata)
     {
         state->inline_metadata_interval = atoi (metadata);

Modified: icecast/branches/kh/icecast/src/format_mp3.h
===================================================================
--- icecast/branches/kh/icecast/src/format_mp3.h	2005-09-16 22:04:44 UTC (rev 10022)
+++ icecast/branches/kh/icecast/src/format_mp3.h	2005-09-16 22:13:49 UTC (rev 10023)
@@ -37,6 +37,6 @@
     char build_metadata[4081];
 } mp3_state;
 
-int format_mp3_get_plugin(struct source_tag *src, http_parser_t *p);
+int format_mp3_get_plugin(struct source_tag *src);
 
 #endif  /* __FORMAT_MP3_H__ */

Modified: icecast/branches/kh/icecast/src/fserve.c
===================================================================
--- icecast/branches/kh/icecast/src/fserve.c	2005-09-16 22:04:44 UTC (rev 10022)
+++ icecast/branches/kh/icecast/src/fserve.c	2005-09-16 22:13:49 UTC (rev 10023)
@@ -419,9 +419,12 @@
         {
             if (strstr (agent, "QTS") || strstr (agent, "QuickTime"))
                 protocol = "icy";
-            if (strchr (agent, ':') == NULL)
-                host = NULL;
         }
+        /* at least a couple of players (fb2k/winamp) are reported to send a 
+         * host header but without the port number. So if we are missing the
+         * port then lets treat it as if no host line was sent */
+        if (host && strchr (host, ':') == NULL)
+            host = NULL;
 
         *dot = 0;
         httpclient->respcode = 200;

Modified: icecast/branches/kh/icecast/src/logging.c
===================================================================
--- icecast/branches/kh/icecast/src/logging.c	2005-09-16 22:04:44 UTC (rev 10022)
+++ icecast/branches/kh/icecast/src/logging.c	2005-09-16 22:13:49 UTC (rev 10023)
@@ -95,12 +95,11 @@
 }
 #endif
 /* 
-** ADDR USER AUTH DATE REQUEST CODE BYTES REFERER AGENT [TIME]
+** ADDR IDENT USER DATE REQUEST CODE BYTES REFERER AGENT [TIME]
 **
 ** ADDR = client->con->ip
-** USER = -      
-**      we should do this for real once we support authentication
-** AUTH = -
+** IDENT = always - , we don't support it because it's useless
+** USER = client->username
 ** DATE = _make_date(client->con->con_time)
 ** REQUEST = build from client->parser
 ** CODE = client->respcode
@@ -116,7 +115,7 @@
     struct tm thetime;
     time_t now;
     time_t stayed;
-    char *referrer, *user_agent;
+    char *referrer, *user_agent, *username;
 
     now = global.time;
 
@@ -137,6 +136,11 @@
 
     stayed = now - client->con->con_time;
 
+    if (client->username == NULL)
+        username = "-"; 
+    else
+        username = client->username;
+
     referrer = httpp_getvar (client->parser, "referer");
     if (referrer == NULL)
         referrer = "-";
@@ -147,8 +151,9 @@
 
 #ifdef HAVE_LOGGING_IP
     log_write_direct (accesslog,
-            "%s - - [%s] \"%s\" %d " FORMAT_UINT64 " \"%s\" \"%s\" %lu",
+            "%s - %s [%s] \"%s\" %d " FORMAT_UINT64 " \"%s\" \"%s\" %lu",
             client->con->ip,
+            username,
             datebuf, reqbuf, client->respcode, client->con->sent_bytes,
             referrer, user_agent, (unsigned long)stayed);
 #else

Modified: icecast/branches/kh/icecast/src/slave.c
===================================================================
--- icecast/branches/kh/icecast/src/slave.c	2005-09-16 22:04:44 UTC (rev 10022)
+++ icecast/branches/kh/icecast/src/slave.c	2005-09-16 22:13:49 UTC (rev 10023)
@@ -309,6 +309,7 @@
             ERROR1("Error from relay request: %s", httpp_getvar(parser, HTTPP_VAR_ERROR_MESSAGE));
             break;
         }
+        src->parser = parser;
 
         global_lock ();
         if (client_create (&src->client, con, parser) < 0)
@@ -324,7 +325,7 @@
         parser = NULL;
         client_set_queue (src->client, NULL);
 
-        if (connection_complete_source (src, NULL, 0) < 0)
+        if (connection_complete_source (src, 0) < 0)
         {
             DEBUG0("Failed to complete source initialisation");
             break;

Modified: icecast/branches/kh/icecast/src/source.c
===================================================================
--- icecast/branches/kh/icecast/src/source.c	2005-09-16 22:04:44 UTC (rev 10022)
+++ icecast/branches/kh/icecast/src/source.c	2005-09-16 22:13:49 UTC (rev 10023)
@@ -194,6 +194,7 @@
     DEBUG1 ("clearing source \"%s\"", source->mount);
     client_destroy(source->client);
     source->client = NULL;
+    source->parser = NULL;
 
     if (source->dumpfile)
     {
@@ -1310,9 +1311,10 @@
         source->hidden = 1;
         source->yp_public = 0;
         source->intro_file = file;
+        source->parser = parser;
         file = NULL;
 
-        if (connection_complete_source (source, parser, 0) < 0)
+        if (connection_complete_source (source, 0) < 0)
             break;
         source_client_thread (source);
         httpp_destroy (parser);

Modified: icecast/branches/kh/icecast/src/source.h
===================================================================
--- icecast/branches/kh/icecast/src/source.h	2005-09-16 22:04:44 UTC (rev 10022)
+++ icecast/branches/kh/icecast/src/source.h	2005-09-16 22:13:49 UTC (rev 10023)
@@ -23,6 +23,7 @@
 typedef struct source_tag
 {
     client_t *client;
+    http_parser_t *parser;
     time_t client_stats_update;
     
     char *mount;



More information about the commits mailing list