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

karl at svn.xiph.org karl at svn.xiph.org
Thu Aug 11 19:40:29 PDT 2005


Author: karl
Date: 2005-08-11 19:40:25 -0700 (Thu, 11 Aug 2005)
New Revision: 9736

Modified:
   icecast/trunk/icecast/src/auth.h
   icecast/trunk/icecast/src/auth_url.c
   icecast/trunk/icecast/src/connection.h
   icecast/trunk/icecast/src/main.c
   icecast/trunk/icecast/src/source.c
Log:
merge in client timelimit, only auth_url sets this currently. Add missing
prototypes for compile warning


Modified: icecast/trunk/icecast/src/auth.h
===================================================================
--- icecast/trunk/icecast/src/auth.h	2005-08-11 23:49:56 UTC (rev 9735)
+++ icecast/trunk/icecast/src/auth.h	2005-08-12 02:40:25 UTC (rev 9736)
@@ -77,6 +77,8 @@
 int  release_client (client_t *client);
 
 void auth_initialise ();
+void auth_shutdown ();
+
 auth_t  *auth_get_authenticator (xmlNodePtr node);
 void    auth_release (auth_t *authenticator);
 

Modified: icecast/trunk/icecast/src/auth_url.c
===================================================================
--- icecast/trunk/icecast/src/auth_url.c	2005-08-11 23:49:56 UTC (rev 9735)
+++ icecast/trunk/icecast/src/auth_url.c	2005-08-12 02:40:25 UTC (rev 9736)
@@ -24,6 +24,12 @@
  *
  * icecast-auth-user: 1
  *
+ * A listening client may also be configured as only to stay connected for a
+ * certain length of time. eg The auth server may only allow a 15 minute
+ * playback by sending back.
+ *
+ * icecast-auth-timelimit: 900
+ *
  * On client disconnection another request can be sent to a URL with the POST
  * information of
  *
@@ -78,14 +84,16 @@
     char *password;
     char *auth_header;
     int  auth_header_len;
+    char *timelimit_header;
+    int  timelimit_header_len;
     CURL *handle;
     char errormsg [CURL_ERROR_SIZE];
 } auth_url;
 
 
 static void auth_url_clear(auth_t *self)
-{
-    auth_url *url;
+{
+    auth_url *url;
 
     INFO0 ("Doing auth URL cleanup");
     url = self->state;
@@ -97,6 +105,7 @@
     free (url->stream_start);
     free (url->stream_end);
     free (url->auth_header);
+    free (url->timelimit_header);
     free (url);
 }
 
@@ -113,6 +122,12 @@
         auth_url *url = auth->state;
         if (strncasecmp (ptr, url->auth_header, url->auth_header_len) == 0)
             client->authenticated = 1;
+        if (strncasecmp (ptr, url->timelimit_header, url->timelimit_header_len) == 0)
+        {
+            unsigned int limit = 0;
+            sscanf ((char *)ptr+url->timelimit_header_len, "%u\r\n", &limit);
+            client->con->discon_time = time(NULL) + limit;
+        }
         if (strncasecmp (ptr, "icecast-auth-message: ", 22) == 0)
         {
             char *eol;
@@ -379,6 +394,7 @@
 
     url_info = calloc(1, sizeof(auth_url));
     url_info->auth_header = strdup ("icecast-auth-user: 1\r\n");
+    url_info->timelimit_header = strdup ("icecast-auth-timelimit:");
 
     while(options) {
         if(!strcmp(options->name, "username"))
@@ -398,6 +414,11 @@
             free (url_info->auth_header);
             url_info->auth_header = strdup (options->value);
         }
+        if (strcmp(options->name, "timelimit-header") == 0)
+        {
+            free (url_info->timelimit_header);
+            url_info->timelimit_header = strdup (options->value);
+        }
         options = options->next;
     }
     url_info->handle = curl_easy_init ();
@@ -408,6 +429,8 @@
     }
     if (url_info->auth_header)
         url_info->auth_header_len = strlen (url_info->auth_header);
+    if (url_info->timelimit_header)
+        url_info->timelimit_header_len = strlen (url_info->timelimit_header);
 
     curl_easy_setopt (url_info->handle, CURLOPT_USERAGENT, ICECAST_VERSION_STRING);
     curl_easy_setopt (url_info->handle, CURLOPT_HEADERFUNCTION, handle_returned_header);

Modified: icecast/trunk/icecast/src/connection.h
===================================================================
--- icecast/trunk/icecast/src/connection.h	2005-08-11 23:49:56 UTC (rev 9735)
+++ icecast/trunk/icecast/src/connection.h	2005-08-12 02:40:25 UTC (rev 9736)
@@ -28,9 +28,9 @@
     unsigned long id;
 
     time_t con_time;
+    time_t discon_time;
     uint64_t sent_bytes;
 
-
     int sock;
     int serversock;
     int error;

Modified: icecast/trunk/icecast/src/main.c
===================================================================
--- icecast/trunk/icecast/src/main.c	2005-08-11 23:49:56 UTC (rev 9735)
+++ icecast/trunk/icecast/src/main.c	2005-08-12 02:40:25 UTC (rev 9736)
@@ -49,6 +49,7 @@
 #include "xslt.h"
 #include "fserve.h"
 #include "yp.h"
+#include "auth.h"
 
 #include <libxml/xmlmemory.h>
 

Modified: icecast/trunk/icecast/src/source.c
===================================================================
--- icecast/trunk/icecast/src/source.c	2005-08-11 23:49:56 UTC (rev 9735)
+++ icecast/trunk/icecast/src/source.c	2005-08-12 02:40:25 UTC (rev 9736)
@@ -507,6 +507,14 @@
 
     while (1)
     {
+        /* check for limited listener time */
+        if (client->con->discon_time)
+            if (time(NULL) >= client->con->discon_time)
+            {
+                INFO1 ("time limit reached for client #%lu", client->con->id);
+                client->con->error = 1;
+            }
+
         /* jump out if client connection has died */
         if (client->con->error)
             break;



More information about the commits mailing list