1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-12-04 14:46:30 -05:00

Update: Make the alias dereferencing loop more easy

This commit is contained in:
Philipp Schafft 2018-05-28 09:07:07 +00:00
parent 306cc58d74
commit 6c0b0e2976

View File

@ -1107,19 +1107,34 @@ static int _handle_aliases(client_t *client, char **uri)
alias = config->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)) &&
(alias->vhost == NULL || (vhost != NULL && strcmp(alias->vhost, vhost) == 0)) ) {
if (alias->destination)
new_uri = strdup(alias->destination);
if (alias->omode != OMODE_DEFAULT)
client->mode = alias->omode;
ICECAST_LOG_DEBUG("alias has made %s into %s", *uri, new_uri);
break;
}
alias = alias->next;
/* We now go thru all aliases and see if any matches. */
for (; alias; alias = alias->next) {
/* We check for several aspects, if they DO NOT match, we continue with our search. */
/* Check for the URI to match. */
if (strcmp(*uri, alias->source) != 0)
continue;
/* Check for the server's port to match. */
if (alias->port != -1 && alias->port != serverport)
continue;
/* Check for the server's bind address to match. */
if (alias->bind_address != NULL && serverhost != NULL && strcmp(alias->bind_address, serverhost) != 0)
continue;
/* Check for the vhost to match. */
if (alias->vhost != NULL && vhost != NULL && strcmp(alias->vhost, vhost) != 0)
continue;
/* Ok, we found a matching entry. */
if (alias->destination)
new_uri = strdup(alias->destination);
if (alias->omode != OMODE_DEFAULT)
client->mode = alias->omode;
ICECAST_LOG_DEBUG("alias has made %s into %s", *uri, new_uri);
break;
}
config_release_config();