Skip to content

Commit

Permalink
Re-enable world packet logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian committed Aug 17, 2016
1 parent 5319c06 commit 0c9c359
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/game/WorldSocket.cpp
Expand Up @@ -99,7 +99,7 @@ void WorldSocket::SendPacket(const WorldPacket& pct, bool immediate)
return;

// Dump outgoing packet.
//sLog.outWorldPacketDump(uint32(get_handle()), pct.GetOpcode(), pct.GetOpcodeName(), &pct, false);
sLog.outWorldPacketDump(GetRemoteEndpoint().c_str(), pct.GetOpcode(), pct.GetOpcodeName(), &pct, false);

ServerPktHeader header(pct.size() + 2, pct.GetOpcode());
m_crypt.EncryptSend((uint8*)header.header, header.getHeaderLength());
Expand Down Expand Up @@ -206,15 +206,16 @@ bool WorldSocket::ProcessIncomingData()

WorldPacket *pct = new WorldPacket(opcode, validBytesRemaining);

// Dump received packet.
//sLog.outWorldPacketDump(uint32(get_handle()), pct->GetOpcode(), pct->GetOpcodeName(), pct, true);

if (validBytesRemaining)
{
pct->append(InPeak(), validBytesRemaining);
ReadSkip(validBytesRemaining);
}

// Dump received packet.
if (opcode != 0x4C524F57)
sLog.outWorldPacketDump(GetRemoteEndpoint().c_str(), pct->GetOpcode(), pct->GetOpcodeName(), pct, true);

try
{
switch (opcode)
Expand Down
4 changes: 2 additions & 2 deletions src/shared/Log.cpp
Expand Up @@ -888,7 +888,7 @@ void Log::outErrorScriptLib(const char* err, ...)
fflush(stderr);
}

void Log::outWorldPacketDump(uint32 socket, uint32 opcode, char const* opcodeName, ByteBuffer const* packet, bool incoming)
void Log::outWorldPacketDump(const char* socket, uint32 opcode, char const* opcodeName, ByteBuffer const* packet, bool incoming)
{
if (!worldLogfile)
return;
Expand All @@ -897,7 +897,7 @@ void Log::outWorldPacketDump(uint32 socket, uint32 opcode, char const* opcodeNam

outTimestamp(worldLogfile);

fprintf(worldLogfile, "\n%s:\nSOCKET: %u\nLENGTH: %u\nOPCODE: %s (0x%.4X)\nDATA:\n",
fprintf(worldLogfile, "\n%s:\nSOCKET: %s\nLENGTH: %u\nOPCODE: %s (0x%.4X)\nDATA:\n",
incoming ? "CLIENT" : "SERVER",
socket, static_cast<uint32>(packet->size()), opcodeName, opcode);

Expand Down
2 changes: 1 addition & 1 deletion src/shared/Log.h
Expand Up @@ -162,7 +162,7 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, std::m
// any log level
void outErrorScriptLib(const char* str, ...) ATTR_PRINTF(2, 3);

void outWorldPacketDump(uint32 socket, uint32 opcode, char const* opcodeName, ByteBuffer const* packet, bool incoming);
void outWorldPacketDump(const char* socket, uint32 opcode, char const* opcodeName, ByteBuffer const* packet, bool incoming);
// any log level
void outCharDump(const char* str, uint32 account_id, uint32 guid, const char* name);
void outRALog(const char* str, ...) ATTR_PRINTF(2, 3);
Expand Down
2 changes: 2 additions & 0 deletions src/shared/Network/Socket.cpp
Expand Up @@ -23,6 +23,7 @@

#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/lexical_cast.hpp>

#include "Socket.hpp"
#include "Log.h"
Expand All @@ -38,6 +39,7 @@ bool Socket::Open()
try
{
const_cast<std::string &>(m_address) = m_socket.remote_endpoint().address().to_string();
const_cast<std::string &>(m_remoteEndpoint) = boost::lexical_cast<std::string>(m_socket.remote_endpoint());
}
catch (boost::system::error_code& error)
{
Expand Down
2 changes: 2 additions & 0 deletions src/shared/Network/Socket.hpp
Expand Up @@ -77,6 +77,7 @@ namespace MaNGOS

protected:
const std::string m_address;
const std::string m_remoteEndpoint;

virtual bool ProcessIncomingData() = 0;

Expand All @@ -103,6 +104,7 @@ namespace MaNGOS

boost::asio::ip::tcp::socket &GetAsioSocket() { return m_socket; }

const std::string &GetRemoteEndpoint() const { return m_remoteEndpoint; }
const std::string &GetRemoteAddress() const { return m_address; }
};
}
Expand Down

0 comments on commit 0c9c359

Please sign in to comment.