Core/WorldSession: Mitigate DoS attacks

Mitigate DoS attacks like one explained in #10555 by processing a limited number of packets at each WorldSession::Update() call, allowing other WorldSessions to be processed.
100 packets in a single update sound like a reasonable amount.
This commit is contained in:
jackpoz committed 2013-10-17 22:03:51 +02:00
1 parent a0b3863bd1
commit 4aee86627e
1 file changed
+10
+10
View File
@@ -272,6 +272,8 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
//! delayed packets that were re-enqueued due to improper timing. To prevent an infinite
//! loop caused by re-enqueueing the same packets over and over again, we stop updating this session
//! and continue updating others. The re-enqueued packets will be handled in the next Update call for this session.
uint32 processedPackets = 0;
while (m_Socket && !m_Socket->IsClosed() &&
!_recvQueue.empty() && _recvQueue.peek(true) != firstDelayedPacket &&
_recvQueue.next(packet, updater))
@@ -383,6 +385,14 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
delete packet;
deletePacket = true;
#define MAX_PROCESSED_PACKETS_IN_SAME_WORLDSESSION_UPDATE 100
processedPackets++;
//process only a max amout of packets in 1 Update() call.
//Any leftover will be processed in next update
if (processedPackets > MAX_PROCESSED_PACKETS_IN_SAME_WORLDSESSION_UPDATE)
break;
}
if (m_Socket && !m_Socket->IsClosed() && _warden)