mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Fix relay stream listing. Remove seperate relay password, there's no
need for it. svn path=/trunk/icecast/; revision=4464
This commit is contained in:
parent
df4431766a
commit
596922217b
50
src/admin.c
50
src/admin.c
@ -29,6 +29,7 @@
|
||||
/* Global commands */
|
||||
#define COMMAND_LIST_MOUNTS 101
|
||||
#define COMMAND_RAW_STATS 102
|
||||
#define COMMAND_RAW_LISTSTREAM 103
|
||||
|
||||
int admin_get_command(char *command)
|
||||
{
|
||||
@ -44,6 +45,8 @@ int admin_get_command(char *command)
|
||||
return COMMAND_RAW_STATS;
|
||||
else if(!strcmp(command, "listmounts"))
|
||||
return COMMAND_LIST_MOUNTS;
|
||||
else if(!strcmp(command, "streamlist"))
|
||||
return COMMAND_RAW_LISTSTREAM;
|
||||
else
|
||||
return COMMAND_ERROR;
|
||||
}
|
||||
@ -53,7 +56,7 @@ static void command_metadata(client_t *client, source_t *source);
|
||||
static void command_show_listeners(client_t *client, source_t *source);
|
||||
|
||||
static void command_raw_stats(client_t *client);
|
||||
static void command_list_mounts(client_t *client);
|
||||
static void command_list_mounts(client_t *client, int formatted);
|
||||
|
||||
static void admin_handle_mount_request(client_t *client, source_t *source,
|
||||
int command);
|
||||
@ -132,7 +135,10 @@ static void admin_handle_general_request(client_t *client, int command)
|
||||
command_raw_stats(client);
|
||||
break;
|
||||
case COMMAND_LIST_MOUNTS:
|
||||
command_list_mounts(client);
|
||||
command_list_mounts(client, 1);
|
||||
break;
|
||||
case COMMAND_RAW_LISTSTREAM:
|
||||
command_list_mounts(client, 0);
|
||||
break;
|
||||
default:
|
||||
WARN0("General admin request not recognised");
|
||||
@ -300,17 +306,28 @@ static void command_raw_stats(client_t *client) {
|
||||
return;
|
||||
}
|
||||
|
||||
static void command_list_mounts(client_t *client) {
|
||||
static void command_list_mounts(client_t *client, int formatted) {
|
||||
avl_node *node;
|
||||
source_t *source;
|
||||
int bytes;
|
||||
|
||||
DEBUG0("List mounts request");
|
||||
|
||||
html_head(client);
|
||||
if(formatted) {
|
||||
html_head(client);
|
||||
|
||||
html_write(client,
|
||||
"<table><tr><td>Mountpoint</td><td>Fallback</td>"
|
||||
"<td>Format</td><td>Listeners</td></tr>");
|
||||
html_write(client,
|
||||
"<table><tr><td>Mountpoint</td><td>Fallback</td>"
|
||||
"<td>Format</td><td>Listeners</td></tr>");
|
||||
}
|
||||
else {
|
||||
client->respcode = 200;
|
||||
bytes = sock_write(client->con->sock,
|
||||
"HTTP/1.0 200 OK\r\n"
|
||||
"Content-Type: text/html\r\n"
|
||||
"\r\n");
|
||||
if(bytes > 0) client->con->sent_bytes = bytes;
|
||||
}
|
||||
|
||||
avl_tree_rlock(global.source_tree);
|
||||
|
||||
@ -318,18 +335,25 @@ static void command_list_mounts(client_t *client) {
|
||||
while(node) {
|
||||
source = (source_t *)node->key;
|
||||
|
||||
html_write(client,
|
||||
"<tr><td>%s</td><td>%s</td><td>%s</td><td>%ld</td></tr>",
|
||||
source->mount, (source->fallback_mount != NULL)?
|
||||
source->fallback_mount:"", source->format->format_description,
|
||||
source->listeners);
|
||||
if(formatted) {
|
||||
html_write(client,
|
||||
"<tr><td>%s</td><td>%s</td><td>%s</td><td>%ld</td></tr>",
|
||||
source->mount, (source->fallback_mount != NULL)?
|
||||
source->fallback_mount:"",
|
||||
source->format->format_description, source->listeners);
|
||||
}
|
||||
else {
|
||||
bytes = sock_write(client->con->sock, "%s\r\n", source->mount);
|
||||
if(bytes > 0) client->con->sent_bytes += bytes;
|
||||
}
|
||||
|
||||
node = avl_get_next(node);
|
||||
}
|
||||
|
||||
avl_tree_unlock(global.source_tree);
|
||||
|
||||
html_write(client, "</table></body></html>");
|
||||
if(formatted)
|
||||
html_write(client, "</table></body></html>");
|
||||
|
||||
client_destroy(client);
|
||||
return;
|
||||
|
14
src/config.c
14
src/config.c
@ -109,8 +109,6 @@ void config_clear(ice_config_t *c)
|
||||
xmlFree(c->admin);
|
||||
if (c->source_password && c->source_password != CONFIG_DEFAULT_SOURCE_PASSWORD)
|
||||
xmlFree(c->source_password);
|
||||
if (c->relay_password && c->relay_password != CONFIG_DEFAULT_SOURCE_PASSWORD)
|
||||
xmlFree(c->relay_password);
|
||||
if (c->admin_username)
|
||||
xmlFree(c->admin_username);
|
||||
if (c->admin_password)
|
||||
@ -260,7 +258,6 @@ static void _set_defaults(ice_config_t *configuration)
|
||||
configuration->header_timeout = CONFIG_DEFAULT_HEADER_TIMEOUT;
|
||||
configuration->source_timeout = CONFIG_DEFAULT_SOURCE_TIMEOUT;
|
||||
configuration->source_password = CONFIG_DEFAULT_SOURCE_PASSWORD;
|
||||
configuration->relay_password = CONFIG_DEFAULT_RELAY_PASSWORD;
|
||||
configuration->ice_login = CONFIG_DEFAULT_ICE_LOGIN;
|
||||
configuration->fileserve = CONFIG_DEFAULT_FILESERVE;
|
||||
configuration->touch_interval = CONFIG_DEFAULT_TOUCH_FREQ;
|
||||
@ -314,10 +311,6 @@ static void _parse_root(xmlDocPtr doc, xmlNodePtr node,
|
||||
if (configuration->source_password && configuration->source_password != CONFIG_DEFAULT_SOURCE_PASSWORD) xmlFree(configuration->source_password);
|
||||
configuration->source_password = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
|
||||
}
|
||||
} else if (strcmp(node->name, "relay-password") == 0) {
|
||||
/* TODO: This is the backwards-compatibility location */
|
||||
if (configuration->relay_password && configuration->relay_password != CONFIG_DEFAULT_RELAY_PASSWORD) xmlFree(configuration->relay_password);
|
||||
configuration->relay_password = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
|
||||
} else if (strcmp(node->name, "icelogin") == 0) {
|
||||
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
|
||||
configuration->ice_login = atoi(tmp);
|
||||
@ -563,13 +556,6 @@ static void _parse_authentication(xmlDocPtr doc, xmlNodePtr node,
|
||||
configuration->source_password =
|
||||
(char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
|
||||
}
|
||||
} else if (strcmp(node->name, "relay-password") == 0) {
|
||||
if (configuration->relay_password &&
|
||||
configuration->relay_password !=
|
||||
CONFIG_DEFAULT_RELAY_PASSWORD)
|
||||
xmlFree(configuration->relay_password);
|
||||
configuration->relay_password =
|
||||
(char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
|
||||
} else if (strcmp(node->name, "admin-password") == 0) {
|
||||
if(configuration->admin_password)
|
||||
xmlFree(configuration->admin_password);
|
||||
|
@ -66,7 +66,6 @@ typedef struct ice_config_tag
|
||||
int fileserve;
|
||||
|
||||
char *source_password;
|
||||
char *relay_password;
|
||||
char *admin_username;
|
||||
char *admin_password;
|
||||
|
||||
|
@ -519,17 +519,6 @@ static int _check_pass_ice(http_parser_t *parser, char *correctpass)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int connection_check_relay_pass(http_parser_t *parser)
|
||||
{
|
||||
ice_config_t *config = config_get_config();
|
||||
char *pass = config->relay_password;
|
||||
if(!pass)
|
||||
pass = config->source_password;
|
||||
config_release_config();
|
||||
|
||||
return _check_pass_http(parser, "relay", pass);
|
||||
}
|
||||
|
||||
int connection_check_admin_pass(http_parser_t *parser)
|
||||
{
|
||||
ice_config_t *config = config_get_config();
|
||||
@ -769,35 +758,6 @@ static void _handle_get_request(connection_t *con,
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(uri, "/admin/streamlist") == 0) {
|
||||
if (!connection_check_relay_pass(parser)) {
|
||||
INFO0("Client attempted to fetch /admin/streamlist with bad password");
|
||||
client_send_401(client);
|
||||
} else {
|
||||
avl_node *node;
|
||||
source_t *s;
|
||||
|
||||
client->respcode = 200;
|
||||
bytes = sock_write(client->con->sock,
|
||||
"HTTP/1.0 200 OK\r\n\r\n");
|
||||
if(bytes > 0) client->con->sent_bytes = bytes;
|
||||
|
||||
avl_tree_rlock(global.source_tree);
|
||||
node = avl_get_first(global.source_tree);
|
||||
while (node) {
|
||||
s = (source_t *)node->key;
|
||||
bytes = sock_write(client->con->sock, "%s\r\n", s->mount);
|
||||
if(bytes > 0) client->con->sent_bytes += bytes;
|
||||
else break;
|
||||
|
||||
node = avl_get_next(node);
|
||||
}
|
||||
avl_tree_unlock(global.source_tree);
|
||||
client_destroy(client);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
global_lock();
|
||||
if (global.clients >= client_limit) {
|
||||
client_send_504(client,
|
||||
|
Loading…
Reference in New Issue
Block a user