37 |
|
#include "list.h" |
38 |
|
#include "s_auth.h" |
39 |
|
#include "s_conf.h" |
40 |
+ |
#include "balloc.h" |
41 |
|
#include "client.h" |
42 |
|
#include "common.h" |
43 |
|
#include "event.h" |
78 |
|
|
79 |
|
#define sendheader(c, i) sendto_one((c), HeaderMessages[(i)], me.name) |
80 |
|
|
81 |
+ |
static BlockHeap *auth_heap = NULL; |
82 |
|
static dlink_list auth_doing_list = { NULL, NULL, 0 }; |
83 |
|
|
84 |
|
static EVH timeout_auth_queries_event; |
96 |
|
void |
97 |
|
init_auth(void) |
98 |
|
{ |
99 |
+ |
auth_heap = BlockHeapCreate("auth", sizeof(struct AuthRequest), AUTH_HEAP_SIZE); |
100 |
|
auth_cb = register_callback("start_auth", start_auth); |
101 |
|
eventAddIsh("timeout_auth_queries_event", timeout_auth_queries_event, NULL, 1); |
102 |
|
} |
107 |
|
static struct AuthRequest * |
108 |
|
make_auth_request(struct Client *client) |
109 |
|
{ |
110 |
< |
struct AuthRequest *request = MyMalloc(sizeof(struct AuthRequest)); |
110 |
> |
struct AuthRequest *request = BlockHeapAlloc(auth_heap); |
111 |
|
|
112 |
|
client->localClient->auth = request; |
113 |
|
request->client = client; |
131 |
|
|
132 |
|
client->localClient->auth = NULL; |
133 |
|
dlinkDelete(&auth->node, &auth_doing_list); |
134 |
+ |
BlockHeapFree(auth_heap, auth); |
135 |
|
|
136 |
|
/* |
137 |
|
* When a client has auth'ed, we want to start reading what it sends |
151 |
|
|
152 |
|
/* |
153 |
|
* auth_dns_callback - called when resolver query finishes |
154 |
< |
* if the query resulted in a successful search, hp will contain |
155 |
< |
* a non-null pointer, otherwise hp will be null. |
154 |
> |
* if the query resulted in a successful search, name will contain |
155 |
> |
* a non-NULL pointer, otherwise name will be NULL. |
156 |
|
* set the client on it's way to a connection completion, regardless |
157 |
|
* of success of failure |
158 |
|
*/ |
371 |
|
assert(client != NULL); |
372 |
|
|
373 |
|
auth = make_auth_request(client); |
374 |
+ |
dlinkAdd(auth, &auth->node, &auth_doing_list); |
375 |
|
|
376 |
|
sendheader(client, REPORT_DO_DNS); |
377 |
|
|
383 |
|
start_auth_query(auth); |
384 |
|
} |
385 |
|
|
381 |
– |
dlinkAdd(auth, &auth->node, &auth_doing_list); |
382 |
– |
|
386 |
|
gethost_byaddr(auth_dns_callback, auth, &client->localClient->ip); |
387 |
|
|
388 |
|
return NULL; |
404 |
|
if (auth->timeout > CurrentTime) |
405 |
|
continue; |
406 |
|
|
404 |
– |
fd_close(&auth->fd); |
405 |
– |
|
407 |
|
if (IsDoingAuth(auth)) |
408 |
|
{ |
409 |
|
++ServerStats.is_abad; |
410 |
+ |
fd_close(&auth->fd); |
411 |
+ |
ClearAuth(auth); |
412 |
|
sendheader(auth->client, REPORT_FAIL_ID); |
413 |
|
} |
414 |
|
|
415 |
|
if (IsDNSPending(auth)) |
416 |
|
{ |
417 |
|
delete_resolver_queries(auth); |
418 |
+ |
ClearDNSPending(auth); |
419 |
|
sendheader(auth->client, REPORT_FAIL_DNS); |
420 |
|
} |
421 |
|
|
597 |
|
if (IsDNSPending(auth)) |
598 |
|
delete_resolver_queries(auth); |
599 |
|
|
600 |
< |
fd_close(&auth->fd); |
600 |
> |
if (IsDoingAuth(auth)) |
601 |
> |
fd_close(&auth->fd); |
602 |
> |
|
603 |
|
dlinkDelete(&auth->node, &auth_doing_list); |
604 |
< |
MyFree(auth); |
604 |
> |
BlockHeapFree(auth_heap, auth); |
605 |
|
} |