refactor(Core/Server): Improvements to antidos opcode handling (#21502)

This commit is contained in:
Takenbacon
2025-02-20 22:17:34 -08:00
committed by GitHub
parent f6c4164765
commit 4cd1ed2181
9 changed files with 413 additions and 419 deletions

View File

@@ -322,7 +322,7 @@ protected:
struct PacketCounter
{
time_t lastReceiveTime;
uint32 amountCounter;
uint16 amountCounter;
};
/// Player session in the World
@@ -1104,22 +1104,21 @@ protected:
{
friend class World;
public:
DosProtection(WorldSession* s);
bool EvaluateOpcode(WorldPacket& p, time_t time) const;
protected:
enum Policy
enum class Policy
{
POLICY_LOG,
POLICY_KICK,
POLICY_BAN
Process,
Kick,
Ban,
Log,
BlockingThrottle,
DropPacket
};
uint32 GetMaxPacketCounterAllowed(uint16 opcode) const;
DosProtection(WorldSession* s);
Policy EvaluateOpcode(WorldPacket const& p, time_t const time) const;
protected:
WorldSession* Session;
private:
Policy _policy;
typedef std::unordered_map<uint16, PacketCounter> PacketThrottlingMap;
// mark this member as "mutable" so it can be modified even in const functions
mutable PacketThrottlingMap _PacketThrottlingMap;