Commit 08ad72ff authored by Michael Smith's avatar Michael Smith

Allow configuring local mountpoint seperately from remote mountpoint

svn path=/trunk/icecast/; revision=4340
parent f3d717e9
...@@ -109,6 +109,8 @@ void config_shutdown(void) ...@@ -109,6 +109,8 @@ void config_shutdown(void)
nextrelay = relay->next; nextrelay = relay->next;
xmlFree(relay->server); xmlFree(relay->server);
xmlFree(relay->mount); xmlFree(relay->mount);
if(relay->localmount)
xmlFree(relay->localmount);
free(relay); free(relay);
relay = nextrelay; relay = nextrelay;
} }
...@@ -419,6 +421,10 @@ static void _parse_relay(xmlDocPtr doc, xmlNodePtr node) ...@@ -419,6 +421,10 @@ static void _parse_relay(xmlDocPtr doc, xmlNodePtr node)
relay->mount = (char *)xmlNodeListGetString( relay->mount = (char *)xmlNodeListGetString(
doc, node->xmlChildrenNode, 1); doc, node->xmlChildrenNode, 1);
} }
else if (strcmp(node->name, "local-mount") == 0) {
relay->localmount = (char *)xmlNodeListGetString(
doc, node->xmlChildrenNode, 1);
}
} while ((node = node->next)); } while ((node = node->next));
} }
......
...@@ -19,6 +19,7 @@ typedef struct _relay_server { ...@@ -19,6 +19,7 @@ typedef struct _relay_server {
char *server; char *server;
int port; int port;
char *mount; char *mount;
char *localmount;
struct _relay_server *next; struct _relay_server *next;
} relay_server; } relay_server;
......
...@@ -65,7 +65,8 @@ void slave_shutdown(void) { ...@@ -65,7 +65,8 @@ void slave_shutdown(void) {
thread_join(_slave_thread_id); thread_join(_slave_thread_id);
} }
static void create_relay_stream(char *server, int port, char *mount) static void create_relay_stream(char *server, int port,
char *remotemount, char *localmount)
{ {
sock_t streamsock; sock_t streamsock;
char header[4096]; char header[4096];
...@@ -73,7 +74,10 @@ static void create_relay_stream(char *server, int port, char *mount) ...@@ -73,7 +74,10 @@ static void create_relay_stream(char *server, int port, char *mount)
http_parser_t *parser; http_parser_t *parser;
client_t *client; client_t *client;
DEBUG1("Adding source at mountpoint \"%s\"", mount); if(!localmount)
localmount = remotemount;
DEBUG1("Adding source at mountpoint \"%s\"", localmount);
streamsock = sock_connect_wto(server, port, 0); streamsock = sock_connect_wto(server, port, 0);
if (streamsock == SOCK_ERROR) { if (streamsock == SOCK_ERROR) {
...@@ -81,7 +85,7 @@ static void create_relay_stream(char *server, int port, char *mount) ...@@ -81,7 +85,7 @@ static void create_relay_stream(char *server, int port, char *mount)
return; return;
} }
con = create_connection(streamsock, NULL); con = create_connection(streamsock, NULL);
sock_write(streamsock, "GET %s HTTP/1.0\r\n\r\n", mount); sock_write(streamsock, "GET %s HTTP/1.0\r\n\r\n", remotemount);
memset(header, 0, sizeof(header)); memset(header, 0, sizeof(header));
if (util_read_header(con->sock, header, 4096) == 0) { if (util_read_header(con->sock, header, 4096) == 0) {
connection_close(con); connection_close(con);
...@@ -89,7 +93,7 @@ static void create_relay_stream(char *server, int port, char *mount) ...@@ -89,7 +93,7 @@ static void create_relay_stream(char *server, int port, char *mount)
} }
parser = httpp_create_parser(); parser = httpp_create_parser();
httpp_initialize(parser, NULL); httpp_initialize(parser, NULL);
if(!httpp_parse_response(parser, header, strlen(header), mount)) { if(!httpp_parse_response(parser, header, strlen(header), localmount)) {
if(httpp_getvar(parser, HTTPP_VAR_ERROR_MESSAGE)) { if(httpp_getvar(parser, HTTPP_VAR_ERROR_MESSAGE)) {
ERROR1("Error parsing relay request: %s", ERROR1("Error parsing relay request: %s",
httpp_getvar(parser, HTTPP_VAR_ERROR_MESSAGE)); httpp_getvar(parser, HTTPP_VAR_ERROR_MESSAGE));
...@@ -164,7 +168,7 @@ static void *_slave_thread(void *arg) { ...@@ -164,7 +168,7 @@ static void *_slave_thread(void *arg) {
create_relay_stream( create_relay_stream(
config_get_config()->master_server, config_get_config()->master_server,
config_get_config()->master_server_port, config_get_config()->master_server_port,
buf); buf, NULL);
} }
else else
avl_tree_unlock(global.source_tree); avl_tree_unlock(global.source_tree);
...@@ -179,7 +183,8 @@ static void *_slave_thread(void *arg) { ...@@ -179,7 +183,8 @@ static void *_slave_thread(void *arg) {
if(!source_find_mount(relay->mount)) { if(!source_find_mount(relay->mount)) {
avl_tree_unlock(global.source_tree); avl_tree_unlock(global.source_tree);
create_relay_stream(relay->server, relay->port, relay->mount); create_relay_stream(relay->server, relay->port, relay->mount,
relay->localmount);
} }
else else
avl_tree_unlock(global.source_tree); avl_tree_unlock(global.source_tree);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment