Commit 176b9f7e authored by Karl Heyes's avatar Karl Heyes

Auth update. Have each auth_t has its own queue of requests and thread to process

them. Each listener connection for each request is checked as connected before
performing the request (so that time isn't wasted on slow authentication). Various
name/comment cleanups as well.

svn path=/icecast/trunk/icecast/; revision=13583
parent 620c51f6
This diff is collapsed.
......@@ -53,29 +53,38 @@ typedef struct auth_tag
/* Authenticate using the given username and password */
auth_result (*authenticate)(auth_client *aclient);
auth_result (*release_client)(auth_client *auth_user);
auth_result (*release_listener)(auth_client *auth_user);
/* callbacks to specific auth for notifying auth server on source
* startup or shutdown
*/
/* auth handler for source startup, no client passed as it may disappear */
void (*stream_start)(auth_client *auth_user);
/* auth handler for source exit, no client passed as it may disappear */
void (*stream_end)(auth_client *auth_user);
/* auth state-specific free call */
void (*free)(struct auth_tag *self);
auth_result (*adduser)(struct auth_tag *auth, const char *username, const char *password);
auth_result (*deleteuser)(struct auth_tag *auth, const char *username);
auth_result (*listuser)(struct auth_tag *auth, xmlNodePtr srcnode);
mutex_t lock;
int running;
int refcount;
int allow_duplicate_users;
thread_type *thread;
/* per-auth queue for clients */
auth_client *head, **tailp;
int pending_count;
void *state;
char *type;
} auth_t;
void add_client (const char *mount, client_t *client);
int release_client (client_t *client);
void auth_add_listener (const char *mount, client_t *client);
int auth_release_listener (client_t *client);
void auth_initialise (void);
void auth_shutdown (void);
......@@ -91,7 +100,7 @@ void auth_stream_end (struct _mount_proxy *mountinfo, const char *mount);
/* called from auth thread, after the client has successfully authenticated
* and requires adding to source or fserve. */
int auth_postprocess_client (auth_client *auth_user);
int auth_postprocess_listener (auth_client *auth_user);
#endif
......
......@@ -162,7 +162,7 @@ static int handle_returned_data (void *ptr, size_t size, size_t nmemb, void *str
}
static auth_result url_remove_client (auth_client *auth_user)
static auth_result url_remove_listener (auth_client *auth_user)
{
client_t *client = auth_user->client;
auth_t *auth = client->auth;
......@@ -242,7 +242,7 @@ static auth_result url_remove_client (auth_client *auth_user)
}
static auth_result url_add_client (auth_client *auth_user)
static auth_result url_add_listener (auth_client *auth_user)
{
client_t *client = auth_user->client;
auth_t *auth = client->auth;
......@@ -463,8 +463,8 @@ int auth_get_url_auth (auth_t *authenticator, config_options_t *options)
{
auth_url *url_info;
authenticator->authenticate = url_add_client;
authenticator->release_client = url_remove_client;
authenticator->authenticate = url_add_listener;
authenticator->release_listener = url_remove_listener;
authenticator->free = auth_url_clear;
authenticator->adduser = auth_url_adduser;
......
......@@ -675,6 +675,8 @@ static void _parse_mount(xmlDocPtr doc, xmlNodePtr node,
config_clear_mount (mount);
return;
}
if (mount->auth)
mount->auth->mount = strdup (mount->mountname);
while(current) {
last = current;
current = current->next;
......
......@@ -93,7 +93,7 @@ void client_destroy(client_t *client)
client->refbuf = NULL;
}
if (release_client (client))
if (auth_release_listener (client))
return;
/* write log entry if ip is set (some things don't set it, like outgoing
......
......@@ -882,7 +882,7 @@ static void _handle_get_request (client_t *client, char *passed_uri)
return;
}
add_client (uri, client);
auth_add_listener (uri, client);
if (uri != passed_uri) free (uri);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment