mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
add function to do mount list search (could be extended later), call it from
various places including the shoutcast source client auth which previously only used the global source password. svn path=/icecast/trunk/icecast/; revision=9240
This commit is contained in:
parent
6d48d6c4f9
commit
e2d6bdb86a
@ -979,3 +979,17 @@ static void _add_server(xmlDocPtr doc, xmlNodePtr node,
|
||||
}
|
||||
|
||||
|
||||
/* return the mount details that match the supplied mountpoint */
|
||||
mount_proxy *config_find_mount (ice_config_t *config, const char *mount)
|
||||
{
|
||||
mount_proxy *mountinfo = config->mounts;
|
||||
|
||||
while (mountinfo)
|
||||
{
|
||||
if (strcmp (mountinfo->mountname, mount) == 0)
|
||||
break;
|
||||
mountinfo = mountinfo->next;
|
||||
}
|
||||
return mountinfo;
|
||||
}
|
||||
|
||||
|
@ -160,6 +160,7 @@ int config_initial_parse_file(const char *filename);
|
||||
int config_parse_cmdline(int arg, char **argv);
|
||||
void config_set_config(ice_config_t *config);
|
||||
void config_clear(ice_config_t *config);
|
||||
mount_proxy *config_find_mount (ice_config_t *config, const char *mount);
|
||||
|
||||
int config_rehash(void);
|
||||
|
||||
|
@ -449,7 +449,7 @@ int connection_complete_source (source_t *source)
|
||||
if (global.sources < config->source_limit)
|
||||
{
|
||||
char *contenttype;
|
||||
mount_proxy *mountproxy = config->mounts;
|
||||
mount_proxy *mountproxy;
|
||||
format_type_t format_type;
|
||||
|
||||
/* setup format handler */
|
||||
@ -516,15 +516,10 @@ int connection_complete_source (source_t *source)
|
||||
}
|
||||
}
|
||||
|
||||
while (mountproxy)
|
||||
{
|
||||
if (strcmp (mountproxy->mountname, source->mount) == 0)
|
||||
{
|
||||
source_apply_mount (source, mountproxy);
|
||||
break;
|
||||
}
|
||||
mountproxy = mountproxy->next;
|
||||
}
|
||||
mountproxy = config_find_mount (config, source->mount);
|
||||
if (mountproxy)
|
||||
source_apply_mount (source, mountproxy);
|
||||
|
||||
config_release_config();
|
||||
|
||||
source->shutdown_rwlock = &_source_shutdown_rwlock;
|
||||
@ -651,7 +646,7 @@ int connection_check_relay_pass(http_parser_t *parser)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int connection_check_source_pass(http_parser_t *parser, char *mount)
|
||||
int connection_check_source_pass(http_parser_t *parser, const char *mount)
|
||||
{
|
||||
ice_config_t *config = config_get_config();
|
||||
char *pass = config->source_password;
|
||||
@ -660,22 +655,16 @@ int connection_check_source_pass(http_parser_t *parser, char *mount)
|
||||
int ice_login = config->ice_login;
|
||||
char *protocol;
|
||||
|
||||
mount_proxy *mountinfo = config->mounts;
|
||||
thread_mutex_lock(&(config_locks()->mounts_lock));
|
||||
mount_proxy *mountinfo = config_find_mount (config, mount);
|
||||
|
||||
while(mountinfo) {
|
||||
if(!strcmp(mountinfo->mountname, mount)) {
|
||||
if(mountinfo->password)
|
||||
pass = mountinfo->password;
|
||||
if(mountinfo->username)
|
||||
user = mountinfo->username;
|
||||
break;
|
||||
}
|
||||
mountinfo = mountinfo->next;
|
||||
if (mountinfo)
|
||||
{
|
||||
if (mountinfo->password)
|
||||
pass = mountinfo->password;
|
||||
if (mountinfo->username)
|
||||
user = mountinfo->username;
|
||||
}
|
||||
|
||||
thread_mutex_unlock(&(config_locks()->mounts_lock));
|
||||
|
||||
if(!pass) {
|
||||
WARN0("No source password set, rejecting source");
|
||||
config_release_config();
|
||||
@ -1081,7 +1070,11 @@ static void *_handle_connection(void *arg)
|
||||
config = config_get_config();
|
||||
if (config->listeners[i].shoutcast_compat) {
|
||||
char *shoutcast_mount = strdup (config->shoutcast_mount);
|
||||
source_password = strdup(config->source_password);
|
||||
mount_proxy *mountinfo = config_find_mount (config, config->shoutcast_mount);
|
||||
if (mountinfo && mountinfo->password)
|
||||
source_password = strdup (mountinfo->password);
|
||||
else
|
||||
source_password = strdup (config->source_password);
|
||||
config_release_config();
|
||||
_handle_shoutcast_compatible(con, shoutcast_mount, source_password);
|
||||
free(source_password);
|
||||
|
@ -52,7 +52,7 @@ int connection_complete_source (struct source_tag *source);
|
||||
|
||||
void connection_inject_event(int eventnum, void *event_data);
|
||||
|
||||
int connection_check_source_pass(http_parser_t *parser, char *mount);
|
||||
int connection_check_source_pass(http_parser_t *parser, const char *mount);
|
||||
int connection_check_relay_pass(http_parser_t *parser);
|
||||
int connection_check_admin_pass(http_parser_t *parser);
|
||||
|
||||
|
30
src/source.c
30
src/source.c
@ -147,34 +147,22 @@ source_t *source_find_mount (const char *mount)
|
||||
int depth = 0;
|
||||
|
||||
config = config_get_config();
|
||||
while (mount != NULL)
|
||||
while (mount && depth < MAX_FALLBACK_DEPTH)
|
||||
{
|
||||
/* limit the number of times through, maybe infinite */
|
||||
if (depth > MAX_FALLBACK_DEPTH)
|
||||
{
|
||||
source = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
source = source_find_mount_raw(mount);
|
||||
|
||||
if (source != NULL && source->running)
|
||||
break;
|
||||
|
||||
/* source is not running, meaning that the fallback is not configured
|
||||
within the source, we need to check the mount list */
|
||||
mountinfo = config->mounts;
|
||||
/* we either have a source which is not active (relay) or no source
|
||||
* at all. Check the mounts list for fallback settings
|
||||
*/
|
||||
mountinfo = config_find_mount (config, mount);
|
||||
source = NULL;
|
||||
while (mountinfo)
|
||||
{
|
||||
if (strcmp (mountinfo->mountname, mount) == 0)
|
||||
break;
|
||||
mountinfo = mountinfo->next;
|
||||
}
|
||||
if (mountinfo)
|
||||
mount = mountinfo->fallback_mount;
|
||||
else
|
||||
mount = NULL;
|
||||
|
||||
if (mountinfo == NULL)
|
||||
break;
|
||||
mount = mountinfo->fallback_mount;
|
||||
depth++;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user