mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-22 16:28:28 +00:00
[Logging] Netcode Logging Unify (#2443)
* [Logging] Unify netcode logging * More tweaks, generator * Exclude OP_SpecialMesg at callback level * Consolidate packet loggers * Log at EQStream level instead of proxy * Fix C->S * Server to server logging * C-S for Loginserver * Hook UCS for C->S * Update eqemu_logsys.h * World C->S logging * Translate opcodes through patch system for client to server * Additional logging requests * Add detailed opcode translation logging * vStringFormat resiliency * Translate loginserver C->S * Simplify out message string (reduce copies) and ignore legacy formats * Update eqemu_logsys.cpp * Log file format * Handle deprecated categories
This commit is contained in:
+37
-52
@@ -26,13 +26,13 @@ bool Client::Process()
|
||||
{
|
||||
EQApplicationPacket *app = m_connection->PopPacket();
|
||||
while (app) {
|
||||
if (server.options.IsTraceOn()) {
|
||||
LogDebug("Application packet received from client (size {0})", app->Size());
|
||||
}
|
||||
|
||||
if (server.options.IsDumpInPacketsOn()) {
|
||||
DumpPacket(app);
|
||||
}
|
||||
LogPacketClientServer(
|
||||
"[{}] [{:#06x}] Size [{}] {}",
|
||||
OpcodeManager::EmuToName(app->GetOpcode()),
|
||||
m_connection->GetOpcodeManager()->EmuToEQ(app->GetOpcode()),
|
||||
app->Size(),
|
||||
(LogSys.IsLogEnabled(Logs::Detail, Logs::PacketClientServer) ? DumpPacketToString(app) : "")
|
||||
);
|
||||
|
||||
if (m_client_status == cs_failed_to_login) {
|
||||
delete app;
|
||||
@@ -42,9 +42,7 @@ bool Client::Process()
|
||||
|
||||
switch (app->GetOpcode()) {
|
||||
case OP_SessionReady: {
|
||||
if (server.options.IsTraceOn()) {
|
||||
LogInfo("Session ready received from client");
|
||||
}
|
||||
LogInfo("Session ready received from client account {}", GetClientDescription());
|
||||
Handle_SessionReady((const char *) app->pBuffer, app->Size());
|
||||
break;
|
||||
}
|
||||
@@ -54,9 +52,7 @@ bool Client::Process()
|
||||
break;
|
||||
}
|
||||
|
||||
if (server.options.IsTraceOn()) {
|
||||
LogInfo("Login received from client");
|
||||
}
|
||||
LogInfo("Login received from client {}", GetClientDescription());
|
||||
|
||||
Handle_Login((const char *) app->pBuffer, app->Size());
|
||||
break;
|
||||
@@ -67,9 +63,7 @@ bool Client::Process()
|
||||
break;
|
||||
}
|
||||
|
||||
if (server.options.IsTraceOn()) {
|
||||
LogDebug("Server list request received from client");
|
||||
}
|
||||
LogInfo("Server list request received from client {}", GetClientDescription());
|
||||
|
||||
SendServerListPacket(*(uint32_t *) app->pBuffer);
|
||||
break;
|
||||
@@ -84,11 +78,9 @@ bool Client::Process()
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
if (LogSys.log_settings[Logs::PacketClientServerUnhandled].is_category_enabled == 1) {
|
||||
char dump[64];
|
||||
app->build_header_dump(dump);
|
||||
LogError("Recieved unhandled application packet from the client: [{}]", dump);
|
||||
}
|
||||
char dump[64];
|
||||
app->build_header_dump(dump);
|
||||
LogError("Received unhandled application packet from the client: [{}]", dump);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,10 +120,6 @@ void Client::Handle_SessionReady(const char *data, unsigned int size)
|
||||
buf->base_reply.success = true;
|
||||
buf->base_reply.error_str_id = 0x65; // 101 "No Error"
|
||||
|
||||
if (server.options.IsDumpOutPacketsOn()) {
|
||||
DumpPacket(outapp);
|
||||
}
|
||||
|
||||
m_connection->QueuePacket(outapp);
|
||||
delete outapp;
|
||||
}
|
||||
@@ -290,14 +278,12 @@ void Client::Handle_Play(const char *data)
|
||||
auto server_id_in = (unsigned int) play->server_number;
|
||||
auto sequence_in = (unsigned int) play->base_header.sequence;
|
||||
|
||||
if (server.options.IsTraceOn()) {
|
||||
LogInfo(
|
||||
"Play received from client [{0}] server number {1} sequence {2}",
|
||||
GetAccountName(),
|
||||
server_id_in,
|
||||
sequence_in
|
||||
);
|
||||
}
|
||||
LogInfo(
|
||||
"[Handle_Play] Play received from client [{}] server number [{}] sequence [{}]",
|
||||
GetAccountName(),
|
||||
server_id_in,
|
||||
sequence_in
|
||||
);
|
||||
|
||||
m_play_server_id = (unsigned int) play->server_number;
|
||||
m_play_sequence_id = sequence_in;
|
||||
@@ -310,21 +296,14 @@ void Client::Handle_Play(const char *data)
|
||||
*/
|
||||
void Client::SendServerListPacket(uint32 seq)
|
||||
{
|
||||
auto outapp = server.server_manager->CreateServerListPacket(this, seq);
|
||||
auto app = server.server_manager->CreateServerListPacket(this, seq);
|
||||
|
||||
if (server.options.IsDumpOutPacketsOn()) {
|
||||
DumpPacket(outapp.get());
|
||||
}
|
||||
|
||||
m_connection->QueuePacket(outapp.get());
|
||||
m_connection->QueuePacket(app.get());
|
||||
}
|
||||
|
||||
void Client::SendPlayResponse(EQApplicationPacket *outapp)
|
||||
{
|
||||
if (server.options.IsTraceOn()) {
|
||||
LogDebug("Sending play response for {0}", GetAccountName());
|
||||
// server_log->LogPacket(log_network_trace, (const char*)outapp->pBuffer, outapp->size);
|
||||
}
|
||||
LogInfo("Sending play response for {}", GetClientDescription());
|
||||
m_connection->QueuePacket(outapp);
|
||||
}
|
||||
|
||||
@@ -422,10 +401,6 @@ void Client::DoFailedLogin()
|
||||
outapp.WriteData(&base_header, sizeof(base_header));
|
||||
outapp.WriteData(&encrypted_buffer, sizeof(encrypted_buffer));
|
||||
|
||||
if (server.options.IsDumpOutPacketsOn()) {
|
||||
DumpPacket(&outapp);
|
||||
}
|
||||
|
||||
m_connection->QueuePacket(&outapp);
|
||||
m_client_status = cs_failed_to_login;
|
||||
}
|
||||
@@ -576,10 +551,6 @@ void Client::DoSuccessfulLogin(
|
||||
outapp->WriteData(&base_header, sizeof(base_header));
|
||||
outapp->WriteData(&encrypted_buffer, sizeof(encrypted_buffer));
|
||||
|
||||
if (server.options.IsDumpOutPacketsOn()) {
|
||||
DumpPacket(outapp.get());
|
||||
}
|
||||
|
||||
m_connection->QueuePacket(outapp.get());
|
||||
|
||||
m_client_status = cs_logged_in;
|
||||
@@ -596,7 +567,7 @@ void Client::SendExpansionPacketData(PlayerLoginReply_Struct& plrs)
|
||||
|
||||
|
||||
if (server.options.IsDisplayExpansions()) {
|
||||
|
||||
|
||||
int32_t expansion = server.options.GetMaxExpansions();
|
||||
int32_t owned_expansion = (expansion << 1) | 1;
|
||||
|
||||
@@ -839,3 +810,17 @@ bool Client::ProcessHealthCheck(std::string username)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string Client::GetClientDescription()
|
||||
{
|
||||
in_addr in{};
|
||||
in.s_addr = GetConnection()->GetRemoteIP();
|
||||
std::string client_ip = inet_ntoa(in);
|
||||
|
||||
return fmt::format(
|
||||
"account_name [{}] account_id ({}) ip_address [{}]",
|
||||
GetAccountName(),
|
||||
GetAccountID(),
|
||||
client_ip
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user