1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-10 21:23:12 +02:00

+ fixing a IPv6 bug

+- Made Inet_si2p (sin to presensation), fixing the "*", bug, some debugging
+  fixes, fixed a lot of IPv6 bugs, hopefully - thanks to JK for borrowing
+  his box
This commit is contained in:
stskeeps
2001-09-09 20:09:59 +00:00
parent ee9f9d9af0
commit 1e438f3560
6 changed files with 62 additions and 67 deletions
+4 -1
View File
@@ -842,4 +842,7 @@ seen. gmtime warning still there
- Some more VFS/PHTML fixes, it actually works now, thanks to butter
- Fixed a IPv6 bindip problem
- Removed bsd.c and made socket.c, moving signal stuff to ircd.c, possible
fixing a IPv6 bug
fixing a IPv6 bug
- Made Inet_si2p (sin to presensation), fixing the "*", bug, some debugging
fixes, fixed a lot of IPv6 bugs, hopefully - thanks to JK for borrowing
his box
+7
View File
@@ -346,6 +346,13 @@ extern char *inetntop(int af, const void *in, char *local_dummy,
size_t the_size);
#endif
/*
* socket.c
*/
char *Inet_si2p(struct SOCKADDR_IN *sin);
char *Inet_si2pB(struct SOCKADDR_IN *sin, char *buf);
/*
* CommandHash -Stskeeps
*/
+4 -23
View File
@@ -507,8 +507,8 @@ static int do_query_number(lp, numb, rptr)
cp = (u_char *)numb->s6_addr;
if (cp[0] == 0 && cp[1] == 0 && cp[2] == 0 && cp[3] == 0 && cp[4] == 0
&& cp[5] == 0 && cp[6] == 0 && cp[7] == 0 && cp[8] == 0
&& cp[9] == 0 && ((cp[10] == 0 && cp[11] == 0) || (cp[10] == 0xff
&& cp[11] == 0xff)))
&& cp[9] == 0 && cp[10] == 0xff
&& cp[11] == 0xff)
{
(void)ircsprintf(ipbuf, "%u.%u.%u.%u.in-addr.arpa.",
(u_int)(cp[15]), (u_int)(cp[14]),
@@ -546,30 +546,11 @@ static int do_query_number(lp, numb, rptr)
{
rptr = make_request(lp);
rptr->type = T_PTR;
#ifndef _WIN32
#ifdef INET6
bcopy(numb->s6_addr, rptr->addr.s6_addr, IN6ADDRSZ);
bcopy((char *)numb->s6_addr,
(char *)&rptr->he.h_addr, sizeof(struct in6_addr));
#else
rptr->addr.s_addr = numb->s_addr;
bcopy((char *)&numb->s_addr,
(char *)&rptr->he.h_addr, sizeof(struct in_addr));
#endif
bcopy(numb->S_ADDR, rptr->addr.S_ADDR, sizeof(rptr->addr.S_ADDR));
rptr->he.h_length = sizeof(struct IN_ADDR);
#else
rptr->addr.S_ADDR = numb->S_ADDR;
rptr->he->h_length = sizeof(struct IN_ADDR);
/* rptr->addr.s_addr = numb->s_addr;
bcopy((char *)&numb->s_addr,
(char *)&rptr->he->h_addr, sizeof(struct in_addr));
rptr->he->h_length = sizeof(struct IN_ADDR);*/
#endif
}
#ifndef _WIN32
return (query_name(ipbuf, C_IN, T_PTR, rptr));
return (query_name(ipbuf, C_IN, T_PTR, rptr));
#else
rptr->id = _beginthread(async_dns, 0, (void *)rptr);
rptr->sends++;
+7 -36
View File
@@ -657,24 +657,6 @@ void write_pidfile()
#endif
}
#ifdef INET6
#undef IN6_IS_ADDR_LOOPBACK
int IN6_IS_ADDR_LOOPBACK(u_int32_t * f)
{
if ((*f == 0) && (*(f + 1) == 0)
&& (*(f + 2) == 0) && (*(f + 3) == htonl(1)))
return 1;
return 0;
}
#define IN6_IS_ADDR_LOOPBACK(a) \
((u_int32_t) (a)[0] == 0) && \
((u_int32_t) (a)[1] == 0) && \
((u_int32_t) (a)[2] == 0) && \
((u_int32_t) (a)[3] == htonl(1))
#endif
/*
* Initialize the various name strings used to store hostnames. This is set
* from either the server's sockhost (if client fd is a tty or localhost)
@@ -703,21 +685,16 @@ static int check_init(cptr, sockn)
report_error("connect failure: %s %s", cptr);
return -1;
}
#ifdef INET6
inetntop(AF_INET6, (char *)&sk.sin6_addr, sockn, MYDUMMY_SIZE);
#else
(void)strcpy(sockn, (char *)inetntoa((char *)&sk.SIN_ADDR));
#endif
(void)strcpy(sockn, (char *)Inet_si2p(&sk));
#ifdef INET6
#undef IN6_IS_ADDR_LOOPBACK
if (IN6_IS_ADDR_LOOPBACK(&sk.SIN_ADDR))
#else
if (inet_netof(sk.SIN_ADDR) == IN_LOOPBACKNET)
#endif
{
cptr->hostp = NULL;
strncpyzt(sockn, me.sockhost, HOSTLEN);
strncpyzt(sockn, "localhost", HOSTLEN);
}
bcopy((char *)&sk.SIN_ADDR, (char *)&cptr->ip, sizeof(struct IN_ADDR));
@@ -1231,13 +1208,7 @@ add_con_refuse:
/* Copy ascii address to 'sockhost' just in case. Then we
* have something valid to put into error messages...
*/
#ifdef INET6
inetntop(AF_INET6, (char *)&addr.sin6_addr, mydummy,
MYDUMMY_SIZE);
get_sockhost(acptr, (char *)mydummy);
#else
get_sockhost(acptr, (char *)inetntoa((char *)&addr.SIN_ADDR));
#endif
get_sockhost(acptr, Inet_si2p(&addr));
bcopy((char *)&addr.SIN_ADDR, (char *)&acptr->ip, sizeof(struct IN_ADDR));
j = 1;
for (i = LastSlot; i >= 0; i--)
@@ -1260,7 +1231,7 @@ add_con_refuse:
}
}
if ((bconf = Find_ban(inetntoa((char *)&acptr->ip), CONF_BAN_IP)))
if ((bconf = Find_ban(acptr->sockhost, CONF_BAN_IP)))
{
ircsprintf(zlinebuf,
"ERROR :Closing Link: [%s] (You are not welcome on "
@@ -1288,8 +1259,7 @@ add_con_refuse:
}
lin.flags = ASYNC_CLIENT;
lin.value.cptr = acptr;
Debug((DEBUG_DNS, "lookup %s", inetntoa((char *)&addr.SIN_ADDR)));
Debug((DEBUG_DNS, "lookup %s", acptr->sockhost));
acptr->hostp = gethost_byaddr((char *)&acptr->ip, &lin);
if (!acptr->hostp)
@@ -2524,8 +2494,9 @@ void do_dns_async(id)
del_queries((char *)cptr);
ClearDNS(cptr);
cptr->hostp = hp;
if (SHOWCONNECTINFO)
sendto_one(cptr, REPORT_FIN_DNS);
sendto_one(cptr, cptr->hostp ? REPORT_FIN_DNS : REPORT_FAIL_DNS);
if (!DoingAuth(cptr))
SetAccess(cptr);
}
+10 -7
View File
@@ -81,6 +81,8 @@ static int dead_link(to, notice)
aClient *to;
char *notice;
{
char *error = NULL;
to->flags |= FLAGS_DEADSOCKET;
/*
* If because of BUFFERPOOL problem then clean dbuf's now so that
@@ -88,15 +90,16 @@ static int dead_link(to, notice)
*/
DBufClear(&to->recvQ);
DBufClear(&to->sendQ);
#ifndef _WIN32
error = strerror(errno);
#else
error = strerror(WSAGetLastError());
#endif
if (!IsPerson(to) && !IsUnknown(to) && !(to->flags & FLAGS_CLOSING))
(void)sendto_failops_whoare_opers(notice, get_client_name(to, FALSE),
#ifndef _WIN32
strerror(errno));
#else
strerror(WSAGetLastError()));
#endif
Debug((DEBUG_ERROR, notice, get_client_name(to, FALSE)));
error);
Debug((DEBUG_ERROR, notice, get_client_name(to, FALSE), error));
return -1;
}
+30
View File
@@ -172,3 +172,33 @@ int deliver_it(aClient *cptr, char *str, int len)
return (retval);
}
char *Inet_si2pB(struct SOCKADDR_IN *sin, char *buf)
{
#ifdef INET6
u_char *cp;
cp = (u_char *)sin->SIN_ADDR.s6_addr;
if (cp[0] == 0 && cp[1] == 0 && cp[2] == 0 && cp[3] == 0 && cp[4] == 0
&& cp[5] == 0 && cp[6] == 0 && cp[7] == 0 && cp[8] == 0
&& cp[9] == 0 && cp[10] == 0xff
&& cp[11] == 0xff)
{
(void)ircsprintf(buf, "%u.%u.%u.%u",
(u_int)(cp[12]), (u_int)(cp[13]),
(u_int)(cp[14]), (u_int)(cp[15]));
return (buf);
}
#endif
return ((char *)inetntop(sin->SIN_FAMILY, (void *)&sin->SIN_ADDR, buf, sizeof(buf)));
}
char *Inet_si2p(struct SOCKADDR_IN *sin)
{
static char buf[256];
return (Inet_si2pB(sin, buf));
}