mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-26 22:40:50 +00:00
Fix partial broken connection to IPv6 / q2ded listening on IPv6 addrs.
This was introduced in 220f0a9
as fix. The submitter, @DanielGibson and
myself missunderstood the code:
* If net_interface is NULL (which in the current code can never happen),
an empty string (the user sets the `ip` cvar to an empty string) or
"localhost" (the default) we want to set `Host` to the unspecified
address. getaddrinfo() will return in6addr_any fot it and we'll bind
to any available address.
* "0.0.0.0" isn't the IPv4 any address, it's the unspecified address.
Thats correct and the code was working fine for IPv4. But at least
the submitter and me confused it with the any address (which is
0.0.0.0/0). So setting `Host` in the IPv6 to `::/128` (the lowest IPv6
address) or `::/0` (any IPv6) is wrong, it must be `::` (unspecified
IPv6 address)!
Have a look at RFC 3493 for the details.
I'm doing the change only for the Unix code path, not for Windows. For
some reason everything besides `::/128` or `::1` doesn't really work on
Windows and I don't know why. Even more scary is that changes to the
IPv6 case also break IPv4 sockets. Since the whole network.c for Windows
is confuse and rather hard to understand (there's still IPX support in
it) I'm leaving things as they are.
This commit is contained in:
parent
9f7c5c205b
commit
16ea835aa1
2 changed files with 3 additions and 5 deletions
|
@ -824,7 +824,7 @@ NET_Socket(char *net_interface, int port, netsrc_t type, int family)
|
|||
if (!net_interface || !net_interface[0] ||
|
||||
!Q_stricmp(net_interface, "localhost"))
|
||||
{
|
||||
Host = (family == AF_INET6) ? "::/128" : "0.0.0.0";
|
||||
Host = (family == AF_INET6) ? "::" : "0.0.0.0";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -848,8 +848,7 @@ NET_Socket(char *net_interface, int port, netsrc_t type, int family)
|
|||
|
||||
for (ai = res; ai != NULL; ai = ai->ai_next)
|
||||
{
|
||||
if ((newsocket =
|
||||
socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) == -1)
|
||||
if ((newsocket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) == -1)
|
||||
{
|
||||
Com_Printf("NET_Socket: socket: %s\n", strerror(errno));
|
||||
continue;
|
||||
|
|
|
@ -846,8 +846,7 @@ NET_IPSocket(char *net_interface, int port, netsrc_t type, int family)
|
|||
|
||||
for (ai = res; ai != NULL; ai = ai->ai_next)
|
||||
{
|
||||
if ((newsocket =
|
||||
socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) == -1)
|
||||
if ((newsocket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) == -1)
|
||||
{
|
||||
Com_Printf("NET_IPSocket: socket: %s\n", strerror(errno));
|
||||
continue;
|
||||
|
|
Loading…
Reference in a new issue