mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-20 06:58:20 +00:00
Try to prevent network spamming issues
This commit is contained in:
parent
764a73e997
commit
e871fbbaad
|
@ -187,6 +187,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; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -124,8 +124,7 @@ int CNetConnection::QueueChunkEx(int Flags, int DataSize, const void *pData, int
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// out of buffer
|
// out of buffer, don't save the packet and hope nobody will ask for resend
|
||||||
Disconnect("too weak connection (out of buffer)");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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() && 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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue