mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-12-21 10:20:42 +00:00
Fix IPv6 address checks
- SOCK_cmpaddr returned inverted truth for IPv6 addresses. This would prevent making a connection. - Account for IPv6 address resolution. (bug: 5a627482)
This commit is contained in:
parent
cf30fd1bd7
commit
a1a58143ec
1 changed files with 14 additions and 6 deletions
20
src/i_tcp.c
20
src/i_tcp.c
|
@ -427,7 +427,7 @@ static boolean SOCK_cmpaddr(mysockaddr_t *a, mysockaddr_t *b, UINT8 mask)
|
||||||
&& (b->ip4.sin_port == 0 || (a->ip4.sin_port == b->ip4.sin_port));
|
&& (b->ip4.sin_port == 0 || (a->ip4.sin_port == b->ip4.sin_port));
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
else if (b->any.sa_family == AF_INET6)
|
else if (b->any.sa_family == AF_INET6)
|
||||||
return memcmp(&a->ip6.sin6_addr, &b->ip6.sin6_addr, sizeof(b->ip6.sin6_addr))
|
return !memcmp(&a->ip6.sin6_addr, &b->ip6.sin6_addr, sizeof(b->ip6.sin6_addr))
|
||||||
&& (b->ip6.sin6_port == 0 || (a->ip6.sin6_port == b->ip6.sin6_port));
|
&& (b->ip6.sin6_port == 0 || (a->ip6.sin6_port == b->ip6.sin6_port));
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
|
@ -1156,6 +1156,7 @@ static SINT8 SOCK_NetMakeNodewPort(const char *address, const char *port)
|
||||||
SINT8 newnode = -1;
|
SINT8 newnode = -1;
|
||||||
struct my_addrinfo *ai = NULL, *runp, hints;
|
struct my_addrinfo *ai = NULL, *runp, hints;
|
||||||
int gaie;
|
int gaie;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
if (!port || !port[0])
|
if (!port || !port[0])
|
||||||
port = DEFAULTPORT;
|
port = DEFAULTPORT;
|
||||||
|
@ -1183,13 +1184,20 @@ static SINT8 SOCK_NetMakeNodewPort(const char *address, const char *port)
|
||||||
|
|
||||||
while (runp != NULL)
|
while (runp != NULL)
|
||||||
{
|
{
|
||||||
// find ip of the server
|
// test ip address of server
|
||||||
if (sendto(mysockets[0], NULL, 0, 0, runp->ai_addr, runp->ai_addrlen) == 0)
|
for (i = 0; i < mysocketses; ++i)
|
||||||
{
|
{
|
||||||
memcpy(&clientaddress[newnode], runp->ai_addr, runp->ai_addrlen);
|
if (runp->ai_addr->sa_family == myfamily[i])
|
||||||
break;
|
{
|
||||||
|
memcpy(&clientaddress[newnode], runp->ai_addr, runp->ai_addrlen);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
runp = runp->ai_next;
|
|
||||||
|
if (i < mysocketses)
|
||||||
|
runp = runp->ai_next;
|
||||||
|
else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
I_freeaddrinfo(ai);
|
I_freeaddrinfo(ai);
|
||||||
return newnode;
|
return newnode;
|
||||||
|
|
Loading…
Reference in a new issue