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

(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) ...@@ -300,6 +300,7 @@ void config_clear(ice_config_t *c)
xmlFree(alias->source); xmlFree(alias->source);
xmlFree(alias->destination); xmlFree(alias->destination);
xmlFree(alias->bind_address); xmlFree(alias->bind_address);
xmlFree(alias->vhost);
free(alias); free(alias);
alias = nextalias; alias = nextalias;
} }
...@@ -1199,6 +1200,7 @@ static void _parse_paths(xmlDocPtr doc, xmlNodePtr node, ...@@ -1199,6 +1200,7 @@ static void _parse_paths(xmlDocPtr doc, xmlNodePtr node,
else else
alias->port = -1; alias->port = -1;
alias->bind_address = (char *)xmlGetProp(node, XMLSTR("bind-address")); alias->bind_address = (char *)xmlGetProp(node, XMLSTR("bind-address"));
alias->vhost = (char *)xmlGetProp(node, XMLSTR("vhost"));
current = configuration->aliases; current = configuration->aliases;
last = NULL; last = NULL;
while(current) { while(current) {
......
...@@ -125,6 +125,7 @@ typedef struct _aliases { ...@@ -125,6 +125,7 @@ typedef struct _aliases {
char *destination; char *destination;
int port; int port;
char *bind_address; char *bind_address;
char *vhost;
struct _aliases *next; struct _aliases *next;
} aliases; } aliases;
......
...@@ -1142,6 +1142,9 @@ static void _handle_get_request (client_t *client, char *passed_uri) ...@@ -1142,6 +1142,9 @@ static void _handle_get_request (client_t *client, char *passed_uri)
ice_config_t *config; ice_config_t *config;
char *uri = passed_uri; char *uri = passed_uri;
listener_t *listen_sock; listener_t *listen_sock;
const char *http_host = httpp_getvar(client->parser, "host");
char *vhost;
char *vhost_colon;
config = config_get_config(); config = config_get_config();
...@@ -1164,14 +1167,27 @@ static void _handle_get_request (client_t *client, char *passed_uri) ...@@ -1164,14 +1167,27 @@ static void _handle_get_request (client_t *client, char *passed_uri)
/* TODO: add GUID-xxxxxx */ /* TODO: add GUID-xxxxxx */
/* Handle aliases */ /* Handle aliases */
while(alias) { if (http_host) {
if(strcmp(uri, alias->source) == 0 && (alias->port == -1 || alias->port == serverport) && (alias->bind_address == NULL || (serverhost != NULL && strcmp(alias->bind_address, serverhost) == 0))) { 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); uri = strdup (alias->destination);
ICECAST_LOG_DEBUG("alias has made %s into %s", passed_uri, uri); ICECAST_LOG_DEBUG("alias has made %s into %s", passed_uri, uri);
break; break;
} }
alias = alias->next; alias = alias->next;
} }
if (vhost)
free(vhost);
config_release_config(); config_release_config();
stats_event_inc(NULL, "client_connections"); 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