chore(Core/Logging): replace most server loggers (#5726)

* chore(Core/Logging): replace most server loggers

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
Kargatum
2021-06-21 08:07:12 +07:00
committed by GitHub
parent 9f80a592bb
commit 5787d00d54
199 changed files with 2312 additions and 4487 deletions

View File

@@ -37,9 +37,7 @@ Warden::~Warden()
void Warden::SendModuleToClient()
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Send module to client");
#endif
// Create packet structure
WardenModuleTransfer packet;
@@ -65,9 +63,7 @@ void Warden::SendModuleToClient()
void Warden::RequestModule()
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Request module");
#endif
// Create packet structure
WardenModuleUse request;
@@ -138,16 +134,12 @@ bool Warden::IsValidCheckSum(uint32 checksum, const uint8* data, const uint16 le
if (checksum != newChecksum)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "CHECKSUM IS NOT VALID");
#endif
return false;
}
else
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "CHECKSUM IS VALID");
#endif
return true;
}
}
@@ -320,9 +312,7 @@ void WorldSession::HandleWardenDataOpcode(WorldPacket& recvData)
_warden->DecryptData(recvData.contents(), recvData.size());
uint8 opcode;
recvData >> opcode;
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Got packet, opcode %02X, size %u", opcode, uint32(recvData.size()));
#endif
recvData.hexlike();
switch (opcode)
@@ -337,23 +327,17 @@ void WorldSession::HandleWardenDataOpcode(WorldPacket& recvData)
_warden->HandleData(recvData);
break;
case WARDEN_CMSG_MEM_CHECKS_RESULT:
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "NYI WARDEN_CMSG_MEM_CHECKS_RESULT received!");
#endif
break;
case WARDEN_CMSG_HASH_RESULT:
_warden->HandleHashResult(recvData);
_warden->InitializeModule();
break;
case WARDEN_CMSG_MODULE_FAILED:
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "NYI WARDEN_CMSG_MODULE_FAILED received!");
#endif
break;
default:
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Got unknown warden opcode %02X of size %u.", opcode, uint32(recvData.size() - 1));
#endif
break;
}
}

View File

