mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2025-02-02 15:07:36 -05: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:
parent
25eec22692
commit
40bb04b644
16
src/auth.c
16
src/auth.c
@ -51,6 +51,19 @@ struct auth_stack_tag {
|
||||
|
||||
/* 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)
|
||||
{
|
||||
/* This will look something like "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" */
|
||||
@ -424,6 +437,7 @@ auth_t *auth_get_authenticator(xmlNodePtr node)
|
||||
|
||||
thread_mutex_create(&auth->lock);
|
||||
auth->refcount = 1;
|
||||
auth->id = _next_auth_id();
|
||||
auth->type = (char*)xmlGetProp(node, XMLSTR("type"));
|
||||
auth->role = (char*)xmlGetProp(node, XMLSTR("name"));
|
||||
|
||||
@ -532,11 +546,13 @@ auth_t *auth_get_authenticator(xmlNodePtr node)
|
||||
|
||||
void auth_initialise (void)
|
||||
{
|
||||
thread_mutex_create(&_auth_lock);
|
||||
}
|
||||
|
||||
void auth_shutdown (void)
|
||||
{
|
||||
ICECAST_LOG_INFO("Auth shutdown");
|
||||
thread_mutex_destroy(&_auth_lock);
|
||||
}
|
||||
|
||||
/* authstack functions */
|
||||
|
@ -68,6 +68,9 @@ typedef struct auth_client_tag
|
||||
|
||||
typedef struct auth_tag
|
||||
{
|
||||
/* unique ID */
|
||||
unsigned long id;
|
||||
|
||||
char *mount;
|
||||
|
||||
/* filters */
|
||||
|
Loading…
Reference in New Issue
Block a user