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

Cleanup: Renamed alias -> resource

This commit is contained in:
Philipp Schafft 2018-05-28 12:25:11 +00:00
parent 29c0501237
commit 07ee2814e0
3 changed files with 65 additions and 65 deletions

View File

@ -573,8 +573,8 @@ void config_clear(ice_config_t *c)
*nextrelay; *nextrelay;
mount_proxy *mount, mount_proxy *mount,
*nextmount; *nextmount;
aliases *alias, resource_t *resource,
*nextalias; *nextresource;
#ifdef USE_YP #ifdef USE_YP
int i; int i;
#endif #endif
@ -633,15 +633,15 @@ void config_clear(ice_config_t *c)
mount = nextmount; mount = nextmount;
} }
alias = c->aliases; resource = c->resources;
while (alias) { while (resource) {
nextalias = alias->next; nextresource = resource->next;
xmlFree(alias->source); xmlFree(resource->source);
xmlFree(alias->destination); xmlFree(resource->destination);
xmlFree(alias->bind_address); xmlFree(resource->bind_address);
xmlFree(alias->vhost); xmlFree(resource->vhost);
free(alias); free(resource);
alias = nextalias; resource = nextresource;
} }
dirnode = c->dir_list; dirnode = c->dir_list;
@ -1905,7 +1905,7 @@ static void _parse_paths(xmlDocPtr doc,
ice_config_t *configuration) ice_config_t *configuration)
{ {
char *temp; char *temp;
aliases *alias, resource_t *resource,
*current, *current,
*last; *last;
@ -1989,52 +1989,52 @@ static void _parse_paths(xmlDocPtr doc,
if (configuration->adminroot_dir[strlen(configuration->adminroot_dir)-1] == '/') if (configuration->adminroot_dir[strlen(configuration->adminroot_dir)-1] == '/')
configuration->adminroot_dir[strlen(configuration->adminroot_dir)-1] = 0; configuration->adminroot_dir[strlen(configuration->adminroot_dir)-1] = 0;
} else if (xmlStrcmp(node->name, XMLSTR("resource")) == 0 || xmlStrcmp(node->name, XMLSTR("alias")) == 0) { } else if (xmlStrcmp(node->name, XMLSTR("resource")) == 0 || xmlStrcmp(node->name, XMLSTR("alias")) == 0) {
alias = calloc(1, sizeof(aliases)); resource = calloc(1, sizeof(resource_t));
alias->next = NULL; resource->next = NULL;
alias->source = (char *)xmlGetProp(node, XMLSTR("source")); resource->source = (char *)xmlGetProp(node, XMLSTR("source"));
alias->destination = (char *)xmlGetProp(node, XMLSTR("destination")); resource->destination = (char *)xmlGetProp(node, XMLSTR("destination"));
if (!alias->destination) if (!resource->destination)
alias->destination = (char *)xmlGetProp(node, XMLSTR("dest")); resource->destination = (char *)xmlGetProp(node, XMLSTR("dest"));
if (!alias->source && alias->destination) { if (!resource->source && resource->destination) {
alias->source = alias->destination; resource->source = resource->destination;
alias->destination = NULL; resource->destination = NULL;
} else if (!alias->source && !alias->destination) { } else if (!resource->source && !resource->destination) {
xmlFree(alias->source); xmlFree(resource->source);
xmlFree(alias->destination); xmlFree(resource->destination);
free(alias); free(resource);
continue; continue;
} }
temp = (char *)xmlGetProp(node, XMLSTR("port")); temp = (char *)xmlGetProp(node, XMLSTR("port"));
if(temp != NULL) { if(temp != NULL) {
alias->port = util_str_to_int(temp, alias->port); resource->port = util_str_to_int(temp, resource->port);
xmlFree(temp); xmlFree(temp);
} else { } else {
alias->port = -1; resource->port = -1;
} }
alias->bind_address = (char *)xmlGetProp(node, XMLSTR("bind-address")); resource->bind_address = (char *)xmlGetProp(node, XMLSTR("bind-address"));
alias->vhost = (char *)xmlGetProp(node, XMLSTR("vhost")); resource->vhost = (char *)xmlGetProp(node, XMLSTR("vhost"));
temp = (char *)xmlGetProp(node, XMLSTR("omode")); temp = (char *)xmlGetProp(node, XMLSTR("omode"));
if (temp) { if (temp) {
alias->omode = config_str_to_omode(temp); resource->omode = config_str_to_omode(temp);
xmlFree(temp); xmlFree(temp);
} else { } else {
alias->omode = OMODE_DEFAULT; resource->omode = OMODE_DEFAULT;
} }
temp = (char *)xmlGetProp(node, XMLSTR("prefixmatch")); temp = (char *)xmlGetProp(node, XMLSTR("prefixmatch"));
alias->flags |= util_str_to_bool(temp) ? ALIAS_FLAG_PREFIXMATCH : 0; resource->flags |= util_str_to_bool(temp) ? ALIAS_FLAG_PREFIXMATCH : 0;
current = configuration->aliases; current = configuration->resources;
last = NULL; last = NULL;
while (current) { while (current) {
last = current; last = current;
current = current->next; current = current->next;
} }
if(last) { if(last) {
last->next = alias; last->next = resource;
} else { } else {
configuration->aliases = alias; configuration->resources = resource;
} }
} }
} while ((node = node->next)); } while ((node = node->next));

View File