@@ -30,8 +30,8 @@ void WardenCheckMgr::LoadWardenChecks()
// Check if Warden is enabled by config before loading anything
if (!sWorld->getBoolConfig(CONFIG_WARDEN_ENABLED))
{
LOG_INFO("server", ">> Warden disabled, loading checks skipped.");
LOG_INFO("server", " ");
LOG_INFO("server.loading", ">> Warden disabled, loading checks skipped.");
LOG_INFO("server.loading", " ");
return;
}
@@ -39,8 +39,8 @@ void WardenCheckMgr::LoadWardenChecks()
if (!result)
{
LOG_INFO("server", ">> Loaded 0 Warden checks. DB table `warden_checks` is empty!");
LOG_INFO("server", " ");
LOG_INFO("server.loading", ">> Loaded 0 Warden checks. DB table `warden_checks` is empty!");
LOG_INFO("server.loading", " ");
return;
}
@@ -63,7 +63,7 @@ void WardenCheckMgr::LoadWardenChecks()
if (checkType == LUA_EVAL_CHECK && id > 9999)
{
LOG_ERROR("server", "sql.sql: Warden Lua check with id %u found in `warden_checks`. Lua checks may have four-digit IDs at most. Skipped.", id);
LOG_ERROR("warden", "sql.sql: Warden Lua check with id %u found in `warden_checks`. Lua checks may have four-digit IDs at most. Skipped.", id);
continue;
}
@@ -122,7 +122,7 @@ void WardenCheckMgr::LoadWardenChecks()
{
if (wardenCheck.Length > WARDEN_MAX_LUA_CHECK_LENGTH)
{
LOG_ERROR("server", "sql.sql: Found over-long Lua check for Warden check with id %u in `warden_checks`. Max length is %u. Skipped.", id, WARDEN_MAX_LUA_CHECK_LENGTH);
LOG_ERROR("warden", "sql.sql: Found over-long Lua check for Warden check with id %u in `warden_checks`. Max length is %u. Skipped.", id, WARDEN_MAX_LUA_CHECK_LENGTH);
continue;
}
@@ -146,8 +146,8 @@ void WardenCheckMgr::LoadWardenChecks()
++count;
} while (result->NextRow());
LOG_INFO("server", ">> Loaded %u warden checks.", count);
LOG_INFO("server", " ");
LOG_INFO("server.loading", ">> Loaded %u warden checks.", count);
LOG_INFO("server.loading", " ");
}
void WardenCheckMgr::LoadWardenOverrides()
@@ -155,8 +155,8 @@ void WardenCheckMgr::LoadWardenOverrides()
// Check if Warden is enabled by config before loading anything
if (!sWorld->getBoolConfig(CONFIG_WARDEN_ENABLED))
{
LOG_INFO("server", ">> Warden disabled, loading check overrides skipped.");
LOG_INFO("server", " ");
LOG_INFO("server.loading", ">> Warden disabled, loading check overrides skipped.");
LOG_INFO("server.loading", " ");
return;
}
@@ -165,8 +165,8 @@ void WardenCheckMgr::LoadWardenOverrides()
if (!result)
{
LOG_INFO("server", ">> Loaded 0 Warden action overrides. DB table `warden_action` is empty!");
LOG_INFO("server", " ");
LOG_INFO("server.loading", ">> Loaded 0 Warden action overrides. DB table `warden_action` is empty!");
LOG_INFO("server.loading", " ");
return;
}
@@ -181,10 +181,10 @@ void WardenCheckMgr::LoadWardenOverrides()
// Check if action value is in range (0-2, see WardenActions enum)
if (action > WARDEN_ACTION_BAN)
LOG_ERROR("server", "Warden check override action out of range (ID: %u, action: %u)", checkId, action);
LOG_ERROR("warden", "Warden check override action out of range (ID: %u, action: %u)", checkId, action);
// Check if check actually exists before accessing the CheckStore vector
else if (checkId > CheckStore.size())
LOG_ERROR("server", "Warden check action override for non-existing check (ID: %u, action: %u), skipped", checkId, action);
LOG_ERROR("warden", "Warden check action override for non-existing check (ID: %u, action: %u), skipped", checkId, action);
else
{
CheckStore.at(checkId).Action = WardenActions(action);
@@ -192,8 +192,8 @@ void WardenCheckMgr::LoadWardenOverrides()
}
} while (result->NextRow());
LOG_INFO("server", ">> Loaded %u warden action overrides.", count);
LOG_INFO("server", " ");
LOG_INFO("server.loading", ">> Loaded %u warden action overrides.", count);
LOG_INFO("server.loading", " ");
}
WardenCheck const* WardenCheckMgr::GetWardenDataById(uint16 Id)

View File

