engine: cache negative master server DNS failures longer, remove dead UDP master server addresses

This commit is contained in:
Alibek Omarov
2026-06-07 02:24:30 +05:00
parent 75ffba64c5
commit 61a84f6953
2 changed files with 12 additions and 21 deletions

View File

@@ -50,8 +50,9 @@ static struct masterlist_s
static CVAR_DEFINE_AUTO( sv_verbose_heartbeats, "0", 0, "print every heartbeat to console" );
#define HEARTBEAT_SECONDS ((sv_nat.value > 0.0f) ? 60.0f : 300.0f) // 1 or 5 minutes
#define RESOLVE_EXPIRE_SECONDS (60.0f) // 1 minute to expire
#define HEARTBEAT_SECONDS ((sv_nat.value > 0.0f) ? 60.0f : 300.0f) // 1 or 5 minutes
#define RESOLVE_EXPIRE_SECONDS (60.0f) // positive cache: 1 minute
#define NEGATIVE_RESOLVE_EXPIRE_SECONDS (300.0f) // negative cache: 5 minutes
static size_t NET_BuildMasterServerScanRequest( char *buf, size_t size, uint32_t key, qboolean nat, const char *filter, connprotocol_t proto )
{
@@ -96,11 +97,10 @@ NET_GetMasterHostByName
*/
static net_gai_state_t NET_GetMasterHostByName( master_t *m )
{
if( host.realtime > m->resolve_time )
m->adr.type = 0;
if( host.realtime < m->resolve_time )
return m->adr.type ? NET_EAI_OK : NET_EAI_NONAME;
if( m->adr.type )
return NET_EAI_OK;
m->adr.type = 0;
net_gai_state_t res = NET_StringToAdrNB( m->address, &m->adr, m->v6only );
@@ -110,10 +110,13 @@ static net_gai_state_t NET_GetMasterHostByName( master_t *m )
return res;
}
m->adr.type = 0;
if( res == NET_EAI_NONAME )
{
Con_Reportf( "Can't resolve adr: %s\n", m->address );
m->resolve_time = host.realtime + NEGATIVE_RESOLVE_EXPIRE_SECONDS;
}
m->adr.type = 0;
return res;
}
@@ -765,17 +768,6 @@ void NET_InitMasters( void )
Cvar_RegisterVariable( &sv_verbose_heartbeats );
{ // IPv4-only
NET_AddMaster( "mentality.rip:27010" );
NET_AddMaster( "ms2.mentality.rip:27010" );
NET_AddMaster( "ms3.mentality.rip:27010" );
}
{ // IPv6-only
NET_AddMaster( "aaaa.mentality.rip:27010" )->v6only = true;
NET_AddMaster( "aaaa.ms2.mentality.rip:27010" )->v6only = true;
}
#if 0
NET_AddMasterStatic( "http://meltdown.lan/test" );
#endif
@@ -785,6 +777,5 @@ void NET_InitMasters( void )
// FIXME: https raw.githubcontent source
// FIXME: cloudflare'd sources both HTTP and HTTPS
NET_LoadMasters();
}

View File

@@ -1777,8 +1777,8 @@ static void NET_DetermineLocalAddress( void )
struct sockaddr_storage address;
WSAsize_t namelen;
memset( &net_local, 0, sizeof( netadr_t ));
memset( &net6_local, 0, sizeof( netadr_t ));
memset( &net_local, 0, sizeof( net_local ));
memset( &net6_local, 0, sizeof( net6_local ));
if( !net.allow_ip && !net.allow_ip6 )
{