1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-09-22 04:15:54 -04:00

Feature: Added a unique ID to each auth_t.

This added a unique ID to each auth_t instance so it can be refered
to e.g. by the web interface for mangement functionallity. Mostly
stolen from connection.[ch].
See #2123
This commit is contained in:
Philipp Schafft 2014-12-19 10:50:52 +00:00
parent 25eec22692
commit 40bb04b644
2 changed files with 19 additions and 0 deletions

View File

@ -51,6 +51,19 @@ struct auth_stack_tag {
/* code */ /* code */
static mutex_t _auth_lock; /* protects _current_id */
static volatile unsigned long _current_id = 0;
static unsigned long _next_auth_id(void) {
unsigned long id;
thread_mutex_lock(&_auth_lock);
id = _current_id++;
thread_mutex_unlock(&_auth_lock);
return id;
}
static auth_client *auth_client_setup (client_t *client) static auth_client *auth_client_setup (client_t *client)
{ {
/* This will look something like "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" */ /* This will look something like "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" */
@ -424,6 +437,7 @@ auth_t *auth_get_authenticator(xmlNodePtr node)
thread_mutex_create(&auth->lock); thread_mutex_create(&auth->lock);
auth->refcount = 1; auth->refcount = 1;
auth->id = _next_auth_id();
auth->type = (char*)xmlGetProp(node, XMLSTR("type")); auth->type = (char*)xmlGetProp(node, XMLSTR("type"));
auth->role = (char*)xmlGetProp(node, XMLSTR("name")); auth->role = (char*)xmlGetProp(node, XMLSTR("name"));
@ -532,11 +546,13 @@ auth_t *auth_get_authenticator(xmlNodePtr node)
void auth_initialise (void) void auth_initialise (void)
{ {
thread_mutex_create(&_auth_lock);
} }
void auth_shutdown (void) void auth_shutdown (void)
{ {
ICECAST_LOG_INFO("Auth shutdown"); ICECAST_LOG_INFO("Auth shutdown");
thread_mutex_destroy(&_auth_lock);
} }
/* authstack functions */ /* authstack functions */

View File

@ -68,6 +68,9 @@ typedef struct auth_client_tag
typedef struct auth_tag typedef struct auth_tag
{ {
/* unique ID */
unsigned long id;
char *mount; char *mount;
/* filters */ /* filters */