mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-19 09:12:19 +00:00
server: Handle dnsbl and other non-critical stuff only on new ticks
Less risk of causing microlags then, I think once per second is often enough since it has to iterate through all players
This commit is contained in:
parent
26cccb7f51
commit
043480b06e
|
@ -2857,54 +2857,6 @@ int CServer::Run()
|
|||
}
|
||||
}
|
||||
|
||||
// handle dnsbl
|
||||
if(Config()->m_SvDnsbl)
|
||||
{
|
||||
for(int ClientId = 0; ClientId < MAX_CLIENTS; ClientId++)
|
||||
{
|
||||
if(m_aClients[ClientId].m_State == CClient::STATE_EMPTY)
|
||||
continue;
|
||||
|
||||
if(m_aClients[ClientId].m_DnsblState == CClient::DNSBL_STATE_NONE)
|
||||
{
|
||||
// initiate dnsbl lookup
|
||||
InitDnsbl(ClientId);
|
||||
}
|
||||
else if(m_aClients[ClientId].m_DnsblState == CClient::DNSBL_STATE_PENDING &&
|
||||
m_aClients[ClientId].m_pDnsblLookup->State() == IJob::STATE_DONE)
|
||||
{
|
||||
if(m_aClients[ClientId].m_pDnsblLookup->Result() != 0)
|
||||
{
|
||||
// entry not found -> whitelisted
|
||||
m_aClients[ClientId].m_DnsblState = CClient::DNSBL_STATE_WHITELISTED;
|
||||
|
||||
char aAddrStr[NETADDR_MAXSTRSIZE];
|
||||
net_addr_str(m_NetServer.ClientAddr(ClientId), aAddrStr, sizeof(aAddrStr), true);
|
||||
|
||||
str_format(aBuf, sizeof(aBuf), "ClientId=%d addr=<{%s}> secure=%s whitelisted", ClientId, aAddrStr, m_NetServer.HasSecurityToken(ClientId) ? "yes" : "no");
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "dnsbl", aBuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
// entry found -> blacklisted
|
||||
m_aClients[ClientId].m_DnsblState = CClient::DNSBL_STATE_BLACKLISTED;
|
||||
|
||||
// console output
|
||||
char aAddrStr[NETADDR_MAXSTRSIZE];
|
||||
net_addr_str(m_NetServer.ClientAddr(ClientId), aAddrStr, sizeof(aAddrStr), true);
|
||||
|
||||
str_format(aBuf, sizeof(aBuf), "ClientId=%d addr=<{%s}> secure=%s blacklisted", ClientId, aAddrStr, m_NetServer.HasSecurityToken(ClientId) ? "yes" : "no");
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "dnsbl", aBuf);
|
||||
|
||||
if(Config()->m_SvDnsblBan)
|
||||
{
|
||||
m_NetServer.NetBan()->BanAddr(m_NetServer.ClientAddr(ClientId), 60, Config()->m_SvDnsblBanReason, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while(t > TickStartTime(m_CurrentGameTick + 1))
|
||||
{
|
||||
GameServer()->OnPreTickTeehistorian();
|
||||
|
@ -2968,7 +2920,6 @@ int CServer::Run()
|
|||
UpdateClientRconCommands();
|
||||
|
||||
m_Fifo.Update();
|
||||
}
|
||||
|
||||
// master server stuff
|
||||
m_pRegister->Update();
|
||||
|
@ -2978,9 +2929,53 @@ int CServer::Run()
|
|||
|
||||
Antibot()->OnEngineTick();
|
||||
|
||||
if(!NonActive)
|
||||
PumpNetwork(PacketWaiting);
|
||||
// handle dnsbl
|
||||
if(Config()->m_SvDnsbl)
|
||||
{
|
||||
for(int ClientId = 0; ClientId < MAX_CLIENTS; ClientId++)
|
||||
{
|
||||
if(m_aClients[ClientId].m_State == CClient::STATE_EMPTY)
|
||||
continue;
|
||||
|
||||
if(m_aClients[ClientId].m_DnsblState == CClient::DNSBL_STATE_NONE)
|
||||
{
|
||||
// initiate dnsbl lookup
|
||||
InitDnsbl(ClientId);
|
||||
}
|
||||
else if(m_aClients[ClientId].m_DnsblState == CClient::DNSBL_STATE_PENDING &&
|
||||
m_aClients[ClientId].m_pDnsblLookup->State() == IJob::STATE_DONE)
|
||||
{
|
||||
if(m_aClients[ClientId].m_pDnsblLookup->Result() != 0)
|
||||
{
|
||||
// entry not found -> whitelisted
|
||||
m_aClients[ClientId].m_DnsblState = CClient::DNSBL_STATE_WHITELISTED;
|
||||
|
||||
char aAddrStr[NETADDR_MAXSTRSIZE];
|
||||
net_addr_str(m_NetServer.ClientAddr(ClientId), aAddrStr, sizeof(aAddrStr), true);
|
||||
|
||||
str_format(aBuf, sizeof(aBuf), "ClientId=%d addr=<{%s}> secure=%s whitelisted", ClientId, aAddrStr, m_NetServer.HasSecurityToken(ClientId) ? "yes" : "no");
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "dnsbl", aBuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
// entry found -> blacklisted
|
||||
m_aClients[ClientId].m_DnsblState = CClient::DNSBL_STATE_BLACKLISTED;
|
||||
|
||||
// console output
|
||||
char aAddrStr[NETADDR_MAXSTRSIZE];
|
||||
net_addr_str(m_NetServer.ClientAddr(ClientId), aAddrStr, sizeof(aAddrStr), true);
|
||||
|
||||
str_format(aBuf, sizeof(aBuf), "ClientId=%d addr=<{%s}> secure=%s blacklisted", ClientId, aAddrStr, m_NetServer.HasSecurityToken(ClientId) ? "yes" : "no");
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "dnsbl", aBuf);
|
||||
|
||||
if(Config()->m_SvDnsblBan)
|
||||
{
|
||||
m_NetServer.NetBan()->BanAddr(m_NetServer.ClientAddr(ClientId), 60, Config()->m_SvDnsblBanReason, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
if(m_aClients[i].m_State == CClient::STATE_REDIRECTED)
|
||||
|
@ -2991,6 +2986,10 @@ int CServer::Run()
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!NonActive)
|
||||
PumpNetwork(PacketWaiting);
|
||||
|
||||
NonActive = true;
|
||||
for(const auto &Client : m_aClients)
|
||||
|
|
Loading…
Reference in a new issue