feat(Core/Network): Per-user togglable packet logging (#23254)

Co-authored-by: Ryan Turner <16946913+TheSCREWEDSoftware@users.noreply.github.com>
This commit is contained in:
killerwife
2025-10-16 11:57:16 +02:00
committed by GitHub
parent 4c3eab650c
commit 72d060f097
6 changed files with 49 additions and 4 deletions

View File

@@ -117,7 +117,7 @@ void EncryptableAndCompressiblePacket::CompressIfNeeded()
}
WorldSocket::WorldSocket(tcp::socket&& socket)
: Socket(std::move(socket)), _OverSpeedPings(0), _worldSession(nullptr), _authed(false), _sendBufferSize(4096)
: Socket(std::move(socket)), _OverSpeedPings(0), _worldSession(nullptr), _authed(false), _sendBufferSize(4096), _loggingPackets(false)
{
Acore::Crypto::GetRandomBytes(_authSeed);
_headerBuffer.Resize(sizeof(ClientPktHeader));
@@ -406,7 +406,7 @@ WorldSocket::ReadDataHandlerResult WorldSocket::ReadDataHandler()
WorldPacket packet(opcode, std::move(_packetBuffer));
WorldPacket* packetToQueue;
if (sPacketLog->CanLogPacket())
if (sPacketLog->CanLogPacket() && IsLoggingPackets())
sPacketLog->LogPacket(packet, CLIENT_TO_SERVER, GetRemoteIpAddress(), GetRemotePort());
std::unique_lock<std::mutex> sessionGuard(_worldSessionLock, std::defer_lock);
@@ -520,7 +520,7 @@ void WorldSocket::SendPacket(WorldPacket const& packet)
if (!IsOpen())
return;
if (sPacketLog->CanLogPacket())
if (sPacketLog->CanLogPacket() && IsLoggingPackets())
sPacketLog->LogPacket(packet, SERVER_TO_CLIENT, GetRemoteIpAddress(), GetRemotePort());
_bufferQueue.Enqueue(new EncryptableAndCompressiblePacket(packet, _authCrypt.IsInitialized()));