@ -157,7 +157,7 @@ typedef struct _mount_proxy {
#define ALIAS_FLAG_PREFIXMATCH 0x0001 #define ALIAS_FLAG_PREFIXMATCH 0x0001
typedef struct _aliases { typedef struct _resource {
char *source; char *source;
char *destination; char *destination;
int port; int port;
@ -165,8 +165,8 @@ typedef struct _aliases {
char *vhost; char *vhost;
operation_mode omode; operation_mode omode;
unsigned int flags; unsigned int flags;
struct _aliases *next; struct _resource *next;
} aliases; } resource_t;
typedef struct _listener_t { typedef struct _listener_t {
struct _listener_t *next; struct _listener_t *next;
@ -241,7 +241,7 @@ typedef struct ice_config_tag {
char *allowfile; char *allowfile;
char *webroot_dir; char *webroot_dir;
char *adminroot_dir; char *adminroot_dir;
aliases *aliases; resource_t *resources;
char *access_log; char *access_log;
char *error_log; char *error_log;

View File

@ -1074,10 +1074,10 @@ static void _handle_shoutcast_compatible(client_queue_t *node)
return; return;
} }
/* Handle <alias> lookups here. /* Handle <resource> lookups here.
*/ */
static int _handle_aliases(client_t *client, char **uri) static int _handle_resources(client_t *client, char **uri)
{ {
const char *http_host = httpp_getvar(client->parser, "host"); const char *http_host = httpp_getvar(client->parser, "host");
char *serverhost = NULL; char *serverhost = NULL;
@ -1087,7 +1087,7 @@ static int _handle_aliases(client_t *client, char **uri)
char *new_uri = NULL; char *new_uri = NULL;
ice_config_t *config; ice_config_t *config;
listener_t *listen_sock; listener_t *listen_sock;
aliases *alias; resource_t *resource;
if (http_host) { if (http_host) {
vhost = strdup(http_host); vhost = strdup(http_host);
@ -1105,48 +1105,48 @@ static int _handle_aliases(client_t *client, char **uri)
serverport = listen_sock->port; serverport = listen_sock->port;
} }
alias = config->aliases; resource = config->resources;
/* We now go thru all aliases and see if any matches. */ /* We now go thru all resources and see if any matches. */
for (; alias; alias = alias->next) { for (; resource; resource = resource->next) {
/* We check for several aspects, if they DO NOT match, we continue with our search. */ /* We check for several aspects, if they DO NOT match, we continue with our search. */
/* Check for the URI to match. */ /* Check for the URI to match. */
if (alias->flags & ALIAS_FLAG_PREFIXMATCH) { if (resource->flags & ALIAS_FLAG_PREFIXMATCH) {
size_t len = strlen(alias->source); size_t len = strlen(resource->source);
if (strncmp(*uri, alias->source, len) != 0) if (strncmp(*uri, resource->source, len) != 0)
continue; continue;
ICECAST_LOG_DEBUG("Match: *uri='%s', alias->source='%s', len=%zu", *uri, alias->source, len); ICECAST_LOG_DEBUG("Match: *uri='%s', resource->source='%s', len=%zu", *uri, resource->source, len);
} else { } else {
if (strcmp(*uri, alias->source) != 0) if (strcmp(*uri, resource->source) != 0)
continue; continue;
} }
/* Check for the server's port to match. */ /* Check for the server's port to match. */
if (alias->port != -1 && alias->port != serverport) if (resource->port != -1 && resource->port != serverport)
continue; continue;
/* Check for the server's bind address to match. */ /* Check for the server's bind address to match. */
if (alias->bind_address != NULL && serverhost != NULL && strcmp(alias->bind_address, serverhost) != 0) if (resource->bind_address != NULL && serverhost != NULL && strcmp(resource->bind_address, serverhost) != 0)
continue; continue;
/* Check for the vhost to match. */ /* Check for the vhost to match. */
if (alias->vhost != NULL && vhost != NULL && strcmp(alias->vhost, vhost) != 0) if (resource->vhost != NULL && vhost != NULL && strcmp(resource->vhost, vhost) != 0)
continue; continue;
/* Ok, we found a matching entry. */ /* Ok, we found a matching entry. */
if (alias->destination) { if (resource->destination) {
if (alias->flags & ALIAS_FLAG_PREFIXMATCH) { if (resource->flags & ALIAS_FLAG_PREFIXMATCH) {
size_t len = strlen(alias->source); size_t len = strlen(resource->source);
asprintf(&new_uri, "%s%s", alias->destination, (*uri) + len); asprintf(&new_uri, "%s%s", resource->destination, (*uri) + len);
} else { } else {
new_uri = strdup(alias->destination); new_uri = strdup(resource->destination);
} }
} }
if (alias->omode != OMODE_DEFAULT) if (resource->omode != OMODE_DEFAULT)
client->mode = alias->omode; client->mode = resource->omode;
ICECAST_LOG_DEBUG("alias has made %s into %s", *uri, new_uri); ICECAST_LOG_DEBUG("resource has made %s into %s", *uri, new_uri);
break; break;
} }
@ -1405,7 +1405,7 @@ static void _handle_connection(void)
client->mode = config_str_to_omode(httpp_get_query_param(client->parser, "omode")); client->mode = config_str_to_omode(httpp_get_query_param(client->parser, "omode"));
if (_handle_aliases(client, &uri) != 0) { if (_handle_resources(client, &uri) != 0) {
client_destroy (client); client_destroy (client);
continue; continue;
} }