blacklist: update for new provider data API
This commit is contained in:
parent
9155a94867
commit
e78a87f3c4
1 changed files with 15 additions and 13 deletions
|
@ -231,13 +231,13 @@ blacklist_dns_callback(const char *result, bool status, query_type type, void *d
|
||||||
struct blacklist *bl;
|
struct blacklist *bl;
|
||||||
struct auth_client *auth;
|
struct auth_client *auth;
|
||||||
|
|
||||||
if (bllookup == NULL || bllookup->auth == NULL)
|
lrb_assert(bllookup != NULL);
|
||||||
return;
|
lrb_assert(bllookup->auth != NULL);
|
||||||
|
|
||||||
bl = bllookup->bl;
|
bl = bllookup->bl;
|
||||||
auth = bllookup->auth;
|
auth = bllookup->auth;
|
||||||
bluser = auth->data[PROVIDER_BLACKLIST];
|
|
||||||
if(bluser == NULL)
|
if((bluser = get_provider_data(auth, PROVIDER_BLACKLIST)) == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (result != NULL && status && blacklist_check_reply(bllookup, result))
|
if (result != NULL && status && blacklist_check_reply(bllookup, result))
|
||||||
|
@ -260,7 +260,7 @@ blacklist_dns_callback(const char *result, bool status, query_type type, void *d
|
||||||
notice_client(auth->cid, "*** IP not found in DNS blacklist%s",
|
notice_client(auth->cid, "*** IP not found in DNS blacklist%s",
|
||||||
rb_dlink_list_length(&blacklist_list) > 1 ? "s" : "");
|
rb_dlink_list_length(&blacklist_list) > 1 ? "s" : "");
|
||||||
rb_free(bluser);
|
rb_free(bluser);
|
||||||
auth->data[PROVIDER_BLACKLIST] = NULL;
|
set_provider_data(auth, PROVIDER_BLACKLIST, NULL);
|
||||||
auth->timeout[PROVIDER_BLACKLIST] = 0;
|
auth->timeout[PROVIDER_BLACKLIST] = 0;
|
||||||
provider_done(auth, PROVIDER_BLACKLIST);
|
provider_done(auth, PROVIDER_BLACKLIST);
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ static void
|
||||||
initiate_blacklist_dnsquery(struct blacklist *bl, struct auth_client *auth)
|
initiate_blacklist_dnsquery(struct blacklist *bl, struct auth_client *auth)
|
||||||
{
|
{
|
||||||
struct blacklist_lookup *bllookup = rb_malloc(sizeof(struct blacklist_lookup));
|
struct blacklist_lookup *bllookup = rb_malloc(sizeof(struct blacklist_lookup));
|
||||||
struct blacklist_user *bluser = auth->data[PROVIDER_BLACKLIST];
|
struct blacklist_user *bluser = get_provider_data(auth, PROVIDER_BLACKLIST);
|
||||||
char buf[IRCD_RES_HOSTLEN + 1];
|
char buf[IRCD_RES_HOSTLEN + 1];
|
||||||
int aftype;
|
int aftype;
|
||||||
|
|
||||||
|
@ -281,7 +281,10 @@ initiate_blacklist_dnsquery(struct blacklist *bl, struct auth_client *auth)
|
||||||
if((aftype == AF_INET && (bl->iptype & IPTYPE_IPV4) == 0) ||
|
if((aftype == AF_INET && (bl->iptype & IPTYPE_IPV4) == 0) ||
|
||||||
(aftype == AF_INET6 && (bl->iptype & IPTYPE_IPV6) == 0))
|
(aftype == AF_INET6 && (bl->iptype & IPTYPE_IPV6) == 0))
|
||||||
/* Incorrect blacklist type for this IP... */
|
/* Incorrect blacklist type for this IP... */
|
||||||
|
{
|
||||||
|
rb_free(bllookup);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
build_rdns(buf, sizeof(buf), &auth->c_addr, bl->host);
|
build_rdns(buf, sizeof(buf), &auth->c_addr, bl->host);
|
||||||
|
|
||||||
|
@ -294,7 +297,7 @@ initiate_blacklist_dnsquery(struct blacklist *bl, struct auth_client *auth)
|
||||||
static inline void
|
static inline void
|
||||||
lookup_all_blacklists(struct auth_client *auth)
|
lookup_all_blacklists(struct auth_client *auth)
|
||||||
{
|
{
|
||||||
struct blacklist_user *bluser = auth->data[PROVIDER_BLACKLIST];
|
struct blacklist_user *bluser = get_provider_data(auth, PROVIDER_BLACKLIST);
|
||||||
rb_dlink_node *ptr;
|
rb_dlink_node *ptr;
|
||||||
|
|
||||||
notice_client(auth->cid, "*** Checking your IP against DNS blacklist%s",
|
notice_client(auth->cid, "*** Checking your IP against DNS blacklist%s",
|
||||||
|
@ -338,8 +341,7 @@ delete_all_blacklists(void)
|
||||||
static bool
|
static bool
|
||||||
blacklists_start(struct auth_client *auth)
|
blacklists_start(struct auth_client *auth)
|
||||||
{
|
{
|
||||||
if(auth->data[PROVIDER_BLACKLIST] != NULL)
|
lrb_assert(get_provider_data(auth, PROVIDER_BLACKLIST) == NULL);
|
||||||
return true;
|
|
||||||
|
|
||||||
if(!rb_dlink_list_length(&blacklist_list))
|
if(!rb_dlink_list_length(&blacklist_list))
|
||||||
{
|
{
|
||||||
|
@ -348,7 +350,7 @@ blacklists_start(struct auth_client *auth)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auth->data[PROVIDER_BLACKLIST] = rb_malloc(sizeof(struct blacklist_user));
|
set_provider_data(auth, PROVIDER_BLACKLIST, rb_malloc(sizeof(struct blacklist_user)));
|
||||||
|
|
||||||
if(is_provider_done(auth, PROVIDER_RDNS) && is_provider_done(auth, PROVIDER_IDENT))
|
if(is_provider_done(auth, PROVIDER_RDNS) && is_provider_done(auth, PROVIDER_IDENT))
|
||||||
/* This probably can't happen but let's handle this case anyway */
|
/* This probably can't happen but let's handle this case anyway */
|
||||||
|
@ -362,7 +364,7 @@ blacklists_start(struct auth_client *auth)
|
||||||
static void
|
static void
|
||||||
blacklists_initiate(struct auth_client *auth, provider_t provider)
|
blacklists_initiate(struct auth_client *auth, provider_t provider)
|
||||||
{
|
{
|
||||||
struct blacklist_user *bluser = auth->data[PROVIDER_BLACKLIST];
|
struct blacklist_user *bluser = get_provider_data(auth, PROVIDER_BLACKLIST);
|
||||||
|
|
||||||
lrb_assert(provider != PROVIDER_BLACKLIST);
|
lrb_assert(provider != PROVIDER_BLACKLIST);
|
||||||
lrb_assert(!is_provider_done(auth, PROVIDER_BLACKLIST));
|
lrb_assert(!is_provider_done(auth, PROVIDER_BLACKLIST));
|
||||||
|
@ -382,7 +384,7 @@ static void
|
||||||
blacklists_cancel(struct auth_client *auth)
|
blacklists_cancel(struct auth_client *auth)
|
||||||
{
|
{
|
||||||
rb_dlink_node *ptr, *nptr;
|
rb_dlink_node *ptr, *nptr;
|
||||||
struct blacklist_user *bluser = auth->data[PROVIDER_BLACKLIST];
|
struct blacklist_user *bluser = get_provider_data(auth, PROVIDER_BLACKLIST);
|
||||||
|
|
||||||
if(bluser == NULL)
|
if(bluser == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -404,7 +406,7 @@ blacklists_cancel(struct auth_client *auth)
|
||||||
}
|
}
|
||||||
|
|
||||||
rb_free(bluser);
|
rb_free(bluser);
|
||||||
auth->data[PROVIDER_BLACKLIST] = NULL;
|
set_provider_data(auth, PROVIDER_BLACKLIST, NULL);
|
||||||
auth->timeout[PROVIDER_BLACKLIST] = 0;
|
auth->timeout[PROVIDER_BLACKLIST] = 0;
|
||||||
provider_done(auth, PROVIDER_BLACKLIST);
|
provider_done(auth, PROVIDER_BLACKLIST);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue