mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2025-02-02 15:07:36 -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 */
|
/* mount specific functons */
|
||||||
time_t max_connection_duration;
|
time_t max_connection_duration;
|
||||||
size_t max_connections_per_user;
|
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 */
|
/* some string util functions */
|
||||||
@ -195,6 +198,20 @@ acl_t *acl_new_from_xml_node(xmlNodePtr node)
|
|||||||
prop = prop->next;
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,6 +232,8 @@ void acl_release(acl_t * acl)
|
|||||||
if (acl->refcount)
|
if (acl->refcount)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
config_clear_http_header(acl->http_headers);
|
||||||
|
|
||||||
free(acl);
|
free(acl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,3 +368,11 @@ ssize_t acl_get_max_connections_per_user(acl_t *acl)
|
|||||||
|
|
||||||
return acl->max_connections_per_user;
|
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 "common/httpp/httpp.h"
|
||||||
|
|
||||||
#include "icecasttypes.h"
|
#include "icecasttypes.h"
|
||||||
|
#include "cfgfile.h"
|
||||||
|
|
||||||
typedef enum acl_policy_tag {
|
typedef enum acl_policy_tag {
|
||||||
/* Error on function call */
|
/* 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);
|
int acl_set_max_connections_per_user(acl_t * acl, size_t limit);
|
||||||
ssize_t acl_get_max_connections_per_user(acl_t * acl);
|
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
|
#endif
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
#include "source.h"
|
#include "source.h"
|
||||||
#include "admin.h"
|
#include "admin.h"
|
||||||
#include "auth.h"
|
#include "auth.h"
|
||||||
|
#include "acl.h"
|
||||||
|
|
||||||
#define CATMODULE "util"
|
#define CATMODULE "util"
|
||||||
|
|
||||||
@ -662,6 +663,7 @@ static inline void _build_headers_loop(char **ret, size_t *len, const ice_conf
|
|||||||
*ret = r;
|
*ret = r;
|
||||||
}
|
}
|
||||||
static inline char * _build_headers(int status, const char *allow, ice_config_t *config, source_t *source, client_t *client) {
|
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;
|
mount_proxy *mountproxy = NULL;
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
size_t len = 1;
|
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);
|
_build_headers_loop(&ret, &len, config->http_headers, status, allow, client);
|
||||||
if (mountproxy && mountproxy->http_headers)
|
if (mountproxy && mountproxy->http_headers)
|
||||||
_build_headers_loop(&ret, &len, mountproxy->http_headers, status, allow, client);
|
_build_headers_loop(&ret, &len, mountproxy->http_headers, status, allow, client);
|
||||||
if (client && client->auth && client->auth->http_headers)
|
if (client && client->auth && (header = client->auth->http_headers))
|
||||||
_build_headers_loop(&ret, &len, client->auth->http_headers, status, allow, client);
|
_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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user