@@ -44,20 +44,16 @@ void WardenMac::Init(WorldSession* pClient, SessionKey const& K)
_inputCrypto.Init(_inputKey);
_outputCrypto.Init(_outputKey);
#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", "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());
#endif
RequestModule();
}
@@ -84,16 +80,12 @@ ClientWardenModule* WardenMac::GetModuleForClient()
void WardenMac::InitializeModule()
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Initialize module");
#endif
}
void WardenMac::RequestHash()
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Request hash");
#endif
// Create packet structure
WardenHashRequest Request;
@@ -161,16 +153,12 @@ void WardenMac::HandleHashResult(ByteBuffer& buff)
// Verify key
if (memcmp(buff.contents() + 1, sha1.GetDigest().data(), 20) != 0)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Request hash reply: failed");
#endif
ApplyPenalty(0, "Request hash reply: failed");
return;
}
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Request hash reply: succeed");
#endif
// client 7F96EEFDA5B63D20A4DF8E00CBF48304
//const uint8 client_key[16] = { 0x7F, 0x96, 0xEE, 0xFD, 0xA5, 0xB6, 0x3D, 0x20, 0xA4, 0xDF, 0x8E, 0x00, 0xCB, 0xF4, 0x83, 0x04 };
@@ -190,9 +178,7 @@ void WardenMac::HandleHashResult(ByteBuffer& buff)
void WardenMac::RequestChecks()
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Request data");
#endif
ByteBuffer buff;
buff << uint8(WARDEN_SMSG_CHEAT_CHECKS_REQUEST);
@@ -216,9 +202,7 @@ void WardenMac::RequestChecks()
void WardenMac::HandleData(ByteBuffer& buff)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Handle data");
#endif
_dataSent = false;
_clientResponseTimer = 0;
@@ -251,9 +235,7 @@ void WardenMac::HandleData(ByteBuffer& buff)
if (sha1Hash != sha1.GetDigest())
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Handle data failed: SHA1 hash is wrong!");
#endif
//found = true;
}
@@ -268,9 +250,7 @@ void WardenMac::HandleData(ByteBuffer& buff)
if (memcmp(ourMD5Hash, theirsMD5Hash, 16))
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Handle data failed: MD5 hash is wrong!");
#endif
//found = true;
}

View File

@@ -100,20 +100,16 @@ void WardenWin::Init(WorldSession* session, SessionKey const& k)
_inputCrypto.Init(_inputKey);
_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", "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());
#endif
RequestModule();
}
@@ -140,9 +136,7 @@ ClientWardenModule* WardenWin::GetModuleForClient()
void WardenWin::InitializeModule()
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Initialize module");
#endif
// Create packet structure
WardenInitModuleRequest Request;
@@ -199,9 +193,7 @@ void WardenWin::InitializeModule()
void WardenWin::RequestHash()
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Request hash");
#endif
// Create packet structure
WardenHashRequest Request;
@@ -223,16 +215,12 @@ void WardenWin::HandleHashResult(ByteBuffer& buff)
// Verify key
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");
#endif
ApplyPenalty(0, "Request hash reply: failed");
return;
}
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Request hash reply: succeed");
#endif
// Change keys here
memcpy(_inputKey, Module.ClientKeySeed, 16);
@@ -246,9 +234,7 @@ void WardenWin::HandleHashResult(ByteBuffer& buff)
void WardenWin::RequestChecks()
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Request data");
#endif
// If all checks were done, fill the todo list again
for (uint8 i = 0; i < MAX_WARDEN_CHECK_TYPES; ++i)
@@ -443,7 +429,6 @@ void WardenWin::RequestChecks()
_dataSent = true;
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
std::stringstream stream;
stream << "Sent check id's: ";
for (uint16 checkId : _CurrentChecks)
@@ -452,14 +437,11 @@ void WardenWin::RequestChecks()
}
LOG_DEBUG("warden", "%s", stream.str().c_str());
#endif
}
void WardenWin::HandleData(ByteBuffer& buff)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "Handle data");
#endif
_dataSent = false;
_clientResponseTimer = 0;
@@ -479,9 +461,7 @@ void WardenWin::HandleData(ByteBuffer& buff)
if (!IsValidCheckSum(Checksum, buff.contents() + buff.rpos(), Length))
{
buff.rpos(buff.wpos());
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "CHECKSUM FAIL");
#endif
ApplyPenalty(0, "Failed checksum in HandleData");
return;
}
@@ -493,9 +473,7 @@ void WardenWin::HandleData(ByteBuffer& buff)
// TODO: test it.
if (result == 0x00)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "TIMING CHECK FAIL result 0x00");
#endif
ApplyPenalty(0, "TIMING CHECK FAIL result");
return;
}
@@ -503,7 +481,6 @@ void WardenWin::HandleData(ByteBuffer& buff)
uint32 newClientTicks;
buff >> newClientTicks;
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
uint32 ticksNow = World::GetGameTimeMS();
uint32 ourTicks = newClientTicks + (ticksNow - _serverTicks);
@@ -511,7 +488,6 @@ void WardenWin::HandleData(ByteBuffer& buff)
LOG_DEBUG("warden", "RequestTicks %u", _serverTicks); // At request
LOG_DEBUG("warden", "Ticks %u", newClientTicks); // At response
LOG_DEBUG("warden", "Ticks diff %u", ourTicks - newClientTicks);
#endif
}
uint16 checkFailed = 0;
@@ -529,9 +505,7 @@ void WardenWin::HandleData(ByteBuffer& buff)
if (Mem_Result != 0)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "RESULT MEM_CHECK not 0x00, CheckId %u account Id %u", checkId, _session->GetAccountId());
#endif
checkFailed = checkId;
continue;
}
@@ -541,18 +515,14 @@ void WardenWin::HandleData(ByteBuffer& buff)
std::vector<uint8> result = rs->Result.ToByteVector(0, false);
if (memcmp(buff.contents() + buff.rpos(), result.data(), rd->Length) != 0)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "RESULT MEM_CHECK fail CheckId %u account Id %u", checkId, _session->GetAccountId());
#endif
checkFailed = checkId;
buff.rpos(buff.rpos() + rd->Length);
continue;
}
buff.rpos(buff.rpos() + rd->Length);
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "RESULT MEM_CHECK passed CheckId %u account Id %u", checkId, _session->GetAccountId());
#endif
break;
}
case PAGE_CHECK_A:
@@ -563,7 +533,6 @@ void WardenWin::HandleData(ByteBuffer& buff)
const uint8 byte = 0xE9;
if (memcmp(buff.contents() + buff.rpos(), &byte, sizeof(uint8)) != 0)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
if (type == PAGE_CHECK_A || type == PAGE_CHECK_B)
LOG_DEBUG("warden", "RESULT PAGE_CHECK fail, CheckId %u account Id %u", checkId, _session->GetAccountId());
@@ -572,7 +541,6 @@ void WardenWin::HandleData(ByteBuffer& buff)
if (type == DRIVER_CHECK)
LOG_DEBUG("warden", "RESULT DRIVER_CHECK fail, CheckId %u account Id %u", checkId, _session->GetAccountId());
#endif
checkFailed = checkId;
buff.rpos(buff.rpos() + 1);
continue;
@@ -580,14 +548,12 @@ void WardenWin::HandleData(ByteBuffer& buff)
buff.rpos(buff.rpos() + 1);
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
if (type == PAGE_CHECK_A || type == PAGE_CHECK_B)
LOG_DEBUG("warden", "RESULT PAGE_CHECK passed CheckId %u account Id %u", checkId, _session->GetAccountId());
else if (type == MODULE_CHECK)
LOG_DEBUG("warden", "RESULT MODULE_CHECK passed CheckId %u account Id %u", checkId, _session->GetAccountId());
else if (type == DRIVER_CHECK)
LOG_DEBUG("warden", "RESULT DRIVER_CHECK passed CheckId %u account Id %u", checkId, _session->GetAccountId());
#endif
break;
}
case LUA_EVAL_CHECK:
@@ -598,9 +564,7 @@ void WardenWin::HandleData(ByteBuffer& buff)
buff.read_skip(buff.read<uint8>()); // discard attached string
}
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "LUA_EVAL_CHECK CheckId %u account Id %u got in-warden dummy response", checkId, _session->GetAccountId()/* , result */);
#endif
break;
}
case MPQ_CHECK:
@@ -610,9 +574,7 @@ void WardenWin::HandleData(ByteBuffer& buff)
if (Mpq_Result != 0)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("warden", "RESULT MPQ_CHECK not 0x00 account id %u", _session->GetAccountId());
#endif
checkFailed = checkId;
continue;
}
@@ -620,18 +582,14 @@ 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 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
continue;
}
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
break;
}
}