Instead of banning players for reconnecting too often, make them wait 3 seconds (fixes #27)

This commit is contained in:
def 2014-09-09 23:27:28 +02:00
parent 49682f4a8d
commit 5b72302672
2 changed files with 11 additions and 5 deletions

View file

@ -7,6 +7,8 @@
void CNetConnection::ResetStats()
{
mem_zero(&m_Stats, sizeof(m_Stats));
mem_zero(&m_PeerAddr, sizeof(m_PeerAddr));
m_LastUpdateTime = 0;
}
void CNetConnection::Reset()
@ -20,9 +22,9 @@ void CNetConnection::Reset()
m_State = NET_CONNSTATE_OFFLINE;
m_LastSendTime = 0;
m_LastRecvTime = 0;
m_LastUpdateTime = 0;
//m_LastUpdateTime = 0;
m_Token = -1;
mem_zero(&m_PeerAddr, sizeof(m_PeerAddr));
//mem_zero(&m_PeerAddr, sizeof(m_PeerAddr));
m_Buffer.Init();
@ -243,6 +245,13 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr)
{
if(CtrlMsg == NET_CTRLMSG_CONNECT)
{
NETADDR nAddr;
mem_copy(&nAddr, pAddr, sizeof(nAddr));
nAddr.port = 0;
m_PeerAddr.port = 0;
if(net_addr_comp(&m_PeerAddr, &nAddr) == 0 && time_get() - m_LastUpdateTime < time_freq() * 3)
return 0;
// send response and init connection
Reset();
m_State = NET_CONNSTATE_PENDING;

View file

@ -77,9 +77,6 @@ int CNetServer::Update()
(!m_aSlots[i].m_Connection.m_TimeoutProtected ||
!m_aSlots[i].m_Connection.m_TimeoutSituation))
{
if (Now - m_aSlots[i].m_Connection.ConnectTime() < time_freq() / 5 && NetBan())
NetBan()->BanAddr(ClientAddr(i), 60, "Too many connections");
else
Drop(i, m_aSlots[i].m_Connection.ErrorString());
}
}