[8798] Partly revert and optimize [8797]

* Revert realmd changes:
  - typos in prev. commit prevent correct work of realmd code.
  - useless log login packets
  - and really horrible idea log of patch packets (how nice convert some MB in hex strings)
* Revert output world packet format to more readable old but output timestamp
* Drop outWorld, but use explcit fprintf calls into new outWorldPacketDump.
  Not nice have 16 flush calls at hex line.
This commit is contained in:
VladimirMangos 2009-11-09 15:06:36 +03:00
parent 07aa44992b
commit ea7100ff63
8 changed files with 39 additions and 112 deletions

View file

@ -165,22 +165,7 @@ int WorldSocket::SendPacket (const WorldPacket& pct)
return -1; return -1;
// Dump outgoing packet. // Dump outgoing packet.
if (sLog.IsLogWorld()) sLog.outWorldPacketDump(uint32(get_handle()), pct.GetOpcode(), LookupOpcodeName(pct.GetOpcode()), &pct, false);
{
sLog.outWorld("S->C - SOCKET: %u LENGTH: %u OPCODE: %s (0x%.4X)\n",
uint32(get_handle()), pct.size (), LookupOpcodeName(pct.GetOpcode()), pct.GetOpcode());
size_t p = 0;
while (p < pct.size())
{
for (size_t j = 0; j < 16 && p < pct.size(); ++j)
sLog.outWorld("%.2X ", const_cast<WorldPacket&>(pct)[p++]);
sLog.outWorld("\n");
}
sLog.outWorld("\n\n");
}
ServerPktHeader header(pct.size()+2, pct.GetOpcode()); ServerPktHeader header(pct.size()+2, pct.GetOpcode());
m_Crypt.EncryptSend ((uint8*)header.header, header.getHeaderLength()); m_Crypt.EncryptSend ((uint8*)header.header, header.getHeaderLength());
@ -678,22 +663,7 @@ int WorldSocket::ProcessIncoming (WorldPacket* new_pct)
return -1; return -1;
// Dump received packet. // Dump received packet.
if (sLog.IsLogWorld()) sLog.outWorldPacketDump(uint32(get_handle()), new_pct->GetOpcode(), LookupOpcodeName(new_pct->GetOpcode()), new_pct, true);
{
sLog.outWorld("C->S - SOCKET: %u LENGTH: %u OPCODE: %s (0x%.4X)\n",
uint32(get_handle()), new_pct->size(), LookupOpcodeName(new_pct->GetOpcode()), new_pct->GetOpcode());
size_t p = 0;
while (p < new_pct->size())
{
for (size_t j = 0; j < 16 && p < new_pct->size(); ++j)
sLog.outWorld("%.2X ", (*new_pct)[p++]);
sLog.outWorld("\n");
}
sLog.outWorld("\n\n");
}
try try
{ {

View file

@ -235,6 +235,11 @@ AddonChannel = 1
# Packet logging file for the worldserver # Packet logging file for the worldserver
# Default: "world.log" # Default: "world.log"
# #
# WorldLogTimestamp
# Logfile with timestamp of server start in name
# Default: 0 - no timestamp in name
# 1 - add timestamp in name in form Logname_YYYY-MM-DD_HH-MM-SS.Ext for Logname.Ext
#
# DBErrorLogFile # DBErrorLogFile
# Log file of DB errors detected at server run # Log file of DB errors detected at server run
# Default: "DBErrors.log" # Default: "DBErrors.log"

View file

@ -22,6 +22,7 @@
#include "Common.h" #include "Common.h"
#include "Database/DatabaseEnv.h" #include "Database/DatabaseEnv.h"
#include "ByteBuffer.h"
#include "Config/ConfigEnv.h" #include "Config/ConfigEnv.h"
#include "Log.h" #include "Log.h"
#include "RealmList.h" #include "RealmList.h"
@ -251,37 +252,14 @@ void AuthSocket::OnRead()
///- Read the packet ///- Read the packet
TcpSocket::OnRead(); TcpSocket::OnRead();
uint8 _cmd; uint8 _cmd;
while (true) while (1)
{ {
if (!ibuf.GetLength()) if (!ibuf.GetLength())
return; return;
///- Get the command out of it. We can assume it's there, since length is not 0. ///- Get the command out of it
ibuf.SoftRead((char *)&_cmd, 1); // UQ1: No longer exists in new net code ??? ibuf.SoftRead((char *)&_cmd, 1); // UQ1: No longer exists in new net code ???
// Dump incoming packet.
if (sLog.IsLogWorld())
{
sLog.outWorld ("C->S - SOCKET: %u LENGTH: %u OPCODE: 0x%.4X\n",
GetSocket(), ibuf.GetLength(), _cmd);
size_t p = 0;
while (p < ibuf.GetLength())
{
char dest;
for (size_t j = 0; j < 16 && p < ibuf.GetLength(); ++j)
{
ibuf.SoftRead(&dest, 1);
sLog.outWorld("%.2X ", *((uint8*)dest));
p++;
}
sLog.outWorld("\n");
}
sLog.outWorld("\n\n");
}
size_t i; size_t i;
///- Circle through known commands and call the correct command handler ///- Circle through known commands and call the correct command handler
@ -311,34 +289,7 @@ void AuthSocket::OnRead()
} }
} }
void AuthSocket::SendPacket(ByteBuffer* buf) /// Make the SRP6 calculation from hash in dB
{
// TODO: Also handle outgoing structs?
uint8 _cmd = buf->read<uint8>();
// Dump outgoing packet.
if (sLog.IsLogWorld())
{
sLog.outWorld ("S->C - SOCKET: %u LENGTH: %u OPCODE: 0x%.4X\n",
GetSocket(), buf->size(), _cmd);
size_t p = 0;
while (p < buf->size())
{
for (size_t j = 0; j < 16 && p < buf->size(); ++j)
sLog.outWorld("%.2X ", (*buf)[p++]);
sLog.outWorld("\n");
}
sLog.outWorld("\n\n");
}
SendBuf((char const*)buf->contents(), buf->size());
}
/// Make the SRP6 calculation from hash in DB
void AuthSocket::_SetVSFields(const std::string& rI) void AuthSocket::_SetVSFields(const std::string& rI)
{ {
s.SetRand(s_BYTE_SIZE * 8); s.SetRand(s_BYTE_SIZE * 8);
@ -570,8 +521,7 @@ bool AuthSocket::_HandleLogonChallenge()
pkt<< (uint8) REALM_AUTH_NO_MATCH; pkt<< (uint8) REALM_AUTH_NO_MATCH;
} }
} }
SendBuf((char const*)pkt.contents(), pkt.size());
SendPacket(&pkt);
return true; return true;
} }
@ -617,7 +567,7 @@ bool AuthSocket::_HandleLogonProof()
pkt << (uint8) REALM_AUTH_WRONG_BUILD_NUMBER; pkt << (uint8) REALM_AUTH_WRONG_BUILD_NUMBER;
DEBUG_LOG("[AuthChallenge] %u is not a valid client version!", _build); DEBUG_LOG("[AuthChallenge] %u is not a valid client version!", _build);
DEBUG_LOG("[AuthChallenge] Patch %s not found", tmp); DEBUG_LOG("[AuthChallenge] Patch %s not found", tmp);
SendPacket(&pkt); SendBuf((char const*)pkt.contents(), pkt.size());
return true; return true;
} }
else // have patch else // have patch
@ -857,7 +807,7 @@ bool AuthSocket::_HandleReconnectChallenge()
_reconnectProof.SetRand(16 * 8); _reconnectProof.SetRand(16 * 8);
pkt.append(_reconnectProof.AsByteArray(16),16); // 16 bytes random pkt.append(_reconnectProof.AsByteArray(16),16); // 16 bytes random
pkt << (uint64) 0x00 << (uint64) 0x00; // 16 bytes zeros pkt << (uint64) 0x00 << (uint64) 0x00; // 16 bytes zeros
SendPacket(&pkt); SendBuf((char const*)pkt.contents(), pkt.size());
return true; return true;
} }
@ -889,7 +839,7 @@ bool AuthSocket::_HandleReconnectProof()
pkt << (uint8) AUTH_RECONNECT_PROOF; pkt << (uint8) AUTH_RECONNECT_PROOF;
pkt << (uint8) 0x00; pkt << (uint8) 0x00;
pkt << (uint16) 0x00; // 2 bytes zeros pkt << (uint16) 0x00; // 2 bytes zeros
SendPacket(&pkt); SendBuf((char const*)pkt.contents(), pkt.size());
///- Set _authed to true! ///- Set _authed to true!
_authed = true; _authed = true;
@ -971,7 +921,7 @@ bool AuthSocket::_HandleRealmList()
hdr << (uint16)pkt.size(); hdr << (uint16)pkt.size();
hdr.append(pkt); hdr.append(pkt);
SendPacket(&pkt); SendBuf((char const*)hdr.contents(), hdr.size());
return true; return true;
} }

