mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Feature: Support per-<acl> HTTP headers
This commit is contained in:
parent
6f28d3fd3a
commit
c71aa0a08f
27
src/acl.c
27
src/acl.c
@ -44,6 +44,9 @@ struct acl_tag {
|
||||
/* mount specific functons */
|
||||
time_t max_connection_duration;
|
||||
size_t max_connections_per_user;
|
||||
|
||||
/* HTTP headers to send to clients using this role */
|
||||
ice_config_http_header_t *http_headers;
|
||||
};
|
||||
|
||||
/* some string util functions */
|
||||
@ -195,6 +198,20 @@ acl_t *acl_new_from_xml_node(xmlNodePtr node)
|
||||
prop = prop->next;
|
||||
}
|
||||
|
||||
/* if we're new style configured try to read child nodes */
|
||||
if (xmlStrcmp(node->name, XMLSTR("acl")) == 0) {
|
||||
xmlNodePtr child = node->xmlChildrenNode;
|
||||
do {
|
||||
if (child == NULL)
|
||||
break;
|
||||
if (xmlIsBlankNode(child))
|
||||
continue;
|
||||
if (xmlStrcmp(child->name, XMLSTR("http-headers")) == 0) {
|
||||
config_parse_http_headers(child->xmlChildrenNode, &(ret->http_headers));
|
||||
}
|
||||
} while ((child = child->next));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -215,6 +232,8 @@ void acl_release(acl_t * acl)
|
||||
if (acl->refcount)
|
||||
return;
|
||||
|
||||
config_clear_http_header(acl->http_headers);
|
||||
|
||||
free(acl);
|
||||
}
|
||||
|
||||
@ -349,3 +368,11 @@ ssize_t acl_get_max_connections_per_user(acl_t *acl)
|
||||
|
||||
return acl->max_connections_per_user;
|
||||
}
|
||||
|
||||
const ice_config_http_header_t *acl_get_http_headers(acl_t * acl)
|
||||
{
|
||||
if (!acl)
|
||||
return NULL;
|
||||
|
||||
return acl->http_headers;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "common/httpp/httpp.h"
|
||||
|
||||
#include "icecasttypes.h"
|
||||
#include "cfgfile.h"
|
||||
|
||||
typedef enum acl_policy_tag {
|
||||
/* Error on function call */
|
||||
@ -60,4 +61,7 @@ time_t acl_get_max_connection_duration(acl_t * acl);
|
||||
int acl_set_max_connections_per_user(acl_t * acl, size_t limit);
|
||||
ssize_t acl_get_max_connections_per_user(acl_t * acl);
|
||||
|
||||
/* HTTP specific functions */
|
||||
const ice_config_http_header_t *acl_get_http_headers(acl_t * acl);
|
||||
|
||||
#endif
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "source.h"
|
||||
#include "admin.h"
|
||||
#include "auth.h"
|
||||
#include "acl.h"
|
||||
|
||||
#define CATMODULE "util"
|
||||
|
||||
@ -662,6 +663,7 @@ static inline void _build_headers_loop(char **ret, size_t *len, const ice_conf
|
||||
*ret = r;
|
||||
}
|
||||
static inline char * _build_headers(int status, const char *allow, ice_config_t *config, source_t *source, client_t *client) {
|
||||
const ice_config_http_header_t *header;
|
||||
mount_proxy *mountproxy = NULL;
|
||||
char *ret = NULL;
|
||||
size_t len = 1;
|
||||
@ -675,8 +677,10 @@ static inline char * _build_headers(int status, const char *allow, ice_config_t
|
||||
_build_headers_loop(&ret, &len, config->http_headers, status, allow, client);
|
||||
if (mountproxy && mountproxy->http_headers)
|
||||
_build_headers_loop(&ret, &len, mountproxy->http_headers, status, allow, client);
|
||||
if (client && client->auth && client->auth->http_headers)
|
||||
_build_headers_loop(&ret, &len, client->auth->http_headers, status, allow, client);
|
||||
if (client && client->auth && (header = client->auth->http_headers))
|
||||
_build_headers_loop(&ret, &len, header, status, allow, client);
|
||||
if (client && client->acl && (header = acl_get_http_headers(client->acl)))
|
||||
_build_headers_loop(&ret, &len, header, status, allow, client);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user