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

karl at dactyl.lonelymoon.com karl
Tue Jul 27 11:37:03 PDT 2004


Author: karl
Date: Tue Jul 27 11:37:03 2004
New Revision: 7373

Modified:
icecast/branches/kh/icecast/src/auth.c
icecast/branches/kh/icecast/src/cfgfile.c
icecast/branches/kh/icecast/src/cfgfile.h
icecast/branches/kh/icecast/src/client.h
icecast/branches/kh/icecast/src/slave.c
icecast/branches/kh/icecast/src/source.c
Log:
Allow for relays as created from the master list, to use the master user/pass
authentication for connecting.  In such cases allow slaves to connect no
matter what the listener count is.  Also add missing a line from previous
patch, need to allocate buffer for authentication header.


Modified: icecast/branches/kh/icecast/src/auth.c
===================================================================
--- icecast/branches/kh/icecast/src/auth.c	2004-07-27 18:27:31 UTC (rev 7372)
+++ icecast/branches/kh/icecast/src/auth.c	2004-07-27 18:37:02 UTC (rev 7373)
@@ -43,7 +43,7 @@
auth_t *authenticator = source->authenticator;
auth_result result;

-    if(authenticator) {
+    if (client->is_slave == 0 && authenticator) {
/* This will look something like "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" */
char *header = httpp_getvar(client->parser, "authorization");
char *userpass, *tmp;

Modified: icecast/branches/kh/icecast/src/cfgfile.c
===================================================================
--- icecast/branches/kh/icecast/src/cfgfile.c	2004-07-27 18:27:31 UTC (rev 7372)
+++ icecast/branches/kh/icecast/src/cfgfile.c	2004-07-27 18:37:02 UTC (rev 7373)
@@ -342,6 +342,7 @@
configuration->master_update_interval = CONFIG_MASTER_UPDATE_INTERVAL;
configuration->master_username = NULL;
configuration->master_password = NULL;
+    configuration->master_relay_auth = 0;
configuration->base_dir = CONFIG_DEFAULT_BASE_DIR;
configuration->log_dir = CONFIG_DEFAULT_LOG_DIR;
configuration->webroot_dir = CONFIG_DEFAULT_WEBROOT_DIR;
@@ -430,6 +431,10 @@
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
configuration->master_update_interval = atoi(tmp);
xmlFree (tmp);
+        } else if (strcmp(node->name, "master-relay-auth") == 0) {
+            tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+            configuration->master_relay_auth = atoi(tmp);
+            xmlFree (tmp);
} else if (strcmp(node->name, "limits") == 0) {
_parse_limits(doc, node->xmlChildrenNode, configuration);
} else if (strcmp(node->name, "relay") == 0) {

Modified: icecast/branches/kh/icecast/src/cfgfile.h
===================================================================
--- icecast/branches/kh/icecast/src/cfgfile.h	2004-07-27 18:27:31 UTC (rev 7372)
+++ icecast/branches/kh/icecast/src/cfgfile.h	2004-07-27 18:37:02 UTC (rev 7373)
@@ -121,6 +121,7 @@
int master_update_interval;
char *master_username;
char *master_password;
+    int master_relay_auth;

relay_server *relay;


Modified: icecast/branches/kh/icecast/src/client.h
===================================================================
--- icecast/branches/kh/icecast/src/client.h	2004-07-27 18:27:31 UTC (rev 7372)
+++ icecast/branches/kh/icecast/src/client.h	2004-07-27 18:37:02 UTC (rev 7373)
@@ -44,6 +44,9 @@
/* position in first buffer */
unsigned long pos;

+    /* client is a slave server */
+    int is_slave;
+
/* Client username, if authenticated */
char *username;


Modified: icecast/branches/kh/icecast/src/slave.c
===================================================================
--- icecast/branches/kh/icecast/src/slave.c	2004-07-27 18:27:31 UTC (rev 7372)
+++ icecast/branches/kh/icecast/src/slave.c	2004-07-27 18:37:02 UTC (rev 7373)
@@ -233,6 +233,7 @@
esc_authorisation = util_base64_encode(auth_header);
free(auth_header);
len = strlen (esc_authorisation) + 24;
+            auth_header = malloc (len);
snprintf (auth_header, len,
"Authorization: Basic %s\r\n", esc_authorisation);
free(esc_authorisation);
@@ -401,7 +402,7 @@
char *authheader, *data;
relay_server *relays = NULL, *relay;
int len, count = 1;
-        int on_demand;
+        int on_demand, send_auth;

if (config->master_username)
username = strdup (config->master_username);
@@ -418,6 +419,7 @@
if (password == NULL || master == NULL || port == 0)
break;
on_demand = config->on_demand;
+        send_auth = config->master_relay_auth;
ret = 1;
config_release_config();
mastersock = sock_connect_wto (master, port, 0);
@@ -467,6 +469,11 @@
r->localmount = xmlStrdup (buf);
r->mp3metadata = 1;
r->on_demand = on_demand;
+                if (send_auth)
+                {
+                    r->username = xmlStrdup (username);
+                    r->password = xmlStrdup (password);
+                }
r->next = relays;
relays = r;
}

Modified: icecast/branches/kh/icecast/src/source.c
===================================================================
--- icecast/branches/kh/icecast/src/source.c	2004-07-27 18:27:31 UTC (rev 7372)
+++ icecast/branches/kh/icecast/src/source.c	2004-07-27 18:37:02 UTC (rev 7373)
@@ -858,6 +858,8 @@
DEBUG2 ("pending %d, current %d", source->new_listeners, source->listeners);
if (source->max_listeners == -1)
break;
+            if (client->is_slave)
+                break;
if (source->new_listeners + source->listeners < source->max_listeners)
break;

@@ -895,6 +897,11 @@

if (mount)
{
+        if (connection_check_relay_pass(client->parser))
+        {
+            INFO0 ("client connected as slave");
+            client->is_slave = 1;
+        }
thread_mutex_lock (&move_clients_mutex);
avl_tree_rlock (global.source_tree);
added = _add_client (mount, client, 1);



More information about the commits mailing list