View file

@ -24,7 +24,6 @@
#define _AUTHSOCKET_H #define _AUTHSOCKET_H
#include "Common.h" #include "Common.h"
#include "ByteBuffer.h"
#include "Auth/BigNumber.h" #include "Auth/BigNumber.h"
#include "sockets/TcpSocket.h" #include "sockets/TcpSocket.h"
#include "sockets/SocketHandler.h" #include "sockets/SocketHandler.h"
@ -56,8 +55,6 @@ class AuthSocket: public TcpSocket
bool _HandleXferCancel(); bool _HandleXferCancel();
bool _HandleXferAccept(); bool _HandleXferAccept();
void SendPacket(ByteBuffer* buf);
void _SetVSFields(const std::string& rI); void _SetVSFields(const std::string& rI);
FILE *pPatch; FILE *pPatch;

View file

@ -49,10 +49,6 @@ ConfVersion=2007062001
# Default: "Realmd.log" # Default: "Realmd.log"
# "" - empty name disable creating log file # "" - empty name disable creating log file
# #
# WorldLogFile
# Packet logging file for the realmserver
# Default: "world.log"
#
# LogTimestamp # LogTimestamp
# Logfile with timestamp of server start in name # Logfile with timestamp of server start in name
# Default: 0 - no timestamp in name # Default: 0 - no timestamp in name
@ -109,7 +105,6 @@ PidFile = ""
LogLevel = 0 LogLevel = 0
LogTime = 0 LogTime = 0
LogFile = "Realmd.log" LogFile = "Realmd.log"
WorldLogFile = ""
LogTimestamp = 0 LogTimestamp = 0
LogFileLevel = 0 LogFileLevel = 0
LogColors = "" LogColors = ""

View file

@ -21,6 +21,7 @@
#include "Policies/SingletonImp.h" #include "Policies/SingletonImp.h"
#include "Config/ConfigEnv.h" #include "Config/ConfigEnv.h"
#include "Util.h" #include "Util.h"
#include "ByteBuffer.h"
#include <stdarg.h> #include <stdarg.h>
@ -227,7 +228,7 @@ void Log::Initialize()
charLogfile = openLogFile("CharLogFile","CharLogTimestamp","a"); charLogfile = openLogFile("CharLogFile","CharLogTimestamp","a");
dberLogfile = openLogFile("DBErrorLogFile",NULL,"a"); dberLogfile = openLogFile("DBErrorLogFile",NULL,"a");
raLogfile = openLogFile("RaLogFile",NULL,"a"); raLogfile = openLogFile("RaLogFile",NULL,"a");
worldLogfile = openLogFile("WorldLogFile",NULL,"a"); worldLogfile = openLogFile("WorldLogFile","WorldLogTimestamp","a");
// Main log file settings // Main log file settings
m_includeTime = sConfig.GetBoolDefault("LogTime", false); m_includeTime = sConfig.GetBoolDefault("LogTime", false);
@ -698,19 +699,28 @@ void Log::outChar(const char * str, ... )
} }
} }
void Log::outWorld( const char * str, ... ) void Log::outWorldPacketDump( uint32 socket, uint32 opcode, char const* opcodeName, ByteBuffer const* packet, bool incoming )
{ {
if (!str) if (!worldLogfile)
return; return;
if (worldLogfile) outTimestamp(worldLogfile);
fprintf(worldLogfile,"\n%s:\nSOCKET: %u\nLENGTH: %u\nOPCODE: %s (0x%.4X)\nDATA:\n",
incoming ? "CLIENT" : "SERVER",
socket, packet->size(), opcodeName, opcode);
size_t p = 0;
while (p < packet->size())
{ {
va_list args; for (size_t j = 0; j < 16 && p < packet->size(); ++j)
va_start(args, str); fprintf(worldLogfile, "%.2X ", (*packet)[p++]);
vfprintf(worldLogfile, str, args);
va_end(args); fprintf(worldLogfile, "\n");
fflush(worldLogfile);
} }
fprintf(worldLogfile, "\n\n");
fflush(worldLogfile);
} }
void Log::outCharDump( const char * str, uint32 account_id, uint32 guid, const char * name ) void Log::outCharDump( const char * str, uint32 account_id, uint32 guid, const char * name )

View file

@ -23,6 +23,7 @@
#include "Policies/Singleton.h" #include "Policies/Singleton.h"
class Config; class Config;
class ByteBuffer;
// bitmask // bitmask
enum LogFilters enum LogFilters
@ -110,8 +111,8 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ACE_Th
// any log level // any log level
void outChar( const char * str, ... ) ATTR_PRINTF(2,3); void outChar( const char * str, ... ) ATTR_PRINTF(2,3);
// any log level // any log level
void outWorld( const char * str, ... ) ATTR_PRINTF(2,3); void outWorldPacketDump( uint32 socket, uint32 opcode, char const* opcodeName, ByteBuffer const* packet, bool incoming );
// any log level // any log level
void outCharDump( const char * str, uint32 account_id, uint32 guid, const char * name ); void outCharDump( const char * str, uint32 account_id, uint32 guid, const char * name );
void outRALog( const char * str, ... ) ATTR_PRINTF(2,3); void outRALog( const char * str, ... ) ATTR_PRINTF(2,3);
void SetLogLevel(char * Level); void SetLogLevel(char * Level);
@ -124,7 +125,6 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ACE_Th
uint32 getLogFilter() const { return m_logFilter; } uint32 getLogFilter() const { return m_logFilter; }
bool IsOutDebug() const { return m_logLevel > 2 || (m_logFileLevel > 2 && logfile); } bool IsOutDebug() const { return m_logLevel > 2 || (m_logFileLevel > 2 && logfile); }
bool IsOutCharDump() const { return m_charLog_Dump; } bool IsOutCharDump() const { return m_charLog_Dump; }
bool IsLogWorld() const { return (worldLogfile); }
bool IsIncludeTime() const { return m_includeTime; } bool IsIncludeTime() const { return m_includeTime; }
private: private:
FILE* openLogFile(char const* configFileName,char const* configTimeStampFlag, char const* mode); FILE* openLogFile(char const* configFileName,char const* configTimeStampFlag, char const* mode);

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "8797" #define REVISION_NR "8798"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__