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