refactor(Core/Misc): acore to Acore (#6043)

This commit is contained in:
Kitzunu
2021-05-31 14:21:54 +02:00
committed by GitHub
parent 7eeae6866e
commit 897a02bb75
224 changed files with 942 additions and 942 deletions
+4 -4
View File
@@ -249,14 +249,14 @@ void Warden::ApplyPenalty(uint16 checkId, std::string const& reason)
if (Player const* plr = _session->GetPlayer())
{
std::string const reportFormat = "Player %s (guid %u, account id: %u) failed warden %u check (%s). Action: %s";
reportMsg = acore::StringFormat(reportFormat, plr->GetName().c_str(), plr->GetGUID().GetCounter(), _session->GetAccountId(),
reportMsg = Acore::StringFormat(reportFormat, plr->GetName().c_str(), plr->GetGUID().GetCounter(), _session->GetAccountId(),
checkId, ((checkData && !checkData->Comment.empty()) ? checkData->Comment.c_str() : "<warden comment is not set>"),
GetWardenActionStr(action).c_str());
}
else
{
std::string const reportFormat = "Account id: %u failed warden %u check. Action: %s";
reportMsg = acore::StringFormat(reportFormat, _session->GetAccountId(), checkId, GetWardenActionStr(action).c_str());
reportMsg = Acore::StringFormat(reportFormat, _session->GetAccountId(), checkId, GetWardenActionStr(action).c_str());
}
}
else
@@ -264,12 +264,12 @@ void Warden::ApplyPenalty(uint16 checkId, std::string const& reason)
if (Player const* plr = _session->GetPlayer())
{
std::string const reportFormat = "Player %s (guid %u, account id: %u) triggered warden penalty by reason: %s. Action: %s";
reportMsg = acore::StringFormat(reportFormat, plr->GetName().c_str(), plr->GetGUID().GetCounter(), _session->GetAccountId(), causeMsg.c_str(), GetWardenActionStr(action).c_str());
reportMsg = Acore::StringFormat(reportFormat, plr->GetName().c_str(), plr->GetGUID().GetCounter(), _session->GetAccountId(), causeMsg.c_str(), GetWardenActionStr(action).c_str());
}
else
{
std::string const reportFormat = "Account id: %u failed warden %u check. Action: %s";
reportMsg = acore::StringFormat(reportFormat, _session->GetAccountId(), causeMsg.c_str(), GetWardenActionStr(action).c_str());
reportMsg = Acore::StringFormat(reportFormat, _session->GetAccountId(), causeMsg.c_str(), GetWardenActionStr(action).c_str());
}
}
+2 -2
View File
@@ -123,8 +123,8 @@ private:
uint8 _inputKey[16];
uint8 _outputKey[16];
uint8 _seed[16];
acore::Crypto::ARC4 _inputCrypto;
acore::Crypto::ARC4 _outputCrypto;
Acore::Crypto::ARC4 _inputCrypto;
Acore::Crypto::ARC4 _outputCrypto;
uint32 _checkTimer; // Timer for sending check requests
uint32 _clientResponseTimer; // Timer for client response delay
bool _dataSent;
+9 -9
View File
@@ -30,7 +30,7 @@ void WardenMac::Init(WorldSession* pClient, SessionKey const& K)
{
_session = pClient;
// Generate Warden Key
SessionKeyGenerator<acore::Crypto::SHA1> WK(K);
SessionKeyGenerator<Acore::Crypto::SHA1> WK(K);
WK.Generate(_inputKey, 16);
WK.Generate(_outputKey, 16);
/*
@@ -49,17 +49,17 @@ void WardenMac::Init(WorldSession* pClient, SessionKey const& K)
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Server side warden for client %u initializing...", pClient->GetAccountId());
LOG_DEBUG("warden", "C->S Key: %s", acore::Impl::ByteArrayToHexStr(_inputKey, 16).c_str());
LOG_DEBUG("warden", "S->C Key: %s", acore::Impl::ByteArrayToHexStr(_outputKey, 16 ).c_str());
LOG_DEBUG("warden", " Seed: %s", acore::Impl::ByteArrayToHexStr(_seed, 16).c_str());
LOG_DEBUG("warden", "C->S Key: %s", Acore::Impl::ByteArrayToHexStr(_inputKey, 16).c_str());
LOG_DEBUG("warden", "S->C Key: %s", Acore::Impl::ByteArrayToHexStr(_outputKey, 16 ).c_str());
LOG_DEBUG("warden", " Seed: %s", Acore::Impl::ByteArrayToHexStr(_seed, 16).c_str());
LOG_DEBUG("warden", "Loading Module...");
#endif
_module = GetModuleForClient();
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Module Key: %s", acore::Impl::ByteArrayToHexStr(_module->Key, 16).c_str());
LOG_DEBUG("warden", "Module ID: %s", acore::Impl::ByteArrayToHexStr(_module->Id, 16).c_str());
LOG_DEBUG("warden", "Module Key: %s", Acore::Impl::ByteArrayToHexStr(_module->Key, 16).c_str());
LOG_DEBUG("warden", "Module ID: %s", Acore::Impl::ByteArrayToHexStr(_module->Id, 16).c_str());
#endif
RequestModule();
}
@@ -155,7 +155,7 @@ void WardenMac::HandleHashResult(ByteBuffer& buff)
buff.rpos(buff.wpos());
acore::Crypto::SHA1 sha1;
Acore::Crypto::SHA1 sha1;
sha1.UpdateData((uint8*)keyIn, 16);
sha1.Finalize();
@@ -243,13 +243,13 @@ void WardenMac::HandleData(ByteBuffer& buff)
std::string str = "Test string!";
acore::Crypto::SHA1 sha1;
Acore::Crypto::SHA1 sha1;
sha1.UpdateData(str);
uint32 magic = 0xFEEDFACE; // unsure
sha1.UpdateData((uint8*)&magic, 4);
sha1.Finalize();
std::array<uint8, acore::Crypto::SHA1::DIGEST_LENGTH> sha1Hash;
std::array<uint8, Acore::Crypto::SHA1::DIGEST_LENGTH> sha1Hash;
buff.read(sha1Hash.data(), sha1Hash.size());
if (sha1Hash != sha1.GetDigest())
+15 -15
View File
@@ -39,7 +39,7 @@ static constexpr uint8 GetCheckPacketBaseSize(uint8 type)
case LUA_EVAL_CHECK: return 1 + sizeof(_luaEvalPrefix) - 1 + sizeof(_luaEvalMidfix) - 1 + 4 + sizeof(_luaEvalPostfix) - 1;
case PAGE_CHECK_A: return (4 + 1);
case PAGE_CHECK_B: return (4 + 1);
case MODULE_CHECK: return (4 + acore::Crypto::Constants::SHA1_DIGEST_LENGTH_BYTES);
case MODULE_CHECK: return (4 + Acore::Crypto::Constants::SHA1_DIGEST_LENGTH_BYTES);
case MEM_CHECK: return (1 + 4 + 1);
default: return 0;
}
@@ -95,7 +95,7 @@ void WardenWin::Init(WorldSession* session, SessionKey const& k)
{
_session = session;
// Generate Warden Key
SessionKeyGenerator<acore::Crypto::SHA1> WK(k);
SessionKeyGenerator<Acore::Crypto::SHA1> WK(k);
WK.Generate(_inputKey, 16);
WK.Generate(_outputKey, 16);
@@ -105,17 +105,17 @@ void WardenWin::Init(WorldSession* session, SessionKey const& k)
_outputCrypto.Init(_outputKey);
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Server side warden for client %u initializing...", session->GetAccountId());
LOG_DEBUG("warden", "C->S Key: %s", acore::Impl::ByteArrayToHexStr(_inputKey, 16).c_str());
LOG_DEBUG("warden", "S->C Key: %s", acore::Impl::ByteArrayToHexStr(_outputKey,16).c_str());
LOG_DEBUG("warden", " Seed: %s", acore::Impl::ByteArrayToHexStr(_seed, 16).c_str());
LOG_DEBUG("warden", "C->S Key: %s", Acore::Impl::ByteArrayToHexStr(_inputKey, 16).c_str());
LOG_DEBUG("warden", "S->C Key: %s", Acore::Impl::ByteArrayToHexStr(_outputKey,16).c_str());
LOG_DEBUG("warden", " Seed: %s", Acore::Impl::ByteArrayToHexStr(_seed, 16).c_str());
LOG_DEBUG("warden", "Loading Module...");
#endif
_module = GetModuleForClient();
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Module Key: %s", acore::Impl::ByteArrayToHexStr(_module->Key, 16).c_str());
LOG_DEBUG("warden", "Module ID: %s", acore::Impl::ByteArrayToHexStr(_module->Id, 16).c_str());
LOG_DEBUG("warden", "Module Key: %s", Acore::Impl::ByteArrayToHexStr(_module->Key, 16).c_str());
LOG_DEBUG("warden", "Module ID: %s", Acore::Impl::ByteArrayToHexStr(_module->Id, 16).c_str());
#endif
RequestModule();
}
@@ -159,7 +159,7 @@ void WardenWin::InitializeModule()
Request.Function1[1] = 0x000218C0; // 0x00400000 + 0x000218C0 SFileGetFileSize
Request.Function1[2] = 0x00022530; // 0x00400000 + 0x00022530 SFileReadFile
Request.Function1[3] = 0x00022910; // 0x00400000 + 0x00022910 SFileCloseFile
Request.CheckSumm1 = BuildChecksum(&Request.Unk1, acore::Crypto::Constants::SHA1_DIGEST_LENGTH_BYTES);
Request.CheckSumm1 = BuildChecksum(&Request.Unk1, Acore::Crypto::Constants::SHA1_DIGEST_LENGTH_BYTES);
Request.Command2 = WARDEN_SMSG_MODULE_INITIALIZE;
Request.Size2 = 8;
@@ -224,7 +224,7 @@ void WardenWin::HandleHashResult(ByteBuffer& buff)
buff.rpos(buff.wpos());
// Verify key
if (memcmp(buff.contents() + 1, Module.ClientKeySeedHash, acore::Crypto::Constants::SHA1_DIGEST_LENGTH_BYTES) != 0)
if (memcmp(buff.contents() + 1, Module.ClientKeySeedHash, Acore::Crypto::Constants::SHA1_DIGEST_LENGTH_BYTES) != 0)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Request hash reply: failed");
@@ -331,7 +331,7 @@ void WardenWin::RequestChecks()
// Filtered checks will get passed in next checks
uint16 expectedSize = 4;
_PendingChecks.clear();
acore::Containers::EraseIf(_CurrentChecks,
Acore::Containers::EraseIf(_CurrentChecks,
[this, &expectedSize](uint16 id)
{
uint16 const thisSize = GetCheckPacketSize(sWardenCheckMgr->GetWardenDataById(id));
@@ -418,9 +418,9 @@ void WardenWin::RequestChecks()
}
case MODULE_CHECK:
{
std::array<uint8, 4> seed = acore::Crypto::GetRandomBytes<4>();
std::array<uint8, 4> seed = Acore::Crypto::GetRandomBytes<4>();
buff.append(seed);
buff.append(acore::Crypto::HMAC_SHA1::GetDigestOf(seed, check->Str));
buff.append(Acore::Crypto::HMAC_SHA1::GetDigestOf(seed, check->Str));
break;
}
/*case PROC_CHECK:
@@ -621,17 +621,17 @@ void WardenWin::HandleData(ByteBuffer& buff)
}
WardenCheckResult const* rs = sWardenCheckMgr->GetWardenResultById(checkId);
if (memcmp(buff.contents() + buff.rpos(), rs->Result.ToByteArray<20>(false).data(), acore::Crypto::Constants::SHA1_DIGEST_LENGTH_BYTES) != 0) // SHA1
if (memcmp(buff.contents() + buff.rpos(), rs->Result.ToByteArray<20>(false).data(), Acore::Crypto::Constants::SHA1_DIGEST_LENGTH_BYTES) != 0) // SHA1
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "RESULT MPQ_CHECK fail, CheckId %u account Id %u", checkId, _session->GetAccountId());
#endif
checkFailed = checkId;
buff.rpos(buff.rpos() + acore::Crypto::Constants::SHA1_DIGEST_LENGTH_BYTES); // 20 bytes SHA1
buff.rpos(buff.rpos() + Acore::Crypto::Constants::SHA1_DIGEST_LENGTH_BYTES); // 20 bytes SHA1
continue;
}
buff.rpos(buff.rpos() + acore::Crypto::Constants::SHA1_DIGEST_LENGTH_BYTES); // 20 bytes SHA1
buff.rpos(buff.rpos() + Acore::Crypto::Constants::SHA1_DIGEST_LENGTH_BYTES); // 20 bytes SHA1
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "RESULT MPQ_CHECK passed, CheckId %u account Id %u", checkId, _session->GetAccountId());
#endif