[xiph-cvs] cvs commit: icecast/src config.c config.h connection.c connection.h slave.c
Michael Smith
msmith at xiph.org
Wed Apr 23 05:44:29 PDT 2003
msmith 03/04/23 08:44:29
Modified: . News
conf icecast.xml
src config.c config.h connection.c connection.h slave.c
Log:
Implementation of aliases contributed by Paul Donohue <icecast at TopQuark.net>
Revision Changes Path
1.5 +3 -0 icecast/News
Index: News
===================================================================
RCS file: /usr/local/cvsroot/icecast/News,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- News 9 Mar 2003 11:27:05 -0000 1.4
+++ News 23 Apr 2003 12:44:28 -0000 1.5
@@ -1,3 +1,6 @@
+2003-04-23
+ Support aliases
+
2003-03-09
Support listening on multiple sockets.
<p><p>1.22 +8 -0 icecast/conf/icecast.xml
Index: icecast.xml
===================================================================
RCS file: /usr/local/cvsroot/icecast/conf/icecast.xml,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- icecast.xml 11 Apr 2003 03:14:26 -0000 1.21
+++ icecast.xml 23 Apr 2003 12:44:28 -0000 1.22
@@ -83,6 +83,14 @@
be relative to the new root, not the original root -->
<logdir>/usr/local/icecast/logs</logdir>
<webroot>/usr/local/icecast/web</webroot>
+
+ <!-- Aliases: treat requests for 'source' path as being for 'dest' path
+ May be made specific to a port or bound address using the "port"
+ and "bind-address" attributes.
+ -->
+ <!--
+ <alias source="/foo" dest="/bar"/>
+ -->
</paths>
<logging>
<p><p>1.33 +50 -1 icecast/src/config.c
Index: config.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/config.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- config.c 15 Mar 2003 02:10:17 -0000 1.32
+++ config.c 23 Apr 2003 12:44:29 -0000 1.33
@@ -98,6 +98,7 @@
ice_config_dir_t *dirnode, *nextdirnode;
relay_server *relay, *nextrelay;
mount_proxy *mount, *nextmount;
+ aliases *alias, *nextalias;
int i;
if (c->config_filename)
@@ -160,6 +161,16 @@
}
thread_mutex_unlock(&(_locks.mounts_lock));
+ alias = c->aliases;
+ while(alias) {
+ nextalias = alias->next;
+ xmlFree(alias->source);
+ xmlFree(alias->destination);
+ xmlFree(alias->bind_address);
+ free(alias);
+ alias = nextalias;
+ }
+
dirnode = c->dir_list;
while(dirnode) {
nextdirnode = dirnode->next;
@@ -423,6 +434,7 @@
configuration->mounts = mount;
mount->max_listeners = -1;
+ mount->next = NULL;
do {
if (node == NULL) break;
@@ -474,6 +486,8 @@
else
configuration->relay = relay;
+ relay->next = NULL;
+
do {
if (node == NULL) break;
if (xmlIsBlankNode(node)) continue;
@@ -606,6 +620,9 @@
static void _parse_paths(xmlDocPtr doc, xmlNodePtr node,
ice_config_t *configuration)
{
+ char *temp;
+ aliases *alias, *current, *last;
+
do {
if (node == NULL) break;
if (xmlIsBlankNode(node)) continue;
@@ -621,7 +638,39 @@
configuration->webroot_dir = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
if(configuration->webroot_dir[strlen(configuration->webroot_dir)-1] == '/')
configuration->webroot_dir[strlen(configuration->webroot_dir)-1] = 0;
-
+ } else if (strcmp(node->name, "alias") == 0) {
+ alias = malloc(sizeof(aliases));
+ alias->next = NULL;
+ alias->source = xmlGetProp(node, "source");
+ if(alias->source == NULL) {
+ free(alias);
+ continue;
+ }
+ alias->destination = xmlGetProp(node, "dest");
+ if(alias->destination == NULL) {
+ xmlFree(alias->source);
+ free(alias);
+ continue;
+ }
+ temp = NULL;
+ temp = xmlGetProp(node, "port");
+ if(temp != NULL) {
+ alias->port = atoi(temp);
+ xmlFree(temp);
+ }
+ else
+ alias->port = -1;
+ alias->bind_address = xmlGetProp(node, "bind-address");
+ current = configuration->aliases;
+ last = NULL;
+ while(current) {
+ last = current;
+ current = current->next;
+ }
+ if(last)
+ last->next = alias;
+ else
+ configuration->aliases = alias;
}
} while ((node = node->next));
}
<p><p>1.21 +9 -0 icecast/src/config.h
Index: config.h
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/config.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- config.h 15 Mar 2003 02:10:17 -0000 1.20
+++ config.h 23 Apr 2003 12:44:29 -0000 1.21
@@ -43,6 +43,14 @@
struct _mount_proxy *next;
} mount_proxy;
+typedef struct _aliases {
+ char *source;
+ char *destination;
+ int port;
+ char *bind_address;
+ struct _aliases *next;
+}aliases;
+
typedef struct {
int port;
char *bind_address;
@@ -89,6 +97,7 @@
char *base_dir;
char *log_dir;
char *webroot_dir;
+ aliases *aliases;
char *access_log;
char *error_log;
<p><p>1.69 +25 -3 icecast/src/connection.c
Index: connection.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/connection.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -r1.68 -r1.69
--- connection.c 18 Apr 2003 14:59:26 -0000 1.68
+++ connection.c 23 Apr 2003 12:44:29 -0000 1.69
@@ -109,11 +109,12 @@
return id;
}
-connection_t *create_connection(sock_t sock, char *ip) {
+connection_t *create_connection(sock_t sock, sock_t serversock, char *ip) {
connection_t *con;
con = (connection_t *)malloc(sizeof(connection_t));
memset(con, 0, sizeof(connection_t));
con->sock = sock;
+ con->serversock = serversock;
con->con_time = time(NULL);
con->id = _next_connection_id();
con->ip = ip;
@@ -203,7 +204,7 @@
sock = sock_accept(serversock, ip, MAX_ADDR_LEN);
if (sock >= 0) {
- con = create_connection(sock, ip);
+ con = create_connection(sock, serversock, ip);
return con;
}
@@ -648,6 +649,10 @@
int fileserve;
char *host;
int port;
+ int i;
+ char *serverhost;
+ int serverport;
+ aliases *alias;
ice_config_t *config;
int client_limit;
@@ -655,6 +660,14 @@
fileserve = config->fileserve;
host = config->hostname;
port = config->port;
+ for(i = 0; i < MAX_LISTEN_SOCKETS; i++) {
+ if(global.serversock[i] == con->serversock) {
+ serverhost = config->listeners[i].bind_address;
+ serverport = config->listeners[i].port;
+ break;
+ }
+ }
+ alias = config->aliases;
client_limit = config->client_limit;
config_release_config();
@@ -668,12 +681,21 @@
/* there are several types of HTTP GET clients
** media clients, which are looking for a source (eg, URI = /stream.ogg)
** stats clients, which are looking for /admin/stats.xml
- ** and director server authorizers, which are looking for /GUID-xxxxxxxx
+ ** and directory server authorizers, which are looking for /GUID-xxxxxxxx
** (where xxxxxx is the GUID in question) - this isn't implemented yet.
** we need to handle the latter two before the former, as the latter two
** aren't subject to the limits.
*/
/* TODO: add GUID-xxxxxx */
+
+ /* Handle aliases */
+ while(alias) {
+ if(strcmp(uri, alias->source) == 0 && (alias->port == -1 || alias->port == serverport) && (alias->bind_address == NULL || (serverhost != NULL && strcmp(alias->bind_address, serverhost) == 0))) {
+ uri = alias->destination;
+ break;
+ }
+ alias = alias->next;
+ }
/* Dispatch all admin requests */
if (strncmp(uri, "/admin/", 7) == 0) {
<p><p>1.10 +2 -1 icecast/src/connection.h
Index: connection.h
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/connection.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- connection.h 15 Mar 2003 02:10:17 -0000 1.9
+++ connection.h 23 Apr 2003 12:44:29 -0000 1.10
@@ -17,6 +17,7 @@
uint64_t sent_bytes;
int sock;
+ int serversock;
int error;
char *ip;
@@ -31,7 +32,7 @@
void connection_shutdown(void);
void connection_accept_loop(void);
void connection_close(connection_t *con);
-connection_t *create_connection(sock_t sock, char *ip);
+connection_t *create_connection(sock_t sock, sock_t serversock, char *ip);
int connection_create_source(struct _client_tag *client, connection_t *con,
http_parser_t *parser, char *mount);
<p><p>1.25 +1 -1 icecast/src/slave.c
Index: slave.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/slave.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- slave.c 27 Mar 2003 17:10:02 -0000 1.24
+++ slave.c 23 Apr 2003 12:44:29 -0000 1.25
@@ -91,7 +91,7 @@
WARN2("Failed to relay stream from master server, couldn't connect to http://%s:%d", server, port);
return;
}
- con = create_connection(streamsock, NULL);
+ con = create_connection(streamsock, -1, NULL);
if(mp3) {
/* Some mp3 servers are bitchy, send a user-agent string to make them
* send the right response.
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list