0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 08:42:34 +01:00

ident: update to use new provider data API

This commit is contained in:
Elizabeth Myers 2016-04-04 03:39:22 -05:00
parent 74909c9ada
commit 751d39cc17

View file

@ -90,9 +90,7 @@ ident_connected(rb_fde_t *F __unused, int error, void *data)
if(auth == NULL) if(auth == NULL)
return; return;
query = auth->data[PROVIDER_IDENT]; if((query = get_provider_data(auth, PROVIDER_IDENT)) == NULL)
if(query == NULL)
return; return;
/* Check the error */ /* Check the error */
@ -131,9 +129,7 @@ read_ident_reply(rb_fde_t *F, void *data)
if(auth == NULL) if(auth == NULL)
return; return;
query = auth->data[PROVIDER_IDENT]; if((query = get_provider_data(auth, PROVIDER_IDENT)) == NULL)
if(query == NULL)
return; return;
len = rb_read(F, buf, IDENT_BUFSIZE); len = rb_read(F, buf, IDENT_BUFSIZE);
@ -178,7 +174,7 @@ read_ident_reply(rb_fde_t *F, void *data)
static void static void
client_fail(struct auth_client *auth, ident_message report) client_fail(struct auth_client *auth, ident_message report)
{ {
struct ident_query *query = auth->data[PROVIDER_IDENT]; struct ident_query *query = get_provider_data(auth, PROVIDER_IDENT);
if(query == NULL) if(query == NULL)
return; return;
@ -189,7 +185,7 @@ client_fail(struct auth_client *auth, ident_message report)
rb_close(query->F); rb_close(query->F);
rb_free(query); rb_free(query);
auth->data[PROVIDER_IDENT] = NULL; set_provider_data(auth, PROVIDER_IDENT, NULL);
auth->timeout[PROVIDER_IDENT] = 0; auth->timeout[PROVIDER_IDENT] = 0;
notice_client(auth->cid, messages[report]); notice_client(auth->cid, messages[report]);
@ -199,7 +195,7 @@ client_fail(struct auth_client *auth, ident_message report)
static void static void
client_success(struct auth_client *auth) client_success(struct auth_client *auth)
{ {
struct ident_query *query = auth->data[PROVIDER_IDENT]; struct ident_query *query = get_provider_data(auth, PROVIDER_IDENT);
if(query == NULL) if(query == NULL)
return; return;
@ -208,7 +204,7 @@ client_success(struct auth_client *auth)
rb_close(query->F); rb_close(query->F);
rb_free(query); rb_free(query);
auth->data[PROVIDER_IDENT] = NULL; set_provider_data(auth, PROVIDER_IDENT, NULL);
auth->timeout[PROVIDER_IDENT] = 0; auth->timeout[PROVIDER_IDENT] = 0;
notice_client(auth->cid, messages[REPORT_FOUND]); notice_client(auth->cid, messages[REPORT_FOUND]);
@ -288,7 +284,7 @@ ident_destroy(void)
/* Nuke all ident queries */ /* Nuke all ident queries */
RB_DICTIONARY_FOREACH(auth, &iter, auth_clients) RB_DICTIONARY_FOREACH(auth, &iter, auth_clients)
{ {
if(auth->data[PROVIDER_IDENT] != NULL) if(get_provider_data(auth, PROVIDER_IDENT) != NULL)
client_fail(auth, REPORT_FAIL); client_fail(auth, REPORT_FAIL);
} }
} }
@ -300,13 +296,11 @@ ident_start(struct auth_client *auth)
struct rb_sockaddr_storage l_addr, c_addr; struct rb_sockaddr_storage l_addr, c_addr;
int family = GET_SS_FAMILY(&auth->c_addr); int family = GET_SS_FAMILY(&auth->c_addr);
if(auth->data[PROVIDER_IDENT] != NULL) lrb_assert(get_provider_data(auth, PROVIDER_IDENT) == NULL);
{
set_provider_done(auth, PROVIDER_IDENT); /* for blacklists */ if(!ident_enable)
return true;
}
else if(!ident_enable)
{ {
rb_free(query);
notice_client(auth->cid, messages[REPORT_DISABLED]); notice_client(auth->cid, messages[REPORT_DISABLED]);
set_provider_done(auth, PROVIDER_IDENT); set_provider_done(auth, PROVIDER_IDENT);
return true; return true;
@ -314,7 +308,7 @@ ident_start(struct auth_client *auth)
notice_client(auth->cid, messages[REPORT_LOOKUP]); notice_client(auth->cid, messages[REPORT_LOOKUP]);
auth->data[PROVIDER_IDENT] = query; set_provider_data(auth, PROVIDER_IDENT, query);
auth->timeout[PROVIDER_IDENT] = rb_current_time() + ident_timeout; auth->timeout[PROVIDER_IDENT] = rb_current_time() + ident_timeout;
if((query->F = rb_socket(family, SOCK_STREAM, 0, "ident")) == NULL) if((query->F = rb_socket(family, SOCK_STREAM, 0, "ident")) == NULL)
@ -344,7 +338,7 @@ ident_start(struct auth_client *auth)
static void static void
ident_cancel(struct auth_client *auth) ident_cancel(struct auth_client *auth)
{ {
struct ident_query *query = auth->data[PROVIDER_IDENT]; struct ident_query *query = get_provider_data(auth, PROVIDER_IDENT);
if(query != NULL) if(query != NULL)
client_fail(auth, REPORT_FAIL); client_fail(auth, REPORT_FAIL);