Commit 5a8d0d16 authored by Philipp Schafft's avatar Philipp Schafft 🦁

(sync with my branch) support vhosting on aliases

svn path=/icecast/trunk/icecast/; revision=19336
parent 1a3fd18c
......@@ -300,6 +300,7 @@ void config_clear(ice_config_t *c)
xmlFree(alias->source);
xmlFree(alias->destination);
xmlFree(alias->bind_address);
xmlFree(alias->vhost);
free(alias);
alias = nextalias;
}
......@@ -1199,6 +1200,7 @@ static void _parse_paths(xmlDocPtr doc, xmlNodePtr node,
else
alias->port = -1;
alias->bind_address = (char *)xmlGetProp(node, XMLSTR("bind-address"));
alias->vhost = (char *)xmlGetProp(node, XMLSTR("vhost"));
current = configuration->aliases;
last = NULL;
while(current) {
......
......@@ -125,6 +125,7 @@ typedef struct _aliases {
char *destination;
int port;
char *bind_address;
char *vhost;
struct _aliases *next;
} aliases;
......
......@@ -1142,6 +1142,9 @@ static void _handle_get_request (client_t *client, char *passed_uri)
ice_config_t *config;
char *uri = passed_uri;
listener_t *listen_sock;
const char *http_host = httpp_getvar(client->parser, "host");
char *vhost;
char *vhost_colon;
config = config_get_config();
......@@ -1164,14 +1167,27 @@ static void _handle_get_request (client_t *client, char *passed_uri)
/* TODO: add GUID-xxxxxx */
/* Handle 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))) {
if (http_host) {
vhost = strdup(http_host);
if (vhost) {
vhost_colon = strstr(vhost, ":");
if (vhost_colon)
*vhost_colon = 0;
}
}
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)) ) {
uri = strdup (alias->destination);
ICECAST_LOG_DEBUG("alias has made %s into %s", passed_uri, uri);
break;
}
alias = alias->next;
}
if (vhost)
free(vhost);
config_release_config();
stats_event_inc(NULL, "client_connections");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment