diff options
| author | Nay <dnpd.dd@gmail.com> | 2013-08-30 15:44:17 +0100 |
|---|---|---|
| committer | Nay <dnpd.dd@gmail.com> | 2013-08-30 15:44:17 +0100 |
| commit | 1903d4ca7dbbd74fda0ece28359a5ac4ceb9d290 (patch) | |
| tree | 83fe41df5a9d0c503c43e36596bb28d8a0848813 /src/server/game | |
| parent | 9bea4fc4515b556fc69412cccc3c3f186553fe7b (diff) | |
Core/Server: Fix a spammy warning in WorldSession and move code to .cpp
Diffstat (limited to 'src/server/game')
| -rw-r--r-- | src/server/game/Server/WorldSession.cpp | 37 | ||||
| -rw-r--r-- | src/server/game/Server/WorldSession.h | 45 |
2 files changed, 39 insertions, 43 deletions
diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index d6e9c17cb11..5ebf436d85d 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -1221,3 +1221,40 @@ void WorldSession::InvalidateRBACData() delete _RBACData; _RBACData = NULL; } + +bool WorldSession::DosProtection::EvaluateOpcode(WorldPacket& p) const +{ + if (IsOpcodeAllowed(p.GetOpcode())) + return true; + + // Opcode not allowed, let the punishment begin + TC_LOG_INFO(LOG_FILTER_NETWORKIO, "AntiDOS: Account %u, IP: %s, sent unacceptable packet (opc: %u, size: %u)", + Session->GetAccountId(), Session->GetRemoteAddress().c_str(), p.GetOpcode(), (uint32)p.size()); + + switch (_policy) + { + case POLICY_LOG: + return true; + case POLICY_KICK: + TC_LOG_INFO(LOG_FILTER_NETWORKIO, "AntiDOS: Player kicked!"); + return false; + case POLICY_BAN: + { + BanMode bm = (BanMode)sWorld->getIntConfig(CONFIG_PACKET_SPOOF_BANMODE); + uin32 duration = sWorld->getIntConfig(CONFIG_PACKET_SPOOF_BANDURATION); // in seconds + std::string nameOrIp = ""; + switch (bm) + { + case BAN_CHARACTER: // not supported, ban account + case BAN_ACCOUNT: (void)sAccountMgr->GetName(Session->GetAccountId(), nameOrIp); break; + case BAN_IP: nameOrIp = Session->GetRemoteAddress(); break; + } + sWorld->BanAccount(bm, nameOrIp, duration, "DOS (Packet Flooding/Spoofing", "Server: AutoDOS"); + sLog->outInfo(LOG_FILTER_NETWORKIO, "AntiDOS: Player automatically banned for %u seconds.", duration); + + return false; + } + default: // invalid policy + return true; + } +} diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 643f74024af..0aa2a9ff06f 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -919,49 +919,8 @@ class WorldSession friend class World; public: DosProtection(WorldSession* s) : Session(s), _policy((Policy)sWorld->getIntConfig(CONFIG_PACKET_SPOOF_POLICY)) {} - - bool EvaluateOpcode(WorldPacket& p) const - { - if (IsOpcodeAllowed(p.GetOpcode())) - return true; - - // Opcode not allowed, let the punishment begin - TC_LOG_INFO(LOG_FILTER_NETWORKIO, "AntiDOS: Account %u, IP: %s, sent unacceptable packet (opc: %u, size: %u)", - Session->GetAccountId(), Session->GetRemoteAddress().c_str(), p.GetOpcode(), (uint32)p.size()); - - switch (_policy) - { - case POLICY_LOG: - return true; - case POLICY_KICK: - TC_LOG_INFO(LOG_FILTER_NETWORKIO, "AntiDOS: Player kicked!"); - return false; - case POLICY_BAN: - { - BanMode bm = (BanMode)sWorld->getIntConfig(CONFIG_PACKET_SPOOF_BANMODE); - int64 duration = (int64)sWorld->getIntConfig(CONFIG_PACKET_SPOOF_BANDURATION); // in seconds - std::string nameOrIp = ""; - switch (bm) - { - case BAN_CHARACTER: // not supported, ban account - case BAN_ACCOUNT: (void)sAccountMgr->GetName(Session->GetAccountId(), nameOrIp); break; - case BAN_IP: nameOrIp = Session->GetRemoteAddress(); break; - } - sWorld->BanAccount(bm, nameOrIp, duration, "DOS (Packet Flooding/Spoofing", "Server: AutoDOS"); - sLog->outInfo(LOG_FILTER_NETWORKIO, "AntiDOS: Player automatically banned for "I64FMT" seconds.", duration); - - return false; - } - default: // invalid policy - return true; - } - } - - void AllowOpcode(uint16 opcode, bool allow) - { - _isOpcodeAllowed[opcode] = allow; - } - + bool EvaluateOpcode(WorldPacket& p) const; + void AllowOpcode(uint16 opcode, bool allow) { _isOpcodeAllowed[opcode] = allow; } protected: enum Policy { |
