Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
spr0cketeer
Icecast-Server
Commits
c71aa0a0
Commit
c71aa0a0
authored
Nov 04, 2018
by
Philipp Schafft
🦁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feature: Support per-<acl> HTTP headers
parent
6f28d3fd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
2 deletions
+37
-2
src/acl.c
src/acl.c
+27
-0
src/acl.h
src/acl.h
+4
-0
src/util.c
src/util.c
+6
-2
No files found.
src/acl.c
View file @
c71aa0a0
...
...
@@ -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
;
}
src/acl.h
View file @
c71aa0a0
...
...
@@ -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
src/util.c
View file @
c71aa0a0
...
...
@@ -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
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment