255 |
|
return; |
256 |
|
|
257 |
|
/* At the moment, the resolver FD data is global .. */ |
258 |
< |
comm_setselect(&ResolverFileDescriptor, COMM_SELECT_READ, |
259 |
< |
res_readreply, NULL, 0); |
258 |
> |
comm_setselect(&ResolverFileDescriptor, COMM_SELECT_READ, res_readreply, NULL, 0); |
259 |
|
eventAdd("timeout_resolver", timeout_resolver, NULL, 1); |
260 |
|
} |
261 |
|
} |
278 |
|
restart_resolver(void) |
279 |
|
{ |
280 |
|
fd_close(&ResolverFileDescriptor); |
281 |
< |
eventDelete(timeout_resolver, NULL); /* -ddosen */ |
281 |
> |
eventDelete(timeout_resolver, NULL); |
282 |
|
start_resolver(); |
283 |
|
} |
284 |
|
|
308 |
|
request->sentat = CurrentTime; |
309 |
|
request->retries = 2; |
310 |
|
request->resend = 1; |
311 |
< |
request->timeout = 4; /* start at 4 and exponential inc. */ |
311 |
> |
request->timeout = 4; /* Start at 4 and exponential inc. */ |
312 |
|
request->state = REQ_IDLE; |
313 |
|
request->callback = callback; |
314 |
|
request->callback_ctx = ctx; |
454 |
|
const struct irc_ssaddr *addr, |
455 |
|
struct reslist *request) |
456 |
|
{ |
457 |
< |
char ipbuf[128]; |
459 |
< |
const unsigned char *cp; |
457 |
> |
char ipbuf[128] = ""; |
458 |
|
|
459 |
|
if (addr->ss.ss_family == AF_INET) |
460 |
|
{ |
461 |
|
const struct sockaddr_in *v4 = (const struct sockaddr_in *)addr; |
462 |
< |
cp = (const unsigned char *)&v4->sin_addr.s_addr; |
462 |
> |
const unsigned char *cp = (const unsigned char *)&v4->sin_addr.s_addr; |
463 |
|
|
464 |
|
snprintf(ipbuf, sizeof(ipbuf), "%u.%u.%u.%u.in-addr.arpa.", |
465 |
|
(unsigned int)(cp[3]), (unsigned int)(cp[2]), |
469 |
|
else if (addr->ss.ss_family == AF_INET6) |
470 |
|
{ |
471 |
|
const struct sockaddr_in6 *v6 = (const struct sockaddr_in6 *)addr; |
472 |
< |
cp = (const unsigned char *)&v6->sin6_addr.s6_addr; |
472 |
> |
const unsigned char *cp = (const unsigned char *)&v6->sin6_addr.s6_addr; |
473 |
|
|
474 |
|
snprintf(ipbuf, sizeof(ipbuf), |
475 |
|
"%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x." |
598 |
|
n = irc_dn_expand((unsigned char *)buf, (unsigned char *)eob, current, |
599 |
|
hostbuf, sizeof(hostbuf)); |
600 |
|
|
601 |
< |
if (n < 0 /* broken message */ || n == 0 /* no more answers left */) |
601 |
> |
if (n < 0 /* Broken message */ || n == 0 /* No more answers left */) |
602 |
|
return 0; |
603 |
|
|
604 |
|
hostbuf[HOSTLEN] = '\0'; |
607 |
|
* this code was not working on alpha due to that |
608 |
|
* (spotted by rodder/jailbird/dianora) |
609 |
|
*/ |
610 |
< |
current += (size_t) n; |
610 |
> |
current += (size_t)n; |
611 |
|
|
612 |
|
if (!(((char *)current + ANSWER_FIXED_SIZE) < eob)) |
613 |
|
break; |
634 |
|
return 0; |
635 |
|
|
636 |
|
/* |
637 |
< |
* check for invalid rd_length or too many addresses |
637 |
> |
* Check for invalid rd_length or too many addresses |
638 |
|
*/ |
639 |
|
if (rd_length != sizeof(struct in_addr)) |
640 |
|
return 0; |
665 |
|
return 0; |
666 |
|
|
667 |
|
n = irc_dn_expand((unsigned char *)buf, (unsigned char *)eob, |
668 |
< |
current, hostbuf, sizeof(hostbuf)); |
669 |
< |
if (n < 0 /* broken message */ || n == 0 /* no more answers left */) |
668 |
> |
current, hostbuf, sizeof(hostbuf)); |
669 |
> |
if (n < 0 /* Broken message */ || n == 0 /* No more answers left */) |
670 |
|
return 0; |
671 |
|
|
672 |
|
strlcpy(request->name, hostbuf, HOSTLEN + 1); |
737 |
|
return; |
738 |
|
|
739 |
|
/* |
740 |
< |
* convert DNS reply reader from Network byte order to CPU byte order. |
740 |
> |
* Convert DNS reply reader from Network byte order to CPU byte order. |
741 |
|
*/ |
742 |
|
header = (HEADER *)buf; |
743 |
|
header->ancount = ntohs(header->ancount); |
746 |
|
header->arcount = ntohs(header->arcount); |
747 |
|
|
748 |
|
/* |
749 |
< |
* check against possibly fake replies |
749 |
> |
* Check against possibly fake replies |
750 |
|
*/ |
751 |
|
if (!res_ourserver(&lsin)) |
752 |
|
return; |
753 |
|
|
754 |
|
/* |
755 |
< |
* response for an id which we have already received an answer for |
755 |
> |
* Response for an id which we have already received an answer for |
756 |
|
* just ignore this response. |
757 |
|
*/ |
758 |
|
if (!(request = find_id(header->id))) |
798 |
|
if (request->name == NULL) |
799 |
|
{ |
800 |
|
/* |
801 |
< |
* got a PTR response with no name, something bogus is happening |
801 |
> |
* Got a PTR response with no name, something bogus is happening |
802 |
|
* don't bother trying again, the client address doesn't resolve |
803 |
|
*/ |
804 |
|
(*request->callback)(request->callback_ctx, NULL, NULL); |
807 |
|
} |
808 |
|
|
809 |
|
/* |
810 |
< |
* Lookup the 'authoritative' name that we were given for the |
813 |
< |
* ip#. |
814 |
< |
* |
810 |
> |
* Lookup the 'authoritative' name that we were given for the ip#. |
811 |
|
*/ |
812 |
|
#ifdef IPV6 |
813 |
|
if (request->addr.ss.ss_family == AF_INET6) |
820 |
|
else |
821 |
|
{ |
822 |
|
/* |
823 |
< |
* got a name and address response, client resolved |
823 |
> |
* Got a name and address response, client resolved |
824 |
|
*/ |
825 |
|
(*request->callback)(request->callback_ctx, &request->addr, request->name); |
826 |
|
rem_request(request); |