prevent quick join/quit flood. #1070

This commit is contained in:
oy 2013-02-24 19:13:45 +01:00
parent 313a0949b0
commit ea2898e94a
2 changed files with 8 additions and 1 deletions

View file

@ -188,6 +188,7 @@ public:
// Needed for GotProblems in NetClient // Needed for GotProblems in NetClient
int64 LastRecvTime() const { return m_LastRecvTime; } int64 LastRecvTime() const { return m_LastRecvTime; }
int64 ConnectTime() const { return m_LastUpdateTime; }
int AckSequence() const { return m_Ack; } int AckSequence() const { return m_Ack; }
}; };

View file

@ -69,12 +69,18 @@ int CNetServer::Drop(int ClientID, const char *pReason)
int CNetServer::Update() int CNetServer::Update()
{ {
int64 Now = time_get();
for(int i = 0; i < MaxClients(); i++) for(int i = 0; i < MaxClients(); i++)
{ {
m_aSlots[i].m_Connection.Update(); m_aSlots[i].m_Connection.Update();
if(m_aSlots[i].m_Connection.State() == NET_CONNSTATE_ERROR) if(m_aSlots[i].m_Connection.State() == NET_CONNSTATE_ERROR)
{
if(Now - m_aSlots[i].m_Connection.ConnectTime() < time_freq()/2 && NetBan())
NetBan()->BanAddr(ClientAddr(i), 60, "Stressing network");
else
Drop(i, m_aSlots[i].m_Connection.ErrorString()); Drop(i, m_aSlots[i].m_Connection.ErrorString());
} }
}
return 0; return 0;
} }