aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Warden
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2023-01-08 21:16:53 +0100
committerShauren <shauren.trinity@gmail.com>2023-01-08 21:16:53 +0100
commitd791afae1dfcfaf592326f787755ca32d629e4d3 (patch)
tree54dc9916ede5800e110a2f0edff91530811fbdb8 /src/server/game/Warden
parentb6820a706f46f18b9652fcd9806e4bec8805d29d (diff)
Core/Logging: Switch from fmt::sprintf to fmt::format (c++20 standard compatible api)
Diffstat (limited to 'src/server/game/Warden')
-rw-r--r--src/server/game/Warden/Warden.cpp14
-rw-r--r--src/server/game/Warden/WardenCheckMgr.cpp16
-rw-r--r--src/server/game/Warden/WardenMac.cpp14
-rw-r--r--src/server/game/Warden/WardenWin.cpp64
4 files changed, 54 insertions, 54 deletions
diff --git a/src/server/game/Warden/Warden.cpp b/src/server/game/Warden/Warden.cpp
index cd3fc94c467..ba2bfbb15c5 100644
--- a/src/server/game/Warden/Warden.cpp
+++ b/src/server/game/Warden/Warden.cpp
@@ -112,8 +112,8 @@ void Warden::Update(uint32 diff)
// Kick player if client response delays more than set in config
if (_clientResponseTimer > maxClientResponseDelay * IN_MILLISECONDS)
{
- TC_LOG_WARN("warden", "%s (latency: %u, IP: %s) exceeded Warden module response delay (%s) - disconnecting client",
- _session->GetPlayerInfo().c_str(), _session->GetLatency(), _session->GetRemoteAddress().c_str(), secsToTimeString(maxClientResponseDelay, TimeFormat::ShortText).c_str());
+ TC_LOG_WARN("warden", "{} (latency: {}, IP: {}) exceeded Warden module response delay ({}) - disconnecting client",
+ _session->GetPlayerInfo(), _session->GetLatency(), _session->GetRemoteAddress(), secsToTimeString(maxClientResponseDelay, TimeFormat::ShortText));
_session->KickPlayer("Warden::Update Warden module response delay exceeded");
}
else
@@ -193,7 +193,7 @@ char const* Warden::ApplyPenalty(WardenCheck const* check)
std::string banReason = "Warden Anticheat Violation";
// Check can be NULL, for example if the client sent a wrong signature in the warden packet (CHECKSUM FAIL)
if (check)
- banReason += Trinity::StringFormat(": %s (CheckId: %u", check->Comment.c_str(), uint32(check->CheckId));
+ banReason += Trinity::StringFormat(": {} (CheckId: {}", check->Comment, check->CheckId);
sWorld->BanAccount(BAN_ACCOUNT, accountName, sWorld->getIntConfig(CONFIG_WARDEN_CLIENT_BAN_DURATION), banReason, "Server");
@@ -211,7 +211,7 @@ void Warden::HandleData(ByteBuffer& buff)
DecryptData(buff.contents(), buff.size());
uint8 opcode;
buff >> opcode;
- TC_LOG_DEBUG("warden", "Got packet, opcode %02X, size %u", opcode, uint32(buff.size() - 1));
+ TC_LOG_DEBUG("warden", "Got packet, opcode {:02X}, size {}", opcode, uint32(buff.size() - 1));
buff.hexlike();
switch (opcode)
@@ -236,7 +236,7 @@ void Warden::HandleData(ByteBuffer& buff)
TC_LOG_DEBUG("warden", "NYI WARDEN_CMSG_MODULE_FAILED received!");
break;
default:
- TC_LOG_WARN("warden", "Got unknown warden opcode %02X of size %u.", opcode, uint32(buff.size() - 1));
+ TC_LOG_WARN("warden", "Got unknown warden opcode {:02X} of size {}.", opcode, uint32(buff.size() - 1));
break;
}
}
@@ -255,13 +255,13 @@ bool Warden::ProcessLuaCheckResponse(std::string const& msg)
if (check.Type == LUA_EVAL_CHECK)
{
char const* penalty = ApplyPenalty(&check);
- TC_LOG_WARN("warden", "%s failed Warden check %u (%s). Action: %s", _session->GetPlayerInfo().c_str(), id, EnumUtils::ToConstant(check.Type), penalty);
+ TC_LOG_WARN("warden", "{} failed Warden check {} ({}). Action: {}", _session->GetPlayerInfo(), id, EnumUtils::ToConstant(check.Type), penalty);
return true;
}
}
char const* penalty = ApplyPenalty(nullptr);
- TC_LOG_WARN("warden", "%s sent bogus Lua check response for Warden. Action: %s", _session->GetPlayerInfo().c_str(), penalty);
+ TC_LOG_WARN("warden", "{} sent bogus Lua check response for Warden. Action: {}", _session->GetPlayerInfo(), penalty);
return true;
}
diff --git a/src/server/game/Warden/WardenCheckMgr.cpp b/src/server/game/Warden/WardenCheckMgr.cpp
index 5b05b4ab25d..b9a9645e605 100644
--- a/src/server/game/Warden/WardenCheckMgr.cpp
+++ b/src/server/game/Warden/WardenCheckMgr.cpp
@@ -67,13 +67,13 @@ void WardenCheckMgr::LoadWardenChecks()
if (category == NUM_CHECK_CATEGORIES)
{
- TC_LOG_ERROR("sql.sql", "Warden check with id %u lists check type %u in `warden_checks`, which is not supported. Skipped.", id, type);
+ TC_LOG_ERROR("sql.sql", "Warden check with id {} lists check type {} in `warden_checks`, which is not supported. Skipped.", id, type);
continue;
}
if ((type == LUA_EVAL_CHECK) && (id > 9999))
{
- TC_LOG_ERROR("sql.sql", "Warden Lua check with id %u found in `warden_checks`. Lua checks may have four-digit IDs at most. Skipped.", id);
+ TC_LOG_ERROR("sql.sql", "Warden Lua check with id {} found in `warden_checks`. Lua checks may have four-digit IDs at most. Skipped.", id);
continue;
}
@@ -105,11 +105,11 @@ void WardenCheckMgr::LoadWardenChecks()
{
if (wardenCheck.Str.size() > WARDEN_MAX_LUA_CHECK_LENGTH)
{
- TC_LOG_ERROR("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);
+ TC_LOG_ERROR("sql.sql", "Found over-long Lua check for Warden check with id {} in `warden_checks`. Max length is {}. Skipped.", id, WARDEN_MAX_LUA_CHECK_LENGTH);
continue;
}
- std::string str = Trinity::StringFormat("%04u", id);
+ std::string str = Trinity::StringFormat("{:04}", id);
ASSERT(str.size() == 4);
std::copy(str.begin(), str.end(), wardenCheck.IdStr.begin());
}
@@ -122,7 +122,7 @@ void WardenCheckMgr::LoadWardenChecks()
}
while (result->NextRow());
- TC_LOG_INFO("server.loading", ">> Loaded %u warden checks in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
+ TC_LOG_INFO("server.loading", ">> Loaded {} warden checks in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
}
void WardenCheckMgr::LoadWardenOverrides()
@@ -156,10 +156,10 @@ void WardenCheckMgr::LoadWardenOverrides()
// Check if action value is in range (0-2, see WardenActions enum)
if (action > WARDEN_ACTION_BAN)
- TC_LOG_ERROR("warden", "Warden check override action out of range (ID: %u, action: %u)", checkId, action);
+ TC_LOG_ERROR("warden", "Warden check override action out of range (ID: {}, action: {})", checkId, action);
// Check if check actually exists before accessing the _checks vector
else if (checkId >= _checks.size())
- TC_LOG_ERROR("warden", "Warden check action override for non-existing check (ID: %u, action: %u), skipped", checkId, action);
+ TC_LOG_ERROR("warden", "Warden check action override for non-existing check (ID: {}, action: {}), skipped", checkId, action);
else
{
_checks[checkId].Action = WardenActions(action);
@@ -168,7 +168,7 @@ void WardenCheckMgr::LoadWardenOverrides()
}
while (result->NextRow());
- TC_LOG_INFO("server.loading", ">> Loaded %u warden action overrides in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
+ TC_LOG_INFO("server.loading", ">> Loaded {} warden action overrides in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
}
WardenCheckMgr* WardenCheckMgr::instance()
diff --git a/src/server/game/Warden/WardenMac.cpp b/src/server/game/Warden/WardenMac.cpp
index e7c7541c8ea..53aebd39557 100644
--- a/src/server/game/Warden/WardenMac.cpp
+++ b/src/server/game/Warden/WardenMac.cpp
@@ -53,16 +53,16 @@ void WardenMac::Init(WorldSession* pClient, SessionKey const& K)
_inputCrypto.Init(_inputKey);
_outputCrypto.Init(_outputKey);
- TC_LOG_DEBUG("warden", "Server side warden for client %u initializing...", pClient->GetAccountId());
- TC_LOG_DEBUG("warden", "C->S Key: %s", ByteArrayToHexStr(_inputKey).c_str());
- TC_LOG_DEBUG("warden", "S->C Key: %s", ByteArrayToHexStr(_outputKey).c_str());
- TC_LOG_DEBUG("warden", " Seed: %s", ByteArrayToHexStr(_seed).c_str());
+ TC_LOG_DEBUG("warden", "Server side warden for client {} initializing...", pClient->GetAccountId());
+ TC_LOG_DEBUG("warden", "C->S Key: {}", ByteArrayToHexStr(_inputKey));
+ TC_LOG_DEBUG("warden", "S->C Key: {}", ByteArrayToHexStr(_outputKey));
+ TC_LOG_DEBUG("warden", " Seed: {}", ByteArrayToHexStr(_seed));
TC_LOG_DEBUG("warden", "Loading Module...");
MakeModuleForClient();
- TC_LOG_DEBUG("warden", "Module Key: %s", ByteArrayToHexStr(_module->Key).c_str());
- TC_LOG_DEBUG("warden", "Module ID: %s", ByteArrayToHexStr(_module->Id).c_str());
+ TC_LOG_DEBUG("warden", "Module Key: {}", ByteArrayToHexStr(_module->Key));
+ TC_LOG_DEBUG("warden", "Module ID: {}", ByteArrayToHexStr(_module->Id));
RequestModule();
}
@@ -145,7 +145,7 @@ void WardenMac::HandleHashResult(ByteBuffer &buff)
if (result != Trinity::Crypto::SHA1::GetDigestOf(reinterpret_cast<uint8*>(keyIn), 16))
{
char const* penalty = ApplyPenalty(nullptr);
- TC_LOG_WARN("warden", "%s failed hash reply. Action: %s", _session->GetPlayerInfo().c_str(), penalty);
+ TC_LOG_WARN("warden", "{} failed hash reply. Action: {}", _session->GetPlayerInfo(), penalty);
return;
}
diff --git a/src/server/game/Warden/WardenWin.cpp b/src/server/game/Warden/WardenWin.cpp
index b3862a316a2..9ac76cb2977 100644
--- a/src/server/game/Warden/WardenWin.cpp
+++ b/src/server/game/Warden/WardenWin.cpp
@@ -66,16 +66,16 @@ void WardenWin::Init(WorldSession* session, SessionKey const& K)
_inputCrypto.Init(_inputKey);
_outputCrypto.Init(_outputKey);
- TC_LOG_DEBUG("warden", "Server side warden for client %u initializing...", session->GetAccountId());
- TC_LOG_DEBUG("warden", "C->S Key: %s", ByteArrayToHexStr(_inputKey).c_str());
- TC_LOG_DEBUG("warden", "S->C Key: %s", ByteArrayToHexStr(_outputKey).c_str());
- TC_LOG_DEBUG("warden", " Seed: %s", ByteArrayToHexStr(_seed).c_str());
+ TC_LOG_DEBUG("warden", "Server side warden for client {} initializing...", session->GetAccountId());
+ TC_LOG_DEBUG("warden", "C->S Key: {}", ByteArrayToHexStr(_inputKey));
+ TC_LOG_DEBUG("warden", "S->C Key: {}", ByteArrayToHexStr(_outputKey));
+ TC_LOG_DEBUG("warden", " Seed: {}", ByteArrayToHexStr(_seed));
TC_LOG_DEBUG("warden", "Loading Module...");
MakeModuleForClient();
- TC_LOG_DEBUG("warden", "Module Key: %s", ByteArrayToHexStr(_module->Key).c_str());
- TC_LOG_DEBUG("warden", "Module ID: %s", ByteArrayToHexStr(_module->Id).c_str());
+ TC_LOG_DEBUG("warden", "Module Key: {}", ByteArrayToHexStr(_module->Key));
+ TC_LOG_DEBUG("warden", "Module ID: {}", ByteArrayToHexStr(_module->Id));
RequestModule();
}
@@ -169,7 +169,7 @@ void WardenWin::HandleHashResult(ByteBuffer &buff)
if (response != Module.ClientKeySeedHash)
{
char const* penalty = ApplyPenalty(nullptr);
- TC_LOG_WARN("warden", "%s failed hash reply. Action: %s", _session->GetPlayerInfo().c_str(), penalty);
+ TC_LOG_WARN("warden", "{} failed hash reply. Action: {}", _session->GetPlayerInfo(), penalty);
return;
}
@@ -212,7 +212,7 @@ static uint16 GetCheckPacketSize(WardenCheck const& check)
void WardenWin::RequestChecks()
{
- TC_LOG_DEBUG("warden", "Request data from %s (account %u) - loaded: %u", _session->GetPlayerName().c_str(), _session->GetAccountId(), _session->GetPlayer() && !_session->PlayerLoading());
+ TC_LOG_DEBUG("warden", "Request data from {} (account {}) - loaded: {}", _session->GetPlayerName(), _session->GetAccountId(), _session->GetPlayer() && !_session->PlayerLoading());
// If all checks for a category are done, fill its todo list again
for (WardenCheckCategory category : EnumUtils::Iterate<WardenCheckCategory>())
@@ -220,7 +220,7 @@ void WardenWin::RequestChecks()
auto& [checks, checksIt] = _checks[category];
if ((checksIt == checks.end()) && !checks.empty())
{
- TC_LOG_DEBUG("warden", "Finished all %s checks, re-shuffling", EnumUtils::ToConstant(category));
+ TC_LOG_DEBUG("warden", "Finished all {} checks, re-shuffling", EnumUtils::ToConstant(category));
Trinity::Containers::RandomShuffle(checks);
checksIt = checks.begin();
}
@@ -356,13 +356,13 @@ void WardenWin::RequestChecks()
if (buff.size() == expectedSize)
{
- TC_LOG_DEBUG("warden", "Finished building warden packet, size is %zu bytes", buff.size());
- TC_LOG_DEBUG("warden", "Sent checks: %s", idstring().c_str());
+ TC_LOG_DEBUG("warden", "Finished building warden packet, size is {} bytes", buff.size());
+ TC_LOG_DEBUG("warden", "Sent checks: {}", idstring());
}
else
{
- TC_LOG_WARN("warden", "Finished building warden packet, size is %zu bytes, but expected %u bytes!", buff.size(), expectedSize);
- TC_LOG_WARN("warden", "Sent checks: %s", idstring().c_str());
+ TC_LOG_WARN("warden", "Finished building warden packet, size is {} bytes, but expected {} bytes!", buff.size(), expectedSize);
+ TC_LOG_WARN("warden", "Sent checks: {}", idstring());
}
// Encrypt with warden RC4 key
@@ -391,7 +391,7 @@ void WardenWin::HandleCheckResult(ByteBuffer &buff)
{
buff.rfinish();
char const* penalty = ApplyPenalty(nullptr);
- TC_LOG_WARN("warden", "%s sends manipulated warden packet. Action: %s", _session->GetPlayerInfo().c_str(), penalty);
+ TC_LOG_WARN("warden", "{} sends manipulated warden packet. Action: {}", _session->GetPlayerInfo(), penalty);
return;
}
@@ -399,7 +399,7 @@ void WardenWin::HandleCheckResult(ByteBuffer &buff)
{
buff.rfinish();
char const* penalty = ApplyPenalty(nullptr);
- TC_LOG_WARN("warden", "%s failed checksum. Action: %s", _session->GetPlayerInfo().c_str(), penalty);
+ TC_LOG_WARN("warden", "{} failed checksum. Action: {}", _session->GetPlayerInfo(), penalty);
return;
}
@@ -411,7 +411,7 @@ void WardenWin::HandleCheckResult(ByteBuffer &buff)
if (result == 0x00)
{
char const* penalty = ApplyPenalty(nullptr);
- TC_LOG_WARN("warden", "%s failed timing check. Action: %s", _session->GetPlayerInfo().c_str(), penalty);
+ TC_LOG_WARN("warden", "{} failed timing check. Action: {}", _session->GetPlayerInfo(), penalty);
return;
}
@@ -421,10 +421,10 @@ void WardenWin::HandleCheckResult(ByteBuffer &buff)
uint32 ticksNow = GameTime::GetGameTimeMS();
uint32 ourTicks = newClientTicks + (ticksNow - _serverTicks);
- TC_LOG_DEBUG("warden", "Server tick count now: %u", ticksNow);
- TC_LOG_DEBUG("warden", "Server tick count at req: %u", _serverTicks);
- TC_LOG_DEBUG("warden", "Client ticks in response: %u", newClientTicks);
- TC_LOG_DEBUG("warden", "Round trip response time: %u ms", ourTicks - newClientTicks);
+ TC_LOG_DEBUG("warden", "Server tick count now: {}", ticksNow);
+ TC_LOG_DEBUG("warden", "Server tick count at req: {}", _serverTicks);
+ TC_LOG_DEBUG("warden", "Client ticks in response: {}", newClientTicks);
+ TC_LOG_DEBUG("warden", "Round trip response time: {} ms", ourTicks - newClientTicks);
}
uint16 checkFailed = 0;
@@ -441,7 +441,7 @@ void WardenWin::HandleCheckResult(ByteBuffer &buff)
if (Mem_Result != 0)
{
- TC_LOG_DEBUG("warden", "RESULT MEM_CHECK not 0x00, CheckId %u account Id %u", id, _session->GetAccountId());
+ TC_LOG_DEBUG("warden", "RESULT MEM_CHECK not 0x00, CheckId {} account Id {}", id, _session->GetAccountId());
checkFailed = id;
continue;
}
@@ -454,14 +454,14 @@ void WardenWin::HandleCheckResult(ByteBuffer &buff)
if (response != expected)
{
- TC_LOG_DEBUG("warden", "RESULT MEM_CHECK fail CheckId %u account Id %u", id, _session->GetAccountId());
- TC_LOG_DEBUG("warden", "Expected: %s", ByteArrayToHexStr(expected).c_str());
- TC_LOG_DEBUG("warden", "Got: %s", ByteArrayToHexStr(response).c_str());
+ TC_LOG_DEBUG("warden", "RESULT MEM_CHECK fail CheckId {} account Id {}", id, _session->GetAccountId());
+ TC_LOG_DEBUG("warden", "Expected: {}", ByteArrayToHexStr(expected));
+ TC_LOG_DEBUG("warden", "Got: {}", ByteArrayToHexStr(response));
checkFailed = id;
continue;
}
- TC_LOG_DEBUG("warden", "RESULT MEM_CHECK passed CheckId %u account Id %u", id, _session->GetAccountId());
+ TC_LOG_DEBUG("warden", "RESULT MEM_CHECK passed CheckId {} account Id {}", id, _session->GetAccountId());
break;
}
case PAGE_CHECK_A:
@@ -471,12 +471,12 @@ void WardenWin::HandleCheckResult(ByteBuffer &buff)
{
if (buff.read<uint8>() != 0xE9)
{
- TC_LOG_DEBUG("warden", "RESULT %s fail, CheckId %u account Id %u", EnumUtils::ToConstant(check.Type), id, _session->GetAccountId());
+ TC_LOG_DEBUG("warden", "RESULT {} fail, CheckId {} account Id {}", EnumUtils::ToConstant(check.Type), id, _session->GetAccountId());
checkFailed = id;
continue;
}
- TC_LOG_DEBUG("warden", "RESULT %s passed CheckId %u account Id %u", EnumUtils::ToConstant(check.Type), id, _session->GetAccountId());
+ TC_LOG_DEBUG("warden", "RESULT {} passed CheckId {} account Id {}", EnumUtils::ToConstant(check.Type), id, _session->GetAccountId());
break;
}
case LUA_EVAL_CHECK:
@@ -485,7 +485,7 @@ void WardenWin::HandleCheckResult(ByteBuffer &buff)
if (result == 0)
buff.read_skip(buff.read<uint8>()); // discard attached string
- TC_LOG_DEBUG("warden", "LUA_EVAL_CHECK CheckId %u account Id %u got in-warden dummy response (%u)", id, _session->GetAccountId(), result);
+ TC_LOG_DEBUG("warden", "LUA_EVAL_CHECK CheckId {} account Id {} got in-warden dummy response ({})", id, _session->GetAccountId(), result);
break;
}
case MPQ_CHECK:
@@ -495,7 +495,7 @@ void WardenWin::HandleCheckResult(ByteBuffer &buff)
if (Mpq_Result != 0)
{
- TC_LOG_DEBUG("warden", "RESULT MPQ_CHECK not 0x00 account id %u", _session->GetAccountId());
+ TC_LOG_DEBUG("warden", "RESULT MPQ_CHECK not 0x00 account id {}", _session->GetAccountId());
checkFailed = id;
continue;
}
@@ -505,12 +505,12 @@ void WardenWin::HandleCheckResult(ByteBuffer &buff)
buff.read(result.data(), result.size());
if (result != sWardenCheckMgr->GetCheckResult(id)) // SHA1
{
- TC_LOG_DEBUG("warden", "RESULT MPQ_CHECK fail, CheckId %u account Id %u", id, _session->GetAccountId());
+ TC_LOG_DEBUG("warden", "RESULT MPQ_CHECK fail, CheckId {} account Id {}", id, _session->GetAccountId());
checkFailed = id;
continue;
}
- TC_LOG_DEBUG("warden", "RESULT MPQ_CHECK passed, CheckId %u account Id %u", id, _session->GetAccountId());
+ TC_LOG_DEBUG("warden", "RESULT MPQ_CHECK passed, CheckId {} account Id {}", id, _session->GetAccountId());
break;
}
default: // Should never happen
@@ -522,7 +522,7 @@ void WardenWin::HandleCheckResult(ByteBuffer &buff)
{
WardenCheck const& check = sWardenCheckMgr->GetCheckData(checkFailed);
char const* penalty = ApplyPenalty(&check);
- TC_LOG_WARN("warden", "%s failed Warden check %u (%s). Action: %s", _session->GetPlayerInfo().c_str(), checkFailed, EnumUtils::ToConstant(check.Type), penalty);
+ TC_LOG_WARN("warden", "{} failed Warden check {} ({}). Action: {}", _session->GetPlayerInfo(), checkFailed, EnumUtils::ToConstant(check.Type), penalty);
}
// Set hold off timer, minimum timer should at least be 1 second