mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 15:40:45 +01:00
Core/Warden: Add .debug warden force, allowing you to force specific warden checks to be sent
This commit is contained in:
6
sql/updates/world/3.3.5/2020_08_18_06_world.sql
Normal file
6
sql/updates/world/3.3.5/2020_08_18_06_world.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
--
|
||||
DELETE FROM `command` WHERE `name`='debug warden force';
|
||||
INSERT INTO `command` (`name`,`permission`,`help`) VALUES
|
||||
('debug warden force', 300, 'Syntax: .debug warden force id1 [id2 [id3 [...]]]
|
||||
|
||||
Queues the specified Warden checks for your client. They will be sent according to your Warden settings.');
|
||||
@@ -115,7 +115,6 @@ WorldSession::WorldSession(uint32 id, std::string&& name, std::shared_ptr<WorldS
|
||||
_accountId(id),
|
||||
_accountName(std::move(name)),
|
||||
m_expansion(expansion),
|
||||
_warden(nullptr),
|
||||
_logoutTime(0),
|
||||
m_inQueue(false),
|
||||
m_playerLoading(false),
|
||||
@@ -164,7 +163,6 @@ WorldSession::~WorldSession()
|
||||
m_Socket = nullptr;
|
||||
}
|
||||
|
||||
delete _warden;
|
||||
delete _RBACData;
|
||||
|
||||
///- empty incoming packet queue
|
||||
@@ -1215,13 +1213,13 @@ void WorldSession::InitWarden(SessionKey const& k, std::string const& os)
|
||||
{
|
||||
if (os == "Win")
|
||||
{
|
||||
_warden = new WardenWin();
|
||||
_warden = std::make_unique<WardenWin>();
|
||||
_warden->Init(this, k);
|
||||
}
|
||||
else if (os == "OSX")
|
||||
{
|
||||
// Disabled as it is causing the client to crash
|
||||
// _warden = new WardenMac();
|
||||
// _warden = std::make_unique<WardenMac>();
|
||||
// _warden->Init(this, k);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "SharedDefines.h"
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <boost/circular_buffer.hpp>
|
||||
|
||||
@@ -429,6 +430,8 @@ class TC_GAME_API WorldSession
|
||||
uint8 Expansion() const { return m_expansion; }
|
||||
|
||||
void InitWarden(SessionKey const& k, std::string const& os);
|
||||
Warden* GetWarden() { return _warden.get(); }
|
||||
Warden const* GetWarden() const { return _warden.get(); }
|
||||
|
||||
/// Session in auth.queue currently
|
||||
void SetInQueue(bool state) { m_inQueue = state; }
|
||||
@@ -1167,7 +1170,7 @@ class TC_GAME_API WorldSession
|
||||
uint8 m_expansion;
|
||||
|
||||
// Warden
|
||||
Warden* _warden; // Remains NULL if Warden system is not enabled by config
|
||||
std::unique_ptr<Warden> _warden; // Remains NULL if Warden system is not enabled by config
|
||||
|
||||
time_t _logoutTime;
|
||||
bool m_inQueue; // session wait in auth.queue
|
||||
|
||||
@@ -92,6 +92,8 @@ class TC_GAME_API Warden
|
||||
void Update(uint32 diff);
|
||||
void HandleData(ByteBuffer& buff);
|
||||
|
||||
virtual size_t DEBUG_ForceSpecificChecks(std::vector<uint16> const& checks) = 0;
|
||||
|
||||
protected:
|
||||
void DecryptData(uint8* buffer, uint32 length);
|
||||
void EncryptData(uint8* buffer, uint32 length);
|
||||
|
||||
@@ -78,7 +78,7 @@ class TC_GAME_API WardenCheckMgr
|
||||
|
||||
private:
|
||||
std::vector<WardenCheck> CheckStore;
|
||||
std::unordered_map<uint32, WardenCheckResult> CheckResultStore;
|
||||
std::unordered_map<uint16, WardenCheckResult> CheckResultStore;
|
||||
std::vector<uint16> MemChecksIdPool;
|
||||
std::vector<uint16> OtherChecksIdPool;
|
||||
};
|
||||
|
||||
@@ -37,6 +37,7 @@ class TC_GAME_API WardenMac : public Warden
|
||||
void RequestHash() override;
|
||||
void HandleHashResult(ByteBuffer& buff) override;
|
||||
void RequestChecks() override;
|
||||
size_t DEBUG_ForceSpecificChecks(std::vector<uint16> const& /*checks*/) override { return 0; }
|
||||
void HandleCheckResult(ByteBuffer& buff) override;
|
||||
};
|
||||
|
||||
|
||||
@@ -476,3 +476,31 @@ void WardenWin::HandleCheckResult(ByteBuffer &buff)
|
||||
uint32 holdOff = sWorld->getIntConfig(CONFIG_WARDEN_CLIENT_CHECK_HOLDOFF);
|
||||
_checkTimer = (holdOff < 1 ? 1 : holdOff) * IN_MILLISECONDS;
|
||||
}
|
||||
|
||||
size_t WardenWin::DEBUG_ForceSpecificChecks(std::vector<uint16> const& checks)
|
||||
{
|
||||
std::vector<uint16>::iterator memChecksIt = _memChecks.begin();
|
||||
std::vector<uint16>::iterator otherChecksIt = _otherChecks.begin();
|
||||
|
||||
size_t n = 0;
|
||||
for (uint16 check : checks)
|
||||
{
|
||||
if (auto it = std::find(memChecksIt, _memChecks.end(), check); it != _memChecks.end())
|
||||
{
|
||||
std::iter_swap(it, memChecksIt);
|
||||
++memChecksIt;
|
||||
++n;
|
||||
}
|
||||
else if (auto it = std::find(otherChecksIt, _otherChecks.end(), check); it != _otherChecks.end())
|
||||
{
|
||||
std::iter_swap(it, otherChecksIt);
|
||||
++otherChecksIt;
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
_memChecksIt = _memChecks.begin();
|
||||
_otherChecksIt = _otherChecks.begin();
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
@@ -75,6 +75,8 @@ class TC_GAME_API WardenWin : public Warden
|
||||
void RequestChecks() override;
|
||||
void HandleCheckResult(ByteBuffer &buff) override;
|
||||
|
||||
size_t DEBUG_ForceSpecificChecks(std::vector<uint16> const& checks) override;
|
||||
|
||||
private:
|
||||
uint32 _serverTicks;
|
||||
std::vector<uint16> _memChecks;
|
||||
|
||||
@@ -43,6 +43,7 @@ EndScriptData */
|
||||
#include "RBAC.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "Transport.h"
|
||||
#include "Warden.h"
|
||||
#include "World.h"
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
@@ -83,6 +84,10 @@ public:
|
||||
{ "memoryleak", rbac::RBAC_PERM_COMMAND_DEBUG_ASAN, true, &HandleDebugMemoryLeak, "" },
|
||||
{ "outofbounds", rbac::RBAC_PERM_COMMAND_DEBUG_ASAN, true, &HandleDebugOutOfBounds, "" },
|
||||
};
|
||||
static std::vector<ChatCommand> debugWardenCommandTable =
|
||||
{
|
||||
{ "force", rbac::RBAC_PERM_COMMAND_DEBUG, true, &HandleDebugWardenForce, "" }
|
||||
};
|
||||
static std::vector<ChatCommand> debugCommandTable =
|
||||
{
|
||||
{ "setbit", rbac::RBAC_PERM_COMMAND_DEBUG_SETBIT, false, &HandleDebugSet32BitCommand, "" },
|
||||
@@ -121,7 +126,8 @@ public:
|
||||
{ "asan", rbac::RBAC_PERM_COMMAND_DEBUG_ASAN, true, nullptr, "", debugAsanCommandTable },
|
||||
{ "guidlimits", rbac::RBAC_PERM_COMMAND_DEBUG, true, &HandleDebugGuidLimitsCommand, "" },
|
||||
{ "objectcount", rbac::RBAC_PERM_COMMAND_DEBUG, true, &HandleDebugObjectCountCommand, "" },
|
||||
{ "questreset", rbac::RBAC_PERM_COMMAND_DEBUG_QUESTRESET, true, &HandleDebugQuestResetCommand, "" }
|
||||
{ "questreset", rbac::RBAC_PERM_COMMAND_DEBUG_QUESTRESET, true, &HandleDebugQuestResetCommand, "" },
|
||||
{ "warden", rbac::RBAC_PERM_COMMAND_DEBUG, true, nullptr, "", debugWardenCommandTable }
|
||||
};
|
||||
static std::vector<ChatCommand> commandTable =
|
||||
{
|
||||
@@ -1725,6 +1731,23 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleDebugWardenForce(ChatHandler* handler, std::vector<uint16> checkIds)
|
||||
{
|
||||
if (checkIds.empty())
|
||||
return false;
|
||||
|
||||
Warden* const warden = handler->GetSession()->GetWarden();
|
||||
if (!warden)
|
||||
{
|
||||
handler->SendSysMessage("Warden system is not enabled");
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t const nQueued = warden->DEBUG_ForceSpecificChecks(checkIds);
|
||||
handler->PSendSysMessage("%zu/%zu checks queued for your Warden, they should be sent over the next few minutes (depending on settings)", nQueued, checkIds.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleDebugGuidLimitsCommand(ChatHandler* handler, Optional<uint32> mapId)
|
||||
{
|
||||
if (mapId)
|
||||
|
||||
Reference in New Issue
Block a user