82 |
|
|
83 |
#define auth_sendheader(c, i) sendto_one_notice((c), &me, "%s", HeaderMessages[(i)]) |
#define auth_sendheader(c, i) sendto_one_notice((c), &me, "%s", HeaderMessages[(i)]) |
84 |
|
|
|
static dlink_list auth_list; |
|
85 |
|
|
86 |
|
|
87 |
/*! \brief Allocate a new auth request. |
/*! \brief Allocate a new auth request. |
95 |
|
|
96 |
auth->client = client; |
auth->client = client; |
97 |
auth->client->connection->auth = auth; |
auth->client->connection->auth = auth; |
|
auth->timeout = CurrentTime + CONNECTTIMEOUT; |
|
98 |
|
|
99 |
return auth; |
return auth; |
100 |
} |
} |
101 |
|
|
102 |
/*! \brief Unlink auth request from auth_list and free memory |
/*! \brief Free memory |
103 |
* \param auth The allocated auth request to cleanup. |
* \param auth The allocated auth request to cleanup. |
104 |
*/ |
*/ |
105 |
static void |
static void |
106 |
auth_free(struct AuthRequest *auth) |
auth_free(struct AuthRequest *auth) |
107 |
{ |
{ |
|
assert(dlinkFind(&auth_list, auth)); |
|
|
|
|
|
dlinkDelete(&auth->node, &auth_list); |
|
|
|
|
|
assert(dlinkFind(&auth_list, auth) == NULL); |
|
|
|
|
108 |
auth->client = NULL; |
auth->client = NULL; |
109 |
xfree(auth); |
xfree(auth); |
110 |
} |
} |
456 |
v6 = (struct sockaddr_in6 *)&localaddr; |
v6 = (struct sockaddr_in6 *)&localaddr; |
457 |
v6->sin6_port = htons(0); |
v6->sin6_port = htons(0); |
458 |
|
|
459 |
comm_connect_tcp(auth->fd, &auth->client->ip, RFC1413_PORT, |
comm_connect_tcp(auth->fd, &auth->client->ip, RFC1413_PORT, &localaddr, |
460 |
&localaddr, auth_connect_callback, auth, |
auth_connect_callback, auth, 5); |
|
GlobalSetOptions.ident_timeout); |
|
461 |
} |
} |
462 |
|
|
463 |
/* |
/* |
475 |
assert(client_p); |
assert(client_p); |
476 |
assert(client_p->connection); |
assert(client_p->connection); |
477 |
|
|
|
dlinkAddTail(auth, &auth->node, &auth_list); |
|
|
|
|
478 |
auth_sendheader(client_p, REPORT_DO_DNS); |
auth_sendheader(client_p, REPORT_DO_DNS); |
479 |
|
|
480 |
auth->dns_pending = true; |
auth->dns_pending = true; |
509 |
|
|
510 |
auth_free(auth); |
auth_free(auth); |
511 |
} |
} |
|
|
|
|
/* |
|
|
* auth_timeout_queries - timeout resolver and identd requests |
|
|
* allow clients through if requests failed |
|
|
*/ |
|
|
static void |
|
|
auth_timeout_queries(void *notused) |
|
|
{ |
|
|
dlink_node *node, *node_next; |
|
|
|
|
|
DLINK_FOREACH_SAFE(node, node_next, auth_list.head) |
|
|
{ |
|
|
struct AuthRequest *auth = node->data; |
|
|
|
|
|
assert(auth->client); |
|
|
assert(auth->client->connection); |
|
|
|
|
|
if (auth->timeout > CurrentTime) |
|
|
break; |
|
|
|
|
|
if (auth->ident_pending == true) |
|
|
{ |
|
|
++ServerStats.is_abad; |
|
|
|
|
|
fd_close(auth->fd); |
|
|
auth->fd = NULL; |
|
|
auth->ident_pending = false; |
|
|
|
|
|
auth_sendheader(auth->client, REPORT_FAIL_ID); |
|
|
} |
|
|
|
|
|
if (auth->dns_pending == true) |
|
|
{ |
|
|
delete_resolver_queries(auth); |
|
|
auth->dns_pending = false; |
|
|
|
|
|
auth_sendheader(auth->client, REPORT_FAIL_DNS); |
|
|
} |
|
|
|
|
|
auth_release_client(auth); |
|
|
} |
|
|
} |
|
|
|
|
|
/* auth_init |
|
|
* |
|
|
* Initialise the auth code |
|
|
*/ |
|
|
void |
|
|
auth_init(void) |
|
|
{ |
|
|
static struct event timeout_auth_queries = |
|
|
{ |
|
|
.name = "auth_timeout_queries", |
|
|
.handler = auth_timeout_queries, |
|
|
.when = 1 |
|
|
}; |
|
|
|
|
|
event_add(&timeout_auth_queries, NULL); |
|
|
} |
|