mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2024-11-10 06:31:47 +00:00
Refresh master server address cache every 24 hours
Resolve master server addresses every 24 hours instead of keeping result forever. Don't clear sv_master[1-5] cvar if the address fails to resolve; it might work later.
This commit is contained in:
parent
8a50e2aa09
commit
973e0a7e9c
2 changed files with 13 additions and 15 deletions
|
@ -241,8 +241,10 @@ typedef struct {
|
|||
int nextHeartbeatTime;
|
||||
challenge_t challenges[MAX_CHALLENGES]; // to prevent invalid IPs from connecting
|
||||
netadr_t redirectAddress; // for rcon return messages
|
||||
|
||||
netadr_t authorizeAddress; // for rcon return messages
|
||||
#ifndef STANDALONE
|
||||
netadr_t authorizeAddress; // authorize server address
|
||||
#endif
|
||||
int masterResolveTime[MAX_MASTER_SERVERS]; // next svs.time that server should do dns lookup for master server
|
||||
} serverStatic_t;
|
||||
|
||||
#define SERVER_MAXBANS 1024
|
||||
|
|
|
@ -236,6 +236,7 @@ but not on every player enter or exit.
|
|||
================
|
||||
*/
|
||||
#define HEARTBEAT_MSEC 300*1000
|
||||
#define MASTERDNS_MSEC 24*60*60*1000
|
||||
void SV_MasterHeartbeat(const char *message)
|
||||
{
|
||||
static netadr_t adr[MAX_MASTER_SERVERS][2]; // [2] for v4 and v6 address for the same address string.
|
||||
|
@ -264,12 +265,12 @@ void SV_MasterHeartbeat(const char *message)
|
|||
if(!sv_master[i]->string[0])
|
||||
continue;
|
||||
|
||||
// see if we haven't already resolved the name
|
||||
// resolving usually causes hitches on win95, so only
|
||||
// do it when needed
|
||||
if(sv_master[i]->modified || (adr[i][0].type == NA_BAD && adr[i][1].type == NA_BAD))
|
||||
// see if we haven't already resolved the name or if it's been over 24 hours
|
||||
// resolving usually causes hitches on win95, so only do it when needed
|
||||
if (sv_master[i]->modified || svs.time > svs.masterResolveTime[i])
|
||||
{
|
||||
sv_master[i]->modified = qfalse;
|
||||
svs.masterResolveTime[i] = svs.time + MASTERDNS_MSEC;
|
||||
|
||||
if(netenabled & NET_ENABLEV4)
|
||||
{
|
||||
|
@ -304,16 +305,11 @@ void SV_MasterHeartbeat(const char *message)
|
|||
else
|
||||
Com_Printf( "%s has no IPv6 address.\n", sv_master[i]->string);
|
||||
}
|
||||
}
|
||||
|
||||
if(adr[i][0].type == NA_BAD && adr[i][1].type == NA_BAD)
|
||||
{
|
||||
// if the address failed to resolve, clear it
|
||||
// so we don't take repeated dns hits
|
||||
Com_Printf("Couldn't resolve address: %s\n", sv_master[i]->string);
|
||||
Cvar_Set(sv_master[i]->name, "");
|
||||
sv_master[i]->modified = qfalse;
|
||||
continue;
|
||||
}
|
||||
if(adr[i][0].type == NA_BAD && adr[i][1].type == NA_BAD)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue