Commit 11a1d83e authored by Michael Smith's avatar Michael Smith

New year's bonus feature:

 configurable fallbacks, now working.

svn path=/trunk/icecast/; revision=4192
parent ab8c8c68
...@@ -419,6 +419,42 @@ static int _check_source_pass(http_parser_t *parser) ...@@ -419,6 +419,42 @@ static int _check_source_pass(http_parser_t *parser)
return ret; return ret;
} }
static void handle_fallback_request(client_t *client)
{
source_t *source;
char *mount, *value, *old;
int bytes;
if(!_check_source_pass(client->parser)) {
INFO0("Bad or missing password on fallback configuration request");
client_send_401(client);
return;
}
mount = httpp_get_query_param(client->parser, "mount");
value = httpp_get_query_param(client->parser, "fallback");
if(value == NULL || mount == NULL) {
client_send_400(client, "Missing parameter");
return;
}
avl_tree_rlock(global.source_tree);
source = source_find_mount(mount);
avl_tree_unlock(global.source_tree);
old = source->fallback_mount;
source->fallback_mount = strdup(value);
free(old);
client->respcode = 200;
bytes = sock_write(client->con->sock,
"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"
"Fallback configured");
if(bytes > 0) client->con->sent_bytes = bytes;
client_destroy(client);
}
static void handle_metadata_request(client_t *client) static void handle_metadata_request(client_t *client)
{ {
source_t *source; source_t *source;
...@@ -578,6 +614,12 @@ static void _handle_get_request(connection_t *con, ...@@ -578,6 +614,12 @@ static void _handle_get_request(connection_t *con,
return; return;
} }
if(strcmp(uri, "/admin/fallbacks") == 0) {
DEBUG0("Got fallback request");
handle_fallback_request(client);
return;
}
/* Here we are parsing the URI request to see /* Here we are parsing the URI request to see
** if the extension is .xsl, if so, then process ** if the extension is .xsl, if so, then process
** this request as an XSLT request ** this request as an XSLT request
......
...@@ -45,6 +45,7 @@ source_t *source_create(client_t *client, connection_t *con, http_parser_t *pars ...@@ -45,6 +45,7 @@ source_t *source_create(client_t *client, connection_t *con, http_parser_t *pars
src = (source_t *)malloc(sizeof(source_t)); src = (source_t *)malloc(sizeof(source_t));
src->client = client; src->client = client;
src->mount = (char *)strdup(mount); src->mount = (char *)strdup(mount);
src->fallback_mount = NULL;
src->format = format_get_plugin(type, src->mount); src->format = format_get_plugin(type, src->mount);
src->con = con; src->con = con;
src->parser = parser; src->parser = parser;
......
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