engine: add macro XASH_NO_IPV6_RESOLVE to completely skip resolving addresses with family AF_INET6

This commit is contained in:
Alibek Omarov 2024-10-02 23:21:25 +03:00
parent a758dffbc1
commit ddd8de888f
2 changed files with 20 additions and 7 deletions

View file

@ -18,16 +18,16 @@ GNU General Public License for more details.
#include "netchan.h" #include "netchan.h"
#include "xash3d_mathlib.h" #include "xash3d_mathlib.h"
#include "ipv6text.h" #include "ipv6text.h"
#if XASH_WIN32
#include "platform/win32/net.h" #if XASH_NO_NETWORK
#elif defined XASH_NO_NETWORK
#include "platform/stub/net_stub.h" #include "platform/stub/net_stub.h"
#else #elif XASH_WIN32
#include "platform/posix/net.h" #include "platform/win32/net.h"
#endif #elif XASH_PSVITA
#if XASH_PSVITA
#include "platform/psvita/net_psvita.h" #include "platform/psvita/net_psvita.h"
static const struct in6_addr in6addr_any; static const struct in6_addr in6addr_any;
#else
#include "platform/posix/net.h"
#endif #endif
#if XASH_SDL == 2 #if XASH_SDL == 2
@ -329,6 +329,11 @@ static qboolean NET_GetHostByName( const char *hostname, int family, struct sock
struct addrinfo hints; struct addrinfo hints;
qboolean ret = false; qboolean ret = false;
#if XASH_NO_IPV6_RESOLVE
if( family == AF_INET6 )
return false;
#endif
memset( &hints, 0, sizeof( hints )); memset( &hints, 0, sizeof( hints ));
hints.ai_family = family; hints.ai_family = family;
@ -351,6 +356,12 @@ static qboolean NET_GetHostByName( const char *hostname, int family, struct sock
return ret; return ret;
#else #else
struct hostent *h; struct hostent *h;
#if XASH_NO_IPV6_RESOLVE
if( family == AF_INET6 )
return false;
#endif
if(!( h = gethostbyname( hostname ))) if(!( h = gethostbyname( hostname )))
return false; return false;

View file

@ -18,8 +18,10 @@ GNU General Public License for more details.
#define NET_PSVITA_H #define NET_PSVITA_H
#include <vitasdk.h> #include <vitasdk.h>
#include "platform/posix/net.h"
/* we're missing IPv6 support; define some trash */ /* we're missing IPv6 support; define some trash */
#define XASH_NO_IPV6_RESOLVE 1
#ifndef IN6_IS_ADDR_V4MAPPED #ifndef IN6_IS_ADDR_V4MAPPED
#define IN6_IS_ADDR_V4MAPPED( p ) ( 0 ) #define IN6_IS_ADDR_V4MAPPED( p ) ( 0 )