Tell why DNSBL isn't allowing to vote (fixes #2466)

This commit is contained in:
def 2020-07-07 23:08:46 +02:00
parent b44ff4cc56
commit 66c7bf8851
3 changed files with 21 additions and 4 deletions

View file

@ -223,6 +223,8 @@ public:
virtual int* GetIdMap(int ClientID) = 0; virtual int* GetIdMap(int ClientID) = 0;
virtual bool DnsblWhite(int ClientID) = 0; virtual bool DnsblWhite(int ClientID) = 0;
virtual bool DnsblPending(int ClientID) = 0;
virtual bool DnsblBlack(int ClientID) = 0;
virtual const char *GetAnnouncementLine(char const *FileName) = 0; virtual const char *GetAnnouncementLine(char const *FileName) = 0;
virtual bool ClientPrevIngame(int ClientID) = 0; virtual bool ClientPrevIngame(int ClientID) = 0;
virtual const char *GetNetErrorString(int ClientID) = 0; virtual const char *GetNetErrorString(int ClientID) = 0;

View file

@ -442,6 +442,14 @@ public:
return m_aClients[ClientID].m_DnsblState == CClient::DNSBL_STATE_NONE || return m_aClients[ClientID].m_DnsblState == CClient::DNSBL_STATE_NONE ||
m_aClients[ClientID].m_DnsblState == CClient::DNSBL_STATE_WHITELISTED; m_aClients[ClientID].m_DnsblState == CClient::DNSBL_STATE_WHITELISTED;
} }
bool DnsblPending(int ClientID)
{
return m_aClients[ClientID].m_DnsblState == CClient::DNSBL_STATE_PENDING;
}
bool DnsblBlack(int ClientID)
{
return m_aClients[ClientID].m_DnsblState == CClient::DNSBL_STATE_BLACKLISTED;
}
void AuthRemoveKey(int KeySlot); void AuthRemoveKey(int KeySlot);
bool ClientPrevIngame(int ClientID) { return m_aPrevStates[ClientID] == CClient::STATE_INGAME; }; bool ClientPrevIngame(int ClientID) { return m_aPrevStates[ClientID] == CClient::STATE_INGAME; };

View file

@ -3894,11 +3894,18 @@ bool CGameContext::RateLimitPlayerVote(int ClientID)
return true; return true;
} }
if (g_Config.m_SvDnsblVote && !m_pServer->DnsblWhite(ClientID) && Server()->DistinctClientCount() > 1) if(g_Config.m_SvDnsblVote && Server()->DistinctClientCount() > 1)
{ {
// blacklisted by dnsbl if(m_pServer->DnsblPending(ClientID))
SendChatTarget(ClientID, "You are not allowed to vote due to DNSBL."); {
return true; SendChatTarget(ClientID, "You are not allowed to vote due to pending DNSBL request. Try again in ~30 seconds.");
return true;
}
else if(m_pServer->DnsblBlack(ClientID))
{
SendChatTarget(ClientID, "You are not allowed to vote due to DNSBL. Try connecting without a VPN.");
return true;
}
} }
if(g_Config.m_SvSpamprotection && pPlayer->m_LastVoteTry && pPlayer->m_LastVoteTry + TickSpeed * 3 > Now) if(g_Config.m_SvSpamprotection && pPlayer->m_LastVoteTry && pPlayer->m_LastVoteTry + TickSpeed * 3 > Now)