mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 18:51:29 +00:00
Add RFC 5424 logging
This commit is contained in:
parent
86f9a205e5
commit
b2ed5fe479
@ -133,6 +133,17 @@ void EQEmuLogSys::LoadLogSettingsDefaults()
|
|||||||
log_settings[Logs::Headless_Client].log_to_console = Logs::General;
|
log_settings[Logs::Headless_Client].log_to_console = Logs::General;
|
||||||
log_settings[Logs::NPCScaling].log_to_gmsay = Logs::General;
|
log_settings[Logs::NPCScaling].log_to_gmsay = Logs::General;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RFC 5424
|
||||||
|
*/
|
||||||
|
log_settings[Logs::Emergency].log_to_console = Logs::General;
|
||||||
|
log_settings[Logs::Alert].log_to_console = Logs::General;
|
||||||
|
log_settings[Logs::Critical].log_to_console = Logs::General;
|
||||||
|
log_settings[Logs::Error].log_to_console = Logs::General;
|
||||||
|
log_settings[Logs::Warning].log_to_console = Logs::General;
|
||||||
|
log_settings[Logs::Notice].log_to_console = Logs::General;
|
||||||
|
log_settings[Logs::Info].log_to_console = Logs::General;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Category enabled status on defaults
|
* Set Category enabled status on defaults
|
||||||
*/
|
*/
|
||||||
@ -172,6 +183,24 @@ void EQEmuLogSys::LoadLogSettingsDefaults()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param log_category
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
bool EQEmuLogSys::IsRfc5424LogCategory(uint16 log_category)
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
log_category == Logs::Emergency ||
|
||||||
|
log_category == Logs::Alert ||
|
||||||
|
log_category == Logs::Critical ||
|
||||||
|
log_category == Logs::Error ||
|
||||||
|
log_category == Logs::Warning ||
|
||||||
|
log_category == Logs::Notice ||
|
||||||
|
log_category == Logs::Info ||
|
||||||
|
log_category == Logs::Debug
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param log_category
|
* @param log_category
|
||||||
* @param in_message
|
* @param in_message
|
||||||
@ -182,13 +211,13 @@ std::string EQEmuLogSys::FormatOutMessageString(
|
|||||||
const std::string &in_message
|
const std::string &in_message
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
std::string ret;
|
std::string return_string;
|
||||||
ret.push_back('[');
|
|
||||||
ret.append(Logs::LogCategoryName[log_category]);
|
if (IsRfc5424LogCategory(log_category)) {
|
||||||
ret.push_back(']');
|
return_string = "[" + GetPlatformName() + "] ";
|
||||||
ret.push_back(' ');
|
}
|
||||||
ret.append(in_message);
|
|
||||||
return ret;
|
return return_string + "[" + Logs::LogCategoryName[log_category] + "] " + in_message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -390,7 +419,7 @@ constexpr const char *r_slant(const char *str)
|
|||||||
* @param str
|
* @param str
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
constexpr const char *file_name(const char *str)
|
constexpr const char *base_file_name(const char *str)
|
||||||
{
|
{
|
||||||
return str_slant(str) ? r_slant(str_end(str)) : str;
|
return str_slant(str) ? r_slant(str_end(str)) : str;
|
||||||
}
|
}
|
||||||
@ -436,7 +465,7 @@ void EQEmuLogSys::Out(
|
|||||||
std::string prefix;
|
std::string prefix;
|
||||||
|
|
||||||
if (RuleB(Logging, PrintFileFunctionAndLine)) {
|
if (RuleB(Logging, PrintFileFunctionAndLine)) {
|
||||||
prefix = fmt::format("[{0}::{1}:{2}] ", file_name(file), func, line);
|
prefix = fmt::format("[{0}::{1}:{2}] ", base_file_name(file), func, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|||||||
@ -94,6 +94,12 @@ namespace Logs {
|
|||||||
NPCRoamBox,
|
NPCRoamBox,
|
||||||
NPCScaling,
|
NPCScaling,
|
||||||
MobAppearance,
|
MobAppearance,
|
||||||
|
Info,
|
||||||
|
Warning,
|
||||||
|
Critical,
|
||||||
|
Emergency,
|
||||||
|
Alert,
|
||||||
|
Notice,
|
||||||
MaxCategoryID /* Don't Remove this */
|
MaxCategoryID /* Don't Remove this */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -153,15 +159,74 @@ namespace Logs {
|
|||||||
"Traps",
|
"Traps",
|
||||||
"NPC Roam Box",
|
"NPC Roam Box",
|
||||||
"NPC Scaling",
|
"NPC Scaling",
|
||||||
"Mob Appearance"
|
"Mob Appearance",
|
||||||
|
"Info",
|
||||||
|
"Warning",
|
||||||
|
"Critical",
|
||||||
|
"Emergency",
|
||||||
|
"Alert",
|
||||||
|
"Notice"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#define Error(message, ...) do {\
|
/**
|
||||||
|
* RFC 5424
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define LogEmergency(message, ...) do {\
|
||||||
|
if (LogSys.log_settings[Logs::Emergency].is_category_enabled == 1)\
|
||||||
|
OutF(LogSys, Logs::General, Logs::Emergency, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define LogAlert(message, ...) do {\
|
||||||
|
if (LogSys.log_settings[Logs::Alert].is_category_enabled == 1)\
|
||||||
|
OutF(LogSys, Logs::General, Logs::Alert, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define LogCritical(message, ...) do {\
|
||||||
|
if (LogSys.log_settings[Logs::Critical].is_category_enabled == 1)\
|
||||||
|
OutF(LogSys, Logs::General, Logs::Critical, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define LogError(message, ...) do {\
|
||||||
if (LogSys.log_settings[Logs::Error].is_category_enabled == 1)\
|
if (LogSys.log_settings[Logs::Error].is_category_enabled == 1)\
|
||||||
OutF(LogSys, Logs::General, Logs::Error, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
OutF(LogSys, Logs::General, Logs::Error, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
#define LogWarning(message, ...) do {\
|
||||||
|
if (LogSys.log_settings[Logs::Warning].is_category_enabled == 1)\
|
||||||
|
OutF(LogSys, Logs::General, Logs::Warning, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define LogNotice(message, ...) do {\
|
||||||
|
if (LogSys.log_settings[Logs::Notice].is_category_enabled == 1)\
|
||||||
|
OutF(LogSys, Logs::General, Logs::Notice, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define LogInfo(message, ...) do {\
|
||||||
|
if (LogSys.log_settings[Logs::Info].is_category_enabled == 1)\
|
||||||
|
OutF(LogSys, Logs::General, Logs::Info, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define LogDebug(message, ...) do {\
|
||||||
|
if (LogSys.log_settings[Logs::Debug].is_category_enabled == 1)\
|
||||||
|
OutF(LogSys, Logs::General, Logs::Debug, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Other
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define LogStatus(message, ...) do {\
|
||||||
|
if (LogSys.log_settings[Logs::Status].is_category_enabled == 1)\
|
||||||
|
OutF(LogSys, Logs::General, Logs::Status, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define Log(debug_level, log_category, message, ...) do {\
|
#define Log(debug_level, log_category, message, ...) do {\
|
||||||
if (LogSys.log_settings[log_category].is_category_enabled == 1)\
|
if (LogSys.log_settings[log_category].is_category_enabled == 1)\
|
||||||
LogSys.Out(debug_level, log_category, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
LogSys.Out(debug_level, log_category, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||||
@ -172,15 +237,6 @@ namespace Logs {
|
|||||||
OutF(LogSys, debug_level, log_category, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
OutF(LogSys, debug_level, log_category, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define LogLoginserver(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Login_Server].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Login_Server, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogLoginserverDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Login_Server].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Login_Server, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
class EQEmuLogSys {
|
class EQEmuLogSys {
|
||||||
public:
|
public:
|
||||||
@ -329,6 +385,12 @@ private:
|
|||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
void ProcessLogWrite(uint16 debug_level, uint16 log_category, const std::string &message);
|
void ProcessLogWrite(uint16 debug_level, uint16 log_category, const std::string &message);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param log_category
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
bool IsRfc5424LogCategory(uint16 log_category);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern EQEmuLogSys LogSys;
|
extern EQEmuLogSys LogSys;
|
||||||
|
|||||||
@ -1,39 +0,0 @@
|
|||||||
/**
|
|
||||||
* EQEmulator: Everquest Server Emulator
|
|
||||||
* Copyright (C) 2001-2019 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; version 2 of the License.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
|
||||||
* are required to give you total support for your newly bought product;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <fmt/format.h>
|
|
||||||
|
|
||||||
template<typename... Args>
|
|
||||||
void OutF(
|
|
||||||
EQEmuLogSys &ls,
|
|
||||||
Logs::DebugLevel debug_level,
|
|
||||||
uint16 log_category,
|
|
||||||
const char *file,
|
|
||||||
const char *func,
|
|
||||||
int line,
|
|
||||||
const char *fmt,
|
|
||||||
const Args &... args
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string log_str = fmt::format(fmt, args...);
|
|
||||||
ls.Out(debug_level, log_category, file, func, line, log_str);
|
|
||||||
}
|
|
||||||
@ -1,3 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2019 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
EQEmuExePlatform exe_platform = ExePlatformNone;
|
EQEmuExePlatform exe_platform = ExePlatformNone;
|
||||||
@ -10,6 +30,44 @@ const EQEmuExePlatform& GetExecutablePlatform() {
|
|||||||
return exe_platform;
|
return exe_platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
int GetExecutablePlatformInt(){
|
int GetExecutablePlatformInt(){
|
||||||
return exe_platform;
|
return exe_platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns platform name by string
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
std::string GetPlatformName()
|
||||||
|
{
|
||||||
|
switch (GetExecutablePlatformInt()) {
|
||||||
|
case EQEmuExePlatform::ExePlatformWorld:
|
||||||
|
return "WorldServer";
|
||||||
|
case EQEmuExePlatform::ExePlatformQueryServ:
|
||||||
|
return "QueryServer";
|
||||||
|
case EQEmuExePlatform::ExePlatformZone:
|
||||||
|
return "ZoneServer";
|
||||||
|
case EQEmuExePlatform::ExePlatformUCS:
|
||||||
|
return "UCS";
|
||||||
|
case EQEmuExePlatform::ExePlatformLogin:
|
||||||
|
return "LoginServer";
|
||||||
|
case EQEmuExePlatform::ExePlatformSocket_Server:
|
||||||
|
return "SocketServer";
|
||||||
|
case EQEmuExePlatform::ExePlatformSharedMemory:
|
||||||
|
return "SharedMemory";
|
||||||
|
case EQEmuExePlatform::ExePlatformClientImport:
|
||||||
|
return "ClientImport";
|
||||||
|
case EQEmuExePlatform::ExePlatformClientExport:
|
||||||
|
return "ClientExport";
|
||||||
|
case EQEmuExePlatform::ExePlatformLaunch:
|
||||||
|
return "Launch";
|
||||||
|
case EQEmuExePlatform::ExePlatformHC:
|
||||||
|
return "HC";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,6 +1,28 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2019 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef EQEMU_PLATFORM_H
|
#ifndef EQEMU_PLATFORM_H
|
||||||
#define EQEMU_PLATFORM_H
|
#define EQEMU_PLATFORM_H
|
||||||
|
|
||||||
|
#include "iostream"
|
||||||
|
|
||||||
enum EQEmuExePlatform
|
enum EQEmuExePlatform
|
||||||
{
|
{
|
||||||
ExePlatformNone = 0,
|
ExePlatformNone = 0,
|
||||||
@ -20,5 +42,6 @@ enum EQEmuExePlatform
|
|||||||
void RegisterExecutablePlatform(EQEmuExePlatform p);
|
void RegisterExecutablePlatform(EQEmuExePlatform p);
|
||||||
const EQEmuExePlatform& GetExecutablePlatform();
|
const EQEmuExePlatform& GetExecutablePlatform();
|
||||||
int GetExecutablePlatformInt();
|
int GetExecutablePlatformInt();
|
||||||
|
std::string GetPlatformName();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -62,19 +62,19 @@ bool Client::Process()
|
|||||||
switch (app->GetOpcode()) {
|
switch (app->GetOpcode()) {
|
||||||
case OP_SessionReady: {
|
case OP_SessionReady: {
|
||||||
if (server.options.IsTraceOn()) {
|
if (server.options.IsTraceOn()) {
|
||||||
LogLoginserver("Session ready received from client.");
|
LogInfo("Session ready received from client.");
|
||||||
}
|
}
|
||||||
Handle_SessionReady((const char *) app->pBuffer, app->Size());
|
Handle_SessionReady((const char *) app->pBuffer, app->Size());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OP_Login: {
|
case OP_Login: {
|
||||||
if (app->Size() < 20) {
|
if (app->Size() < 20) {
|
||||||
Error("Login received but it is too small, discarding.");
|
LogError("Login received but it is too small, discarding.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server.options.IsTraceOn()) {
|
if (server.options.IsTraceOn()) {
|
||||||
LogLoginserver("Login received from client.");
|
LogInfo("Login received from client.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle_Login((const char *) app->pBuffer, app->Size());
|
Handle_Login((const char *) app->pBuffer, app->Size());
|
||||||
@ -82,12 +82,12 @@ bool Client::Process()
|
|||||||
}
|
}
|
||||||
case OP_ServerListRequest: {
|
case OP_ServerListRequest: {
|
||||||
if (app->Size() < 4) {
|
if (app->Size() < 4) {
|
||||||
Error("Server List Request received but it is too small, discarding.");
|
LogError("Server List Request received but it is too small, discarding.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server.options.IsTraceOn()) {
|
if (server.options.IsTraceOn()) {
|
||||||
LogLoginserver("Server list request received from client.");
|
LogInfo("Server list request received from client.");
|
||||||
}
|
}
|
||||||
|
|
||||||
SendServerListPacket(*(uint32_t *) app->pBuffer);
|
SendServerListPacket(*(uint32_t *) app->pBuffer);
|
||||||
@ -95,7 +95,7 @@ bool Client::Process()
|
|||||||
}
|
}
|
||||||
case OP_PlayEverquestRequest: {
|
case OP_PlayEverquestRequest: {
|
||||||
if (app->Size() < sizeof(PlayEverquestRequest_Struct)) {
|
if (app->Size() < sizeof(PlayEverquestRequest_Struct)) {
|
||||||
Error("Play received but it is too small, discarding.");
|
LogError("Play received but it is too small, discarding.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ bool Client::Process()
|
|||||||
if (LogSys.log_settings[Logs::Client_Server_Packet_Unhandled].is_category_enabled == 1) {
|
if (LogSys.log_settings[Logs::Client_Server_Packet_Unhandled].is_category_enabled == 1) {
|
||||||
char dump[64];
|
char dump[64];
|
||||||
app->build_header_dump(dump);
|
app->build_header_dump(dump);
|
||||||
Error("Recieved unhandled application packet from the client: %s.", dump);
|
LogError("Recieved unhandled application packet from the client: %s.", dump);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,12 +127,12 @@ bool Client::Process()
|
|||||||
void Client::Handle_SessionReady(const char *data, unsigned int size)
|
void Client::Handle_SessionReady(const char *data, unsigned int size)
|
||||||
{
|
{
|
||||||
if (status != cs_not_sent_session_ready) {
|
if (status != cs_not_sent_session_ready) {
|
||||||
Error("Session ready received again after already being received.");
|
LogError("Session ready received again after already being received.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size < sizeof(unsigned int)) {
|
if (size < sizeof(unsigned int)) {
|
||||||
Error("Session ready was too small.");
|
LogError("Session ready was too small.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,18 +180,18 @@ void Client::Handle_SessionReady(const char *data, unsigned int size)
|
|||||||
void Client::Handle_Login(const char *data, unsigned int size)
|
void Client::Handle_Login(const char *data, unsigned int size)
|
||||||
{
|
{
|
||||||
if (status != cs_waiting_for_login) {
|
if (status != cs_waiting_for_login) {
|
||||||
Error("Login received after already having logged in");
|
LogError("Login received after already having logged in");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((size - 12) % 8 != 0) {
|
if ((size - 12) % 8 != 0) {
|
||||||
Error("Login received packet of size: {0}, this would cause a block corruption, discarding", size);
|
LogError("Login received packet of size: {0}, this would cause a block corruption, discarding", size);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size < sizeof(LoginLoginRequest_Struct)) {
|
if (size < sizeof(LoginLoginRequest_Struct)) {
|
||||||
Error("Login received packet of size: {0}, this would cause a buffer overflow, discarding", size);
|
LogError("Login received packet of size: {0}, this would cause a buffer overflow, discarding", size);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -205,13 +205,13 @@ void Client::Handle_Login(const char *data, unsigned int size)
|
|||||||
std::string outbuffer;
|
std::string outbuffer;
|
||||||
outbuffer.resize(size - 12);
|
outbuffer.resize(size - 12);
|
||||||
if (outbuffer.length() == 0) {
|
if (outbuffer.length() == 0) {
|
||||||
Error("Corrupt buffer sent to server, no length.");
|
LogError("Corrupt buffer sent to server, no length.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto r = eqcrypt_block(data + 10, size - 12, &outbuffer[0], 0);
|
auto r = eqcrypt_block(data + 10, size - 12, &outbuffer[0], 0);
|
||||||
if (r == nullptr) {
|
if (r == nullptr) {
|
||||||
Error("Failed to decrypt eqcrypt block");
|
LogError("Failed to decrypt eqcrypt block");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ void Client::Handle_Login(const char *data, unsigned int size)
|
|||||||
|
|
||||||
std::string user(&outbuffer[0]);
|
std::string user(&outbuffer[0]);
|
||||||
if (user.length() >= outbuffer.length()) {
|
if (user.length() >= outbuffer.length()) {
|
||||||
Error("Corrupt buffer sent to server, preventing buffer overflow.");
|
LogError("Corrupt buffer sent to server, preventing buffer overflow.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ void Client::Handle_Login(const char *data, unsigned int size)
|
|||||||
user = components[1];
|
user = components[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
LogLoginserver(
|
LogInfo(
|
||||||
"Attempting password based login [{0}] login [{1}] user [{2}]",
|
"Attempting password based login [{0}] login [{1}] user [{2}]",
|
||||||
user,
|
user,
|
||||||
db_loginserver,
|
db_loginserver,
|
||||||
@ -259,7 +259,7 @@ void Client::Handle_Login(const char *data, unsigned int size)
|
|||||||
if (server.db->GetLoginDataFromAccountInfo(user, db_loginserver, db_account_password_hash, db_account_id)) {
|
if (server.db->GetLoginDataFromAccountInfo(user, db_loginserver, db_account_password_hash, db_account_id)) {
|
||||||
result = VerifyLoginHash(user, db_loginserver, cred, db_account_password_hash);
|
result = VerifyLoginHash(user, db_loginserver, cred, db_account_password_hash);
|
||||||
|
|
||||||
LogLoginserverDetail("[VerifyLoginHash] Success [{0}]", (result ? "true" : "false"));
|
LogDebug("[VerifyLoginHash] Success [{0}]", (result ? "true" : "false"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
status = cs_creating_account;
|
status = cs_creating_account;
|
||||||
@ -274,7 +274,7 @@ void Client::Handle_Login(const char *data, unsigned int size)
|
|||||||
* Login accepted
|
* Login accepted
|
||||||
*/
|
*/
|
||||||
if (result) {
|
if (result) {
|
||||||
LogLoginserverDetail(
|
LogDebug(
|
||||||
"login [{0}] user [{1}] Login succeeded",
|
"login [{0}] user [{1}] Login succeeded",
|
||||||
db_loginserver,
|
db_loginserver,
|
||||||
user
|
user
|
||||||
@ -283,7 +283,7 @@ void Client::Handle_Login(const char *data, unsigned int size)
|
|||||||
DoSuccessfulLogin(user, db_account_id, db_loginserver);
|
DoSuccessfulLogin(user, db_account_id, db_loginserver);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogLoginserverDetail(
|
LogDebug(
|
||||||
"login [{0}] user [{1}] Login failed",
|
"login [{0}] user [{1}] Login failed",
|
||||||
db_loginserver,
|
db_loginserver,
|
||||||
user
|
user
|
||||||
@ -301,7 +301,7 @@ void Client::Handle_Login(const char *data, unsigned int size)
|
|||||||
void Client::Handle_Play(const char *data)
|
void Client::Handle_Play(const char *data)
|
||||||
{
|
{
|
||||||
if (status != cs_logged_in) {
|
if (status != cs_logged_in) {
|
||||||
Error("Client sent a play request when they were not logged in, discarding.");
|
LogError("Client sent a play request when they were not logged in, discarding.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,7 +310,7 @@ void Client::Handle_Play(const char *data)
|
|||||||
auto sequence_in = (unsigned int) play->Sequence;
|
auto sequence_in = (unsigned int) play->Sequence;
|
||||||
|
|
||||||
if (server.options.IsTraceOn()) {
|
if (server.options.IsTraceOn()) {
|
||||||
LogLoginserver("Play received from client, server number {0} sequence {1}", server_id_in, sequence_in);
|
LogInfo("Play received from client, server number {0} sequence {1}", server_id_in, sequence_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->play_server_id = (unsigned int) play->ServerNumber;
|
this->play_server_id = (unsigned int) play->ServerNumber;
|
||||||
@ -375,10 +375,10 @@ void Client::AttemptLoginAccountCreation(
|
|||||||
{
|
{
|
||||||
if (loginserver == "eqemu") {
|
if (loginserver == "eqemu") {
|
||||||
|
|
||||||
LogLoginserver("Attempting login account creation via '{0}'", loginserver);
|
LogInfo("Attempting login account creation via '{0}'", loginserver);
|
||||||
|
|
||||||
if (!server.options.CanAutoLinkAccounts()) {
|
if (!server.options.CanAutoLinkAccounts()) {
|
||||||
LogLoginserver("CanAutoLinkAccounts disabled - sending failed login");
|
LogInfo("CanAutoLinkAccounts disabled - sending failed login");
|
||||||
DoFailedLogin();
|
DoFailedLogin();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -500,7 +500,7 @@ bool Client::VerifyLoginHash(
|
|||||||
if (hash.length() == 32) { //md5 is insecure
|
if (hash.length() == 32) { //md5 is insecure
|
||||||
for (int i = EncryptionModeMD5; i <= EncryptionModeMD5Triple; ++i) {
|
for (int i = EncryptionModeMD5; i <= EncryptionModeMD5Triple; ++i) {
|
||||||
if (i != mode && eqcrypt_verify_hash(user, cred, hash, i)) {
|
if (i != mode && eqcrypt_verify_hash(user, cred, hash, i)) {
|
||||||
LogLoginserverDetail(
|
LogDebug(
|
||||||
"user [{0}] loginserver [{1}] mode [{2}]",
|
"user [{0}] loginserver [{1}] mode [{2}]",
|
||||||
user,
|
user,
|
||||||
loginserver,
|
loginserver,
|
||||||
@ -514,7 +514,7 @@ bool Client::VerifyLoginHash(
|
|||||||
else if (hash.length() == 40) { //sha1 is insecure
|
else if (hash.length() == 40) { //sha1 is insecure
|
||||||
for (int i = EncryptionModeSHA; i <= EncryptionModeSHATriple; ++i) {
|
for (int i = EncryptionModeSHA; i <= EncryptionModeSHATriple; ++i) {
|
||||||
if (i != mode && eqcrypt_verify_hash(user, cred, hash, i)) {
|
if (i != mode && eqcrypt_verify_hash(user, cred, hash, i)) {
|
||||||
LogLoginserverDetail(
|
LogDebug(
|
||||||
"user [{0}] loginserver [{1}] mode [{2}]",
|
"user [{0}] loginserver [{1}] mode [{2}]",
|
||||||
user,
|
user,
|
||||||
loginserver,
|
loginserver,
|
||||||
@ -529,7 +529,7 @@ bool Client::VerifyLoginHash(
|
|||||||
else if (hash.length() == 128) { //sha2-512 is insecure
|
else if (hash.length() == 128) { //sha2-512 is insecure
|
||||||
for (int i = EncryptionModeSHA512; i <= EncryptionModeSHA512Triple; ++i) {
|
for (int i = EncryptionModeSHA512; i <= EncryptionModeSHA512Triple; ++i) {
|
||||||
if (i != mode && eqcrypt_verify_hash(user, cred, hash, i)) {
|
if (i != mode && eqcrypt_verify_hash(user, cred, hash, i)) {
|
||||||
LogLoginserverDetail(
|
LogDebug(
|
||||||
"user [{0}] loginserver [{1}] mode [{2}]",
|
"user [{0}] loginserver [{1}] mode [{2}]",
|
||||||
user,
|
user,
|
||||||
loginserver,
|
loginserver,
|
||||||
@ -605,7 +605,7 @@ void Client::DoSuccessfulLogin(const std::string &user, int db_account_id, const
|
|||||||
char encrypted_buffer[80] = {0};
|
char encrypted_buffer[80] = {0};
|
||||||
auto rc = eqcrypt_block((const char *) login_failed_attempts, 75, encrypted_buffer, 1);
|
auto rc = eqcrypt_block((const char *) login_failed_attempts, 75, encrypted_buffer, 1);
|
||||||
if (rc == nullptr) {
|
if (rc == nullptr) {
|
||||||
LogLoginserverDetail("Failed to encrypt eqcrypt block");
|
LogDebug("Failed to encrypt eqcrypt block");
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(login_accepted->encrypt, encrypted_buffer, 80);
|
memcpy(login_accepted->encrypt, encrypted_buffer, 80);
|
||||||
@ -682,12 +682,12 @@ void Client::LoginOnStatusChange(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (to == EQ::Net::StatusConnected) {
|
if (to == EQ::Net::StatusConnected) {
|
||||||
LogLoginserverDetail("EQ::Net::StatusConnected");
|
LogDebug("EQ::Net::StatusConnected");
|
||||||
LoginSendSessionReady();
|
LoginSendSessionReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to == EQ::Net::StatusDisconnecting || to == EQ::Net::StatusDisconnected) {
|
if (to == EQ::Net::StatusDisconnecting || to == EQ::Net::StatusDisconnected) {
|
||||||
LogLoginserverDetail("EQ::Net::StatusDisconnecting || EQ::Net::StatusDisconnected");
|
LogDebug("EQ::Net::StatusDisconnecting || EQ::Net::StatusDisconnected");
|
||||||
|
|
||||||
DoFailedLogin();
|
DoFailedLogin();
|
||||||
}
|
}
|
||||||
@ -785,12 +785,12 @@ void Client::LoginProcessLoginResponse(const EQ::Net::Packet &p)
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (response_error > 101) {
|
if (response_error > 101) {
|
||||||
LogLoginserverDetail("response [{0}] failed login", response_error);
|
LogDebug("response [{0}] failed login", response_error);
|
||||||
DoFailedLogin();
|
DoFailedLogin();
|
||||||
login_connection->Close();
|
login_connection->Close();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogLoginserverDetail(
|
LogDebug(
|
||||||
"response [{0}] login succeeded user [{1}]",
|
"response [{0}] login succeeded user [{1}]",
|
||||||
response_error,
|
response_error,
|
||||||
stored_user
|
stored_user
|
||||||
|
|||||||
@ -41,7 +41,7 @@ ClientManager::ClientManager()
|
|||||||
"login_opcodes.conf"
|
"login_opcodes.conf"
|
||||||
).c_str())) {
|
).c_str())) {
|
||||||
|
|
||||||
Error(
|
LogError(
|
||||||
"ClientManager fatal error: couldn't load opcodes for Titanium file [{0}]",
|
"ClientManager fatal error: couldn't load opcodes for Titanium file [{0}]",
|
||||||
server.config.GetVariableString("Titanium", "opcodes", "login_opcodes.conf")
|
server.config.GetVariableString("Titanium", "opcodes", "login_opcodes.conf")
|
||||||
);
|
);
|
||||||
@ -51,7 +51,7 @@ ClientManager::ClientManager()
|
|||||||
|
|
||||||
titanium_stream->OnNewConnection(
|
titanium_stream->OnNewConnection(
|
||||||
[this](std::shared_ptr<EQ::Net::EQStream> stream) {
|
[this](std::shared_ptr<EQ::Net::EQStream> stream) {
|
||||||
LogLoginserver(
|
LogInfo(
|
||||||
"New Titanium client connection from {0}:{1}",
|
"New Titanium client connection from {0}:{1}",
|
||||||
stream->GetRemoteIP(),
|
stream->GetRemoteIP(),
|
||||||
stream->GetRemotePort()
|
stream->GetRemotePort()
|
||||||
@ -69,7 +69,7 @@ ClientManager::ClientManager()
|
|||||||
sod_stream = new EQ::Net::EQStreamManager(sod_opts);
|
sod_stream = new EQ::Net::EQStreamManager(sod_opts);
|
||||||
sod_ops = new RegularOpcodeManager;
|
sod_ops = new RegularOpcodeManager;
|
||||||
if (!sod_ops->LoadOpcodes(server.config.GetVariableString("SoD", "opcodes", "login_opcodes.conf").c_str())) {
|
if (!sod_ops->LoadOpcodes(server.config.GetVariableString("SoD", "opcodes", "login_opcodes.conf").c_str())) {
|
||||||
Error(
|
LogError(
|
||||||
"ClientManager fatal error: couldn't load opcodes for SoD file {0}",
|
"ClientManager fatal error: couldn't load opcodes for SoD file {0}",
|
||||||
server.config.GetVariableString("SoD", "opcodes", "login_opcodes.conf").c_str()
|
server.config.GetVariableString("SoD", "opcodes", "login_opcodes.conf").c_str()
|
||||||
);
|
);
|
||||||
@ -79,7 +79,7 @@ ClientManager::ClientManager()
|
|||||||
|
|
||||||
sod_stream->OnNewConnection(
|
sod_stream->OnNewConnection(
|
||||||
[this](std::shared_ptr<EQ::Net::EQStream> stream) {
|
[this](std::shared_ptr<EQ::Net::EQStream> stream) {
|
||||||
LogLoginserver(
|
LogInfo(
|
||||||
"New SoD client connection from {0}:{1}",
|
"New SoD client connection from {0}:{1}",
|
||||||
stream->GetRemoteIP(),
|
stream->GetRemoteIP(),
|
||||||
stream->GetRemotePort()
|
stream->GetRemotePort()
|
||||||
@ -134,7 +134,7 @@ void ClientManager::ProcessDisconnect()
|
|||||||
while (iter != clients.end()) {
|
while (iter != clients.end()) {
|
||||||
std::shared_ptr<EQStreamInterface> c = (*iter)->GetConnection();
|
std::shared_ptr<EQStreamInterface> c = (*iter)->GetConnection();
|
||||||
if (c->CheckState(CLOSED)) {
|
if (c->CheckState(CLOSED)) {
|
||||||
LogLoginserver("Client disconnected from the server, removing client.");
|
LogInfo("Client disconnected from the server, removing client.");
|
||||||
delete (*iter);
|
delete (*iter);
|
||||||
iter = clients.erase(iter);
|
iter = clients.erase(iter);
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ void ClientManager::RemoveExistingClient(unsigned int account_id, const std::str
|
|||||||
auto iter = clients.begin();
|
auto iter = clients.begin();
|
||||||
while (iter != clients.end()) {
|
while (iter != clients.end()) {
|
||||||
if ((*iter)->GetAccountID() == account_id && (*iter)->GetLoginServerName().compare(loginserver) == 0) {
|
if ((*iter)->GetAccountID() == account_id && (*iter)->GetLoginServerName().compare(loginserver) == 0) {
|
||||||
LogLoginserver("Client attempting to log in existing client already logged in, removing existing client");
|
LogInfo("Client attempting to log in existing client already logged in, removing existing client");
|
||||||
delete (*iter);
|
delete (*iter);
|
||||||
iter = clients.erase(iter);
|
iter = clients.erase(iter);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,7 +52,7 @@ std::string Config::GetVariable(std::string title, std::string parameter)
|
|||||||
void Config::Parse(const char *file_name)
|
void Config::Parse(const char *file_name)
|
||||||
{
|
{
|
||||||
if (file_name == nullptr) {
|
if (file_name == nullptr) {
|
||||||
Error("Config::Parse(), file_name passed was null");
|
LogError("Config::Parse(), file_name passed was null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ void Config::Parse(const char *file_name)
|
|||||||
bool first = true;
|
bool first = true;
|
||||||
++iter;
|
++iter;
|
||||||
if (iter == tokens.end()) {
|
if (iter == tokens.end()) {
|
||||||
Error("Config::Parse(), EOF before title done parsing");
|
LogError("Config::Parse(), EOF before title done parsing");
|
||||||
fclose(input);
|
fclose(input);
|
||||||
vars.clear();
|
vars.clear();
|
||||||
return;
|
return;
|
||||||
@ -99,7 +99,7 @@ void Config::Parse(const char *file_name)
|
|||||||
else if (mode == 1) {
|
else if (mode == 1) {
|
||||||
mode++;
|
mode++;
|
||||||
if ((*iter).compare("=") != 0) {
|
if ((*iter).compare("=") != 0) {
|
||||||
Error("Config::Parse(), invalid parse token where = should be");
|
LogError("Config::Parse(), invalid parse token where = should be");
|
||||||
fclose(input);
|
fclose(input);
|
||||||
vars.clear();
|
vars.clear();
|
||||||
return;
|
return;
|
||||||
@ -124,7 +124,7 @@ void Config::Parse(const char *file_name)
|
|||||||
fclose(input);
|
fclose(input);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Error("Config::Parse(), file was unable to be opened for parsing");
|
LogError("Config::Parse(), file was unable to be opened for parsing");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -103,7 +103,7 @@ bool Database::GetLoginDataFromAccountInfo(
|
|||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
if (results.RowCount() != 1) {
|
if (results.RowCount() != 1) {
|
||||||
LogLoginserverDetail(
|
LogDebug(
|
||||||
"Could not find account for name [{0}] login [{1}]",
|
"Could not find account for name [{0}] login [{1}]",
|
||||||
name,
|
name,
|
||||||
loginserver
|
loginserver
|
||||||
@ -121,7 +121,7 @@ bool Database::GetLoginDataFromAccountInfo(
|
|||||||
id = atoi(row[0]);
|
id = atoi(row[0]);
|
||||||
password = row[1];
|
password = row[1];
|
||||||
|
|
||||||
LogLoginserverDetail(
|
LogDebug(
|
||||||
"Found account for name [{0}] login [{1}]",
|
"Found account for name [{0}] login [{1}]",
|
||||||
name,
|
name,
|
||||||
loginserver
|
loginserver
|
||||||
@ -301,7 +301,7 @@ void Database::UpdateLoginHash(
|
|||||||
const std::string &hash
|
const std::string &hash
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
LogLoginserverDetail(
|
LogDebug(
|
||||||
"name [{0}] loginserver [{1}] hash [{2}]",
|
"name [{0}] loginserver [{1}] hash [{2}]",
|
||||||
name,
|
name,
|
||||||
loginserver,
|
loginserver,
|
||||||
|
|||||||
@ -47,10 +47,10 @@ int main()
|
|||||||
|
|
||||||
LogSys.LoadLogSettingsDefaults();
|
LogSys.LoadLogSettingsDefaults();
|
||||||
|
|
||||||
LogLoginserver("Logging System Init");
|
LogInfo("Logging System Init");
|
||||||
|
|
||||||
server.config = EQ::JsonConfigFile::Load("login.json");
|
server.config = EQ::JsonConfigFile::Load("login.json");
|
||||||
LogLoginserver("Config System Init");
|
LogInfo("Config System Init");
|
||||||
|
|
||||||
server.options.Trace(server.config.GetVariableBool("general", "trace", false));
|
server.options.Trace(server.config.GetVariableBool("general", "trace", false));
|
||||||
server.options.WorldTrace(server.config.GetVariableBool("general", "world_trace", false));
|
server.options.WorldTrace(server.config.GetVariableBool("general", "world_trace", false));
|
||||||
@ -119,7 +119,7 @@ int main()
|
|||||||
/**
|
/**
|
||||||
* mysql connect
|
* mysql connect
|
||||||
*/
|
*/
|
||||||
LogLoginserver("MySQL Database Init");
|
LogInfo("MySQL Database Init");
|
||||||
|
|
||||||
server.db = new Database(
|
server.db = new Database(
|
||||||
server.config.GetVariableString("database", "user", "root"),
|
server.config.GetVariableString("database", "user", "root"),
|
||||||
@ -135,19 +135,19 @@ int main()
|
|||||||
* make sure our database got created okay, otherwise cleanup and exit
|
* make sure our database got created okay, otherwise cleanup and exit
|
||||||
*/
|
*/
|
||||||
if (!server.db) {
|
if (!server.db) {
|
||||||
Error("Database Initialization Failure");
|
LogError("Database Initialization Failure");
|
||||||
LogLoginserver("Log System Shutdown");
|
LogInfo("Log System Shutdown");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create server manager
|
* create server manager
|
||||||
*/
|
*/
|
||||||
LogLoginserver("Server Manager Init");
|
LogInfo("Server Manager Init");
|
||||||
server.server_manager = new ServerManager();
|
server.server_manager = new ServerManager();
|
||||||
if (!server.server_manager) {
|
if (!server.server_manager) {
|
||||||
Error("Server Manager Failed to Start");
|
LogError("Server Manager Failed to Start");
|
||||||
LogLoginserver("Database System Shutdown");
|
LogInfo("Database System Shutdown");
|
||||||
delete server.db;
|
delete server.db;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -155,14 +155,14 @@ int main()
|
|||||||
/**
|
/**
|
||||||
* create client manager
|
* create client manager
|
||||||
*/
|
*/
|
||||||
LogLoginserver("Client Manager Init");
|
LogInfo("Client Manager Init");
|
||||||
server.client_manager = new ClientManager();
|
server.client_manager = new ClientManager();
|
||||||
if (!server.client_manager) {
|
if (!server.client_manager) {
|
||||||
Error("Client Manager Failed to Start");
|
LogError("Client Manager Failed to Start");
|
||||||
LogLoginserver("Server Manager Shutdown");
|
LogInfo("Server Manager Shutdown");
|
||||||
delete server.server_manager;
|
delete server.server_manager;
|
||||||
|
|
||||||
LogLoginserver("Database System Shutdown");
|
LogInfo("Database System Shutdown");
|
||||||
delete server.db;
|
delete server.db;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -175,10 +175,10 @@ int main()
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LogLoginserver("Server Started");
|
LogInfo("Server Started");
|
||||||
|
|
||||||
if (LogSys.log_settings[Logs::Login_Server].log_to_console == 1) {
|
if (LogSys.log_settings[Logs::Login_Server].log_to_console == 1) {
|
||||||
LogLoginserver("Loginserver logging set to level [1] for more debugging, enable detail [3]");
|
LogInfo("Loginserver logging set to level [1] for more debugging, enable detail [3]");
|
||||||
}
|
}
|
||||||
|
|
||||||
while (run_server) {
|
while (run_server) {
|
||||||
@ -188,13 +188,13 @@ int main()
|
|||||||
Sleep(50);
|
Sleep(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogLoginserver("Server Shutdown");
|
LogInfo("Server Shutdown");
|
||||||
LogLoginserver("Client Manager Shutdown");
|
LogInfo("Client Manager Shutdown");
|
||||||
delete server.client_manager;
|
delete server.client_manager;
|
||||||
LogLoginserver("Server Manager Shutdown");
|
LogInfo("Server Manager Shutdown");
|
||||||
delete server.server_manager;
|
delete server.server_manager;
|
||||||
|
|
||||||
LogLoginserver("Database System Shutdown");
|
LogInfo("Database System Shutdown");
|
||||||
delete server.db;
|
delete server.db;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,11 +39,11 @@ ServerManager::ServerManager()
|
|||||||
opts.ipv6 = false;
|
opts.ipv6 = false;
|
||||||
server_connection->Listen(opts);
|
server_connection->Listen(opts);
|
||||||
|
|
||||||
LogLoginserver("Loginserver now listening on port [{0}]", listen_port);
|
LogInfo("Loginserver now listening on port [{0}]", listen_port);
|
||||||
|
|
||||||
server_connection->OnConnectionIdentified(
|
server_connection->OnConnectionIdentified(
|
||||||
"World", [this](std::shared_ptr<EQ::Net::ServertalkServerConnection> world_connection) {
|
"World", [this](std::shared_ptr<EQ::Net::ServertalkServerConnection> world_connection) {
|
||||||
LogLoginserver(
|
LogInfo(
|
||||||
"New world server connection from {0}:{1}",
|
"New world server connection from {0}:{1}",
|
||||||
world_connection->Handle()->RemoteIP(),
|
world_connection->Handle()->RemoteIP(),
|
||||||
world_connection->Handle()->RemotePort()
|
world_connection->Handle()->RemotePort()
|
||||||
@ -55,7 +55,7 @@ ServerManager::ServerManager()
|
|||||||
0 &&
|
0 &&
|
||||||
(*iter)->GetConnection()->Handle()->RemotePort() == world_connection->Handle()->RemotePort()) {
|
(*iter)->GetConnection()->Handle()->RemotePort() == world_connection->Handle()->RemotePort()) {
|
||||||
|
|
||||||
LogLoginserver(
|
LogInfo(
|
||||||
"World server already existed for {0}:{1}, removing existing connection.",
|
"World server already existed for {0}:{1}, removing existing connection.",
|
||||||
world_connection->Handle()->RemoteIP(),
|
world_connection->Handle()->RemoteIP(),
|
||||||
world_connection->Handle()->RemotePort()
|
world_connection->Handle()->RemotePort()
|
||||||
@ -138,7 +138,7 @@ EQApplicationPacket *ServerManager::CreateServerListPacket(Client *client, uint3
|
|||||||
packet_size += (*iter)->GetLongName().size() + (*iter)->GetLocalIP().size() + 24;
|
packet_size += (*iter)->GetLongName().size() + (*iter)->GetLocalIP().size() + 24;
|
||||||
}
|
}
|
||||||
else if (IpUtil::IsIpInPrivateRfc1918(client_ip)) {
|
else if (IpUtil::IsIpInPrivateRfc1918(client_ip)) {
|
||||||
LogLoginserver("Client is requesting server list from a local address [{0}]", client_ip);
|
LogInfo("Client is requesting server list from a local address [{0}]", client_ip);
|
||||||
packet_size += (*iter)->GetLongName().size() + (*iter)->GetLocalIP().size() + 24;
|
packet_size += (*iter)->GetLongName().size() + (*iter)->GetLocalIP().size() + 24;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -264,14 +264,14 @@ void ServerManager::SendUserToWorldRequest(
|
|||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
if (server.options.IsDumpInPacketsOn()) {
|
if (server.options.IsDumpInPacketsOn()) {
|
||||||
LogLoginserver("{0}", outapp.ToString());
|
LogInfo("{0}", outapp.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found && server.options.IsTraceOn()) {
|
if (!found && server.options.IsTraceOn()) {
|
||||||
Error("Client requested a user to world but supplied an invalid id of {0}", server_id);
|
LogError("Client requested a user to world but supplied an invalid id of {0}", server_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -107,7 +107,7 @@ void WorldServer::ProcessNewLSInfo(uint16_t opcode, const EQ::Net::Packet &packe
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (packet.Length() < sizeof(ServerNewLSInfo_Struct)) {
|
if (packet.Length() < sizeof(ServerNewLSInfo_Struct)) {
|
||||||
Error(
|
LogError(
|
||||||
"Received application packet from server that had opcode ServerOP_NewLSInfo, "
|
"Received application packet from server that had opcode ServerOP_NewLSInfo, "
|
||||||
"but was too small. Discarded to avoid buffer overrun"
|
"but was too small. Discarded to avoid buffer overrun"
|
||||||
);
|
);
|
||||||
@ -118,7 +118,7 @@ void WorldServer::ProcessNewLSInfo(uint16_t opcode, const EQ::Net::Packet &packe
|
|||||||
|
|
||||||
auto *info = (ServerNewLSInfo_Struct *) packet.Data();
|
auto *info = (ServerNewLSInfo_Struct *) packet.Data();
|
||||||
|
|
||||||
LogLoginserver(
|
LogInfo(
|
||||||
"Received New Login Server Info \n"
|
"Received New Login Server Info \n"
|
||||||
" - name [{0}]\n"
|
" - name [{0}]\n"
|
||||||
" - shortname [{1}]\n"
|
" - shortname [{1}]\n"
|
||||||
@ -162,7 +162,7 @@ void WorldServer::ProcessLSStatus(uint16_t opcode, const EQ::Net::Packet &packet
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (packet.Length() < sizeof(ServerLSStatus_Struct)) {
|
if (packet.Length() < sizeof(ServerLSStatus_Struct)) {
|
||||||
Error(
|
LogError(
|
||||||
"Received application packet from server that had opcode ServerOP_LSStatus, but was too small. Discarded to avoid buffer overrun"
|
"Received application packet from server that had opcode ServerOP_LSStatus, but was too small. Discarded to avoid buffer overrun"
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ void WorldServer::ProcessLSStatus(uint16_t opcode, const EQ::Net::Packet &packet
|
|||||||
|
|
||||||
auto *ls_status = (ServerLSStatus_Struct *) packet.Data();
|
auto *ls_status = (ServerLSStatus_Struct *) packet.Data();
|
||||||
|
|
||||||
LogLoginserverDetail(
|
LogDebug(
|
||||||
"World Server Status Update Received | Server [{0}] Status [{1}] Players [{2}] Zones [{3}]",
|
"World Server Status Update Received | Server [{0}] Status [{1}] Players [{2}] Zones [{3}]",
|
||||||
this->GetLongName(),
|
this->GetLongName(),
|
||||||
ls_status->status,
|
ls_status->status,
|
||||||
@ -201,7 +201,7 @@ void WorldServer::ProcessUsertoWorldRespLeg(uint16_t opcode, const EQ::Net::Pack
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (packet.Length() < sizeof(UsertoWorldResponseLegacy_Struct)) {
|
if (packet.Length() < sizeof(UsertoWorldResponseLegacy_Struct)) {
|
||||||
Error(
|
LogError(
|
||||||
"Received application packet from server that had opcode ServerOP_UsertoWorldResp, "
|
"Received application packet from server that had opcode ServerOP_UsertoWorldResp, "
|
||||||
"but was too small. Discarded to avoid buffer overrun"
|
"but was too small. Discarded to avoid buffer overrun"
|
||||||
);
|
);
|
||||||
@ -284,7 +284,7 @@ void WorldServer::ProcessUsertoWorldRespLeg(uint16_t opcode, const EQ::Net::Pack
|
|||||||
delete outapp;
|
delete outapp;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Error(
|
LogError(
|
||||||
"Received User-To-World Response for {0} but could not find the client referenced!",
|
"Received User-To-World Response for {0} but could not find the client referenced!",
|
||||||
user_to_world_response->lsaccountid
|
user_to_world_response->lsaccountid
|
||||||
);
|
);
|
||||||
@ -403,7 +403,7 @@ void WorldServer::ProcessUserToWorldResponse(uint16_t opcode, const EQ::Net::Pac
|
|||||||
delete outapp;
|
delete outapp;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Error("Received User-To-World Response for {0} but could not find the client referenced!.",
|
LogError("Received User-To-World Response for {0} but could not find the client referenced!.",
|
||||||
user_to_world_response->lsaccountid);
|
user_to_world_response->lsaccountid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -427,7 +427,7 @@ void WorldServer::ProcessLSAccountUpdate(uint16_t opcode, const EQ::Net::Packet
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (packet.Length() < sizeof(ServerLSAccountUpdate_Struct)) {
|
if (packet.Length() < sizeof(ServerLSAccountUpdate_Struct)) {
|
||||||
Error(
|
LogError(
|
||||||
"Received application packet from server that had opcode ServerLSAccountUpdate_Struct, "
|
"Received application packet from server that had opcode ServerLSAccountUpdate_Struct, "
|
||||||
"but was too small. Discarded to avoid buffer overrun"
|
"but was too small. Discarded to avoid buffer overrun"
|
||||||
);
|
);
|
||||||
@ -464,7 +464,7 @@ void WorldServer::ProcessLSAccountUpdate(uint16_t opcode, const EQ::Net::Packet
|
|||||||
void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info_packet)
|
void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info_packet)
|
||||||
{
|
{
|
||||||
if (is_server_logged_in) {
|
if (is_server_logged_in) {
|
||||||
Error("WorldServer::Handle_NewLSInfo called but the login server was already marked as logged in, aborting.");
|
LogError("WorldServer::Handle_NewLSInfo called but the login server was already marked as logged in, aborting.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,7 +472,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info
|
|||||||
account_name = new_world_server_info_packet->account;
|
account_name = new_world_server_info_packet->account;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Error("Handle_NewLSInfo error, account name was too long.");
|
LogError("Handle_NewLSInfo error, account name was too long.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,7 +480,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info
|
|||||||
account_password = new_world_server_info_packet->password;
|
account_password = new_world_server_info_packet->password;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Error("Handle_NewLSInfo error, account password was too long.");
|
LogError("Handle_NewLSInfo error, account password was too long.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,7 +488,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info
|
|||||||
long_name = new_world_server_info_packet->name;
|
long_name = new_world_server_info_packet->name;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Error("Handle_NewLSInfo error, long name was too long.");
|
LogError("Handle_NewLSInfo error, long name was too long.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,13 +496,13 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info
|
|||||||
short_name = new_world_server_info_packet->shortname;
|
short_name = new_world_server_info_packet->shortname;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Error("Handle_NewLSInfo error, short name was too long.");
|
LogError("Handle_NewLSInfo error, short name was too long.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(new_world_server_info_packet->local_address) <= 125) {
|
if (strlen(new_world_server_info_packet->local_address) <= 125) {
|
||||||
if (strlen(new_world_server_info_packet->local_address) == 0) {
|
if (strlen(new_world_server_info_packet->local_address) == 0) {
|
||||||
Error("Handle_NewLSInfo error, local address was null, defaulting to localhost");
|
LogError("Handle_NewLSInfo error, local address was null, defaulting to localhost");
|
||||||
local_ip = "127.0.0.1";
|
local_ip = "127.0.0.1";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -510,7 +510,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Error("Handle_NewLSInfo error, local address was too long.");
|
LogError("Handle_NewLSInfo error, local address was too long.");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -518,7 +518,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info
|
|||||||
if (strlen(new_world_server_info_packet->remote_address) <= 125) {
|
if (strlen(new_world_server_info_packet->remote_address) <= 125) {
|
||||||
if (strlen(new_world_server_info_packet->remote_address) == 0) {
|
if (strlen(new_world_server_info_packet->remote_address) == 0) {
|
||||||
remote_ip = GetConnection()->Handle()->RemoteIP();
|
remote_ip = GetConnection()->Handle()->RemoteIP();
|
||||||
Error(
|
LogError(
|
||||||
"Remote address was null, defaulting to stream address %s.",
|
"Remote address was null, defaulting to stream address %s.",
|
||||||
remote_ip.c_str()
|
remote_ip.c_str()
|
||||||
);
|
);
|
||||||
@ -542,7 +542,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info
|
|||||||
version = new_world_server_info_packet->serverversion;
|
version = new_world_server_info_packet->serverversion;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Error("Handle_NewLSInfo error, server version was too long.");
|
LogError("Handle_NewLSInfo error, server version was too long.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,7 +550,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info
|
|||||||
protocol = new_world_server_info_packet->protocolversion;
|
protocol = new_world_server_info_packet->protocolversion;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Error("Handle_NewLSInfo error, protocol version was too long.");
|
LogError("Handle_NewLSInfo error, protocol version was too long.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -559,13 +559,13 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info
|
|||||||
|
|
||||||
if (server.options.IsRejectingDuplicateServers()) {
|
if (server.options.IsRejectingDuplicateServers()) {
|
||||||
if (server.server_manager->ServerExists(long_name, short_name, this)) {
|
if (server.server_manager->ServerExists(long_name, short_name, this)) {
|
||||||
Error("World tried to login but there already exists a server that has that name");
|
LogError("World tried to login but there already exists a server that has that name");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (server.server_manager->ServerExists(long_name, short_name, this)) {
|
if (server.server_manager->ServerExists(long_name, short_name, this)) {
|
||||||
Error("World tried to login but there already exists a server that has that name");
|
LogError("World tried to login but there already exists a server that has that name");
|
||||||
server.server_manager->DestroyServerByName(long_name, short_name, this);
|
server.server_manager->DestroyServerByName(long_name, short_name, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -700,14 +700,14 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info
|
|||||||
* this is the second of two cases where we should deny access even if unregistered is allowed
|
* this is the second of two cases where we should deny access even if unregistered is allowed
|
||||||
*/
|
*/
|
||||||
if (server_account_name.size() > 0 || server_account_password.size() > 0) {
|
if (server_account_name.size() > 0 || server_account_password.size() > 0) {
|
||||||
LogLoginserver(
|
LogInfo(
|
||||||
"Server [{0}] [{1}] did not login but this server required a password to login",
|
"Server [{0}] [{1}] did not login but this server required a password to login",
|
||||||
long_name,
|
long_name,
|
||||||
short_name
|
short_name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogLoginserver(
|
LogInfo(
|
||||||
"Server [{0}] [{1}] did not login but unregistered servers are allowed",
|
"Server [{0}] [{1}] did not login but unregistered servers are allowed",
|
||||||
long_name,
|
long_name,
|
||||||
short_name
|
short_name
|
||||||
@ -720,7 +720,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogLoginserver(
|
LogInfo(
|
||||||
"Server [{0}] ({1}) is not registered but unregistered servers are allowed",
|
"Server [{0}] ({1}) is not registered but unregistered servers are allowed",
|
||||||
long_name,
|
long_name,
|
||||||
short_name
|
short_name
|
||||||
@ -782,7 +782,7 @@ void WorldServer::SendClientAuth(
|
|||||||
client_auth.local = 1;
|
client_auth.local = 1;
|
||||||
}
|
}
|
||||||
else if (IpUtil::IsIpInPrivateRfc1918(client_address)) {
|
else if (IpUtil::IsIpInPrivateRfc1918(client_address)) {
|
||||||
LogLoginserver("Client is authenticating from a local address [{0}]", client_address);
|
LogInfo("Client is authenticating from a local address [{0}]", client_address);
|
||||||
client_auth.local = 1;
|
client_auth.local = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -792,13 +792,13 @@ void WorldServer::SendClientAuth(
|
|||||||
struct in_addr ip_addr{};
|
struct in_addr ip_addr{};
|
||||||
ip_addr.s_addr = client_auth.ip;
|
ip_addr.s_addr = client_auth.ip;
|
||||||
|
|
||||||
LogLoginserver(
|
LogInfo(
|
||||||
"Client authentication response: world_address [{0}] client_address [{1}]",
|
"Client authentication response: world_address [{0}] client_address [{1}]",
|
||||||
world_address,
|
world_address,
|
||||||
client_address
|
client_address
|
||||||
);
|
);
|
||||||
|
|
||||||
LogLoginserver(
|
LogInfo(
|
||||||
"Sending Client Authentication Response ls_account_id [{0}] ls_name [{1}] name [{2}] key [{3}] ls_admin [{4}] "
|
"Sending Client Authentication Response ls_account_id [{0}] ls_name [{1}] name [{2}] key [{3}] ls_admin [{4}] "
|
||||||
" world_admin [{5}] ip [{6}] local [{7}]",
|
" world_admin [{5}] ip [{6}] local [{7}]",
|
||||||
client_auth.lsaccount_id,
|
client_auth.lsaccount_id,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user