authd/res: clean up some horribly indented code
This commit is contained in:
parent
0c0c9cf8fe
commit
fa2d5b83b4
1 changed files with 64 additions and 63 deletions
127
authd/res.c
127
authd/res.c
|
@ -322,21 +322,23 @@ static struct reslist *make_request(struct DNSQuery *query)
|
||||||
/*
|
/*
|
||||||
* retryfreq - determine how many queries to wait before resending
|
* retryfreq - determine how many queries to wait before resending
|
||||||
* if there have been that many consecutive timeouts
|
* if there have been that many consecutive timeouts
|
||||||
|
*
|
||||||
|
* This is a cubic backoff btw, if anyone didn't pick up on it. --Elizafox
|
||||||
*/
|
*/
|
||||||
static int retryfreq(int timeouts)
|
static int retryfreq(int timeouts)
|
||||||
{
|
{
|
||||||
switch (timeouts)
|
switch (timeouts)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
return 3;
|
return 3;
|
||||||
case 2:
|
case 2:
|
||||||
return 9;
|
return 9;
|
||||||
case 3:
|
case 3:
|
||||||
return 27;
|
return 27;
|
||||||
case 4:
|
case 4:
|
||||||
return 81;
|
return 81;
|
||||||
default:
|
default:
|
||||||
return 243;
|
return 243;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -565,17 +567,17 @@ static void resend_query(struct reslist *request)
|
||||||
|
|
||||||
switch (request->type)
|
switch (request->type)
|
||||||
{
|
{
|
||||||
case T_PTR:
|
case T_PTR:
|
||||||
do_query_number(NULL, &request->addr, request);
|
do_query_number(NULL, &request->addr, request);
|
||||||
break;
|
break;
|
||||||
case T_A:
|
case T_A:
|
||||||
#ifdef RB_IPV6
|
#ifdef RB_IPV6
|
||||||
case T_AAAA:
|
case T_AAAA:
|
||||||
#endif
|
#endif
|
||||||
do_query_name(NULL, request->name, request, request->type);
|
do_query_name(NULL, request->name, request, request->type);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -679,55 +681,54 @@ static int proc_answer(struct reslist *request, HEADER * header, char *buf, char
|
||||||
*/
|
*/
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case T_A:
|
case T_A:
|
||||||
if (request->type != T_A)
|
if (request->type != T_A)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check for invalid rd_length or too many addresses
|
* check for invalid rd_length or too many addresses
|
||||||
*/
|
*/
|
||||||
if (rd_length != sizeof(struct in_addr))
|
if (rd_length != sizeof(struct in_addr))
|
||||||
return (0);
|
return (0);
|
||||||
v4 = (struct sockaddr_in *)&request->addr;
|
v4 = (struct sockaddr_in *)&request->addr;
|
||||||
SET_SS_LEN(&request->addr, sizeof(struct sockaddr_in));
|
SET_SS_LEN(&request->addr, sizeof(struct sockaddr_in));
|
||||||
v4->sin_family = AF_INET;
|
v4->sin_family = AF_INET;
|
||||||
memcpy(&v4->sin_addr, current, sizeof(struct in_addr));
|
memcpy(&v4->sin_addr, current, sizeof(struct in_addr));
|
||||||
return (1);
|
return (1);
|
||||||
break;
|
break;
|
||||||
#ifdef RB_IPV6
|
#ifdef RB_IPV6
|
||||||
case T_AAAA:
|
case T_AAAA:
|
||||||
if (request->type != T_AAAA)
|
if (request->type != T_AAAA)
|
||||||
return (0);
|
return (0);
|
||||||
if (rd_length != sizeof(struct in6_addr))
|
if (rd_length != sizeof(struct in6_addr))
|
||||||
return (0);
|
return (0);
|
||||||
SET_SS_LEN(&request->addr, sizeof(struct sockaddr_in6));
|
SET_SS_LEN(&request->addr, sizeof(struct sockaddr_in6));
|
||||||
v6 = (struct sockaddr_in6 *)&request->addr;
|
v6 = (struct sockaddr_in6 *)&request->addr;
|
||||||
v6->sin6_family = AF_INET6;
|
v6->sin6_family = AF_INET6;
|
||||||
memcpy(&v6->sin6_addr, current, sizeof(struct in6_addr));
|
memcpy(&v6->sin6_addr, current, sizeof(struct in6_addr));
|
||||||
return (1);
|
return (1);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case T_PTR:
|
case T_PTR:
|
||||||
if (request->type != T_PTR)
|
if (request->type != T_PTR)
|
||||||
return (0);
|
return (0);
|
||||||
n = irc_dn_expand((unsigned char *)buf, (unsigned char *)eob, current,
|
n = irc_dn_expand((unsigned char *)buf, (unsigned char *)eob, current,
|
||||||
hostbuf, sizeof(hostbuf));
|
hostbuf, sizeof(hostbuf));
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
return (0); /* broken message */
|
return (0); /* broken message */
|
||||||
else if (n == 0)
|
else if (n == 0)
|
||||||
return (0); /* no more answers left */
|
return (0); /* no more answers left */
|
||||||
|
|
||||||
rb_strlcpy(request->name, hostbuf, IRCD_RES_HOSTLEN + 1);
|
rb_strlcpy(request->name, hostbuf, IRCD_RES_HOSTLEN + 1);
|
||||||
|
|
||||||
return (1);
|
return (1);
|
||||||
break;
|
break;
|
||||||
case T_CNAME:
|
case T_CNAME:
|
||||||
/* real answer will follow */
|
/* real answer will follow */
|
||||||
current += rd_length;
|
current += rd_length;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
default:
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue