From d75d1d6a7a4383f05400c9200982fd9335c3c287 Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Sat, 20 Dec 2014 18:48:03 +0000 Subject: [PATCH] Feature: Allow to have only one of source and destination This allows (former ) to have only one of the attribues source and destination. In that case other parameters will be applied to the client but uri is not mapped. See #2097 --- src/cfgfile.c | 11 ++++++----- src/connection.c | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/cfgfile.c b/src/cfgfile.c index e2da9920..5f6703fb 100644 --- a/src/cfgfile.c +++ b/src/cfgfile.c @@ -1692,15 +1692,16 @@ static void _parse_paths(xmlDocPtr doc, xmlNodePtr node, alias = malloc(sizeof(aliases)); alias->next = NULL; alias->source = (char *)xmlGetProp(node, XMLSTR("source")); - if(alias->source == NULL) { - free(alias); - continue; - } alias->destination = (char *)xmlGetProp(node, XMLSTR("destination")); if (!alias->destination) alias->destination = (char *)xmlGetProp(node, XMLSTR("dest")); - if(alias->destination == NULL) { + + if (!alias->source && alias->destination) { + alias->source = alias->destination; + alias->destination = NULL; + } else if(!alias->source && !alias->destination) { xmlFree(alias->source); + xmlFree(alias->destination); free(alias); continue; } diff --git a/src/connection.c b/src/connection.c index e70d618b..13f4385b 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1269,7 +1269,8 @@ static int _handle_aliases(client_t *client, char **uri) { (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)) ) { - new_uri = strdup(alias->destination); + 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);