Cleanup logging behavior
Fix #8 - the multiple 'version' handling in LS is removed, now just GetVersion() as before. - Console commands '1' and '2' removed (would change world status to all clients). Version command added (was missing). - Window Title updated to note version - Some loose log messages (printfs) were made into proper "LOGIN" messages via log_config.xml - Previously marked "World" messages that are also used as "Login" now properly categorized as such - Removed DumpPacket on unknown opcodes (stop unnecessary data to console) - Welcome banners on world/login updated
This commit is contained in:
parent
a5131f3e31
commit
a9f087b40c
9 changed files with 129 additions and 69 deletions
3
DB/updates/login_updates.sql
Normal file
3
DB/updates/login_updates.sql
Normal file
|
@ -0,0 +1,3 @@
|
|||
alter table log_messages add column name text default null;
|
||||
alter table log_messages add column version text default null;
|
||||
alter table log_messages modify column log_type text not null default '';
|
|
@ -48,7 +48,7 @@ Client::Client(EQStream* ieqnc) {
|
|||
lsadmin = 0;
|
||||
worldadmin = 0;
|
||||
lsstatus = 0;
|
||||
origversion = version = 0;
|
||||
version = 0;
|
||||
kicked = false;
|
||||
verified = false;
|
||||
memset(bannedreason, 0, sizeof(bannedreason));
|
||||
|
@ -168,12 +168,6 @@ bool Client::Process() {
|
|||
|
||||
LogWrite(LOGIN__DEBUG, 0, "Login", "Client Version Provided: %i", version);
|
||||
|
||||
// Image 2020 Notes
|
||||
// we keep the original version for special packets like char creation to pass to world server
|
||||
origversion = version;
|
||||
// forced version to 60085 for now since those structures seem to work best for steam AoM 12133L Aug 17 2015 11:19:13 build
|
||||
version = 60085;
|
||||
|
||||
if (EQOpcodeManager.count(GetOpcodeVersion(version)) == 0) {
|
||||
LogWrite(LOGIN__ERROR, 0, "Login", "Incompatible client version provided: %i", version);
|
||||
SendLoginDenied();
|
||||
|
@ -181,7 +175,7 @@ bool Client::Process() {
|
|||
}
|
||||
|
||||
if(EQOpcodeManager.count(GetOpcodeVersion(version)) > 0 && getConnection()){
|
||||
getConnection()->SetClientVersion(GetOrigVersion());
|
||||
getConnection()->SetClientVersion(GetVersion());
|
||||
EQ2_16BitString username = packet->getType_EQ2_16BitString_ByName("username");
|
||||
EQ2_16BitString password = packet->getType_EQ2_16BitString_ByName("password");
|
||||
LoginAccount* acct = database.LoadAccount(username.data.c_str(),password.data.c_str(), net.IsAllowingAccountCreation());
|
||||
|
@ -231,7 +225,7 @@ bool Client::Process() {
|
|||
case OP_AllWSDescRequestMsg:{
|
||||
SendWorldList();
|
||||
needs_world_list = false;
|
||||
database.LoadCharacters(GetLoginAccount(), GetOrigVersion());
|
||||
database.LoadCharacters(GetLoginAccount(), GetVersion());
|
||||
SendCharList();
|
||||
break;
|
||||
}
|
||||
|
@ -259,7 +253,7 @@ bool Client::Process() {
|
|||
break;
|
||||
}
|
||||
case OP_CreateCharacterRequestMsg:{
|
||||
PacketStruct* packet = configReader.getStruct("CreateCharacter", GetOrigVersion());
|
||||
PacketStruct* packet = configReader.getStruct("CreateCharacter", GetVersion());
|
||||
|
||||
playWaitTimer = new Timer ( 15000 );
|
||||
playWaitTimer->Start ( );
|
||||
|
@ -276,7 +270,7 @@ bool Client::Process() {
|
|||
else
|
||||
{
|
||||
ServerPacket* outpack = new ServerPacket(ServerOP_CharacterCreate, app->size+sizeof(int16));
|
||||
int16 out_version = GetOrigVersion();
|
||||
int16 out_version = GetVersion();
|
||||
memcpy(outpack->pBuffer, &out_version, sizeof(int16));
|
||||
memcpy(outpack->pBuffer + sizeof(int16), app->pBuffer, app->size);
|
||||
uchar* tmp = outpack->pBuffer;
|
||||
|
@ -366,14 +360,11 @@ bool Client::Process() {
|
|||
break;
|
||||
}
|
||||
default: {
|
||||
char* name = (char*)app->GetOpcodeName();
|
||||
if(name)
|
||||
cout << name;
|
||||
const char* name = app->GetOpcodeName();
|
||||
if (name)
|
||||
LogWrite(OPCODE__DEBUG, 1, "Opcode", "%s Received %04X (%i)", name, app->GetRawOpcode(), app->GetRawOpcode());
|
||||
else
|
||||
cout << "Unknown";
|
||||
cout << " Packet: OPCode: 0x" << hex << setw(2) << setfill('0') << app->GetOpcode() << dec << ", size: " << setw(5) << setfill(' ') << app->Size() << " from " << GetAccountName() << endl;
|
||||
if (app->Size() < 128)
|
||||
DumpPacket(app);
|
||||
LogWrite(OPCODE__DEBUG, 1, "Opcode", "Received %04X (%i)", app->GetRawOpcode(), app->GetRawOpcode());
|
||||
}
|
||||
}
|
||||
delete app;
|
||||
|
@ -421,7 +412,7 @@ void Client::CharacterApproved(int32 server_id,int32 char_id)
|
|||
if(!world_server)
|
||||
return;
|
||||
|
||||
PacketStruct* packet = configReader.getStruct("LS_CreateCharacterReply", GetOrigVersion());
|
||||
PacketStruct* packet = configReader.getStruct("LS_CreateCharacterReply", GetVersion());
|
||||
if(packet){
|
||||
packet->setDataByName("account_id", GetAccountID());
|
||||
packet->setDataByName("unknown", 0xFFFFFFFF);
|
||||
|
@ -433,7 +424,7 @@ void Client::CharacterApproved(int32 server_id,int32 char_id)
|
|||
database.SaveCharacter(createRequest, GetLoginAccount(),char_id);
|
||||
|
||||
// refresh characters for this account
|
||||
database.LoadCharacters(GetLoginAccount(), GetOrigVersion());
|
||||
database.LoadCharacters(GetLoginAccount(), GetVersion());
|
||||
|
||||
SendCharList();
|
||||
}
|
||||
|
@ -500,8 +491,8 @@ void Client::SendCharList(){
|
|||
safe_delete(packet);*/
|
||||
LogWrite(LOGIN__INFO, 0, "Login", "[%s] sending character list.", GetAccountName());
|
||||
LS_CharSelectList list;
|
||||
list.loadData(GetAccountID(), GetLoginAccount()->charlist, GetOrigVersion());
|
||||
EQ2Packet* outapp = list.serialize(GetOrigVersion());
|
||||
list.loadData(GetAccountID(), GetLoginAccount()->charlist, GetVersion());
|
||||
EQ2Packet* outapp = list.serialize(GetVersion());
|
||||
// DumpPacket(outapp);
|
||||
QueuePacket(outapp);
|
||||
|
||||
|
@ -524,7 +515,7 @@ void Client::SendLoginDenied(){
|
|||
}
|
||||
|
||||
void Client::SendLoginAccepted() {
|
||||
PacketStruct* packet = configReader.getStruct("LS_LoginReplyMsg", GetOrigVersion());
|
||||
PacketStruct* packet = configReader.getStruct("LS_LoginReplyMsg", GetVersion());
|
||||
int i = 0;
|
||||
if (packet)
|
||||
{
|
||||
|
@ -559,7 +550,7 @@ void Client::SendLoginAccepted() {
|
|||
void Client::SendWorldList(){
|
||||
EQ2Packet* pack = world_list.MakeServerListPacket(lsadmin, version);
|
||||
EQ2Packet* dupe = pack->Copy();
|
||||
DumpPacket(dupe->pBuffer,dupe->size);
|
||||
//DumpPacket(dupe->pBuffer,dupe->size);
|
||||
QueuePacket(dupe);
|
||||
return;
|
||||
}
|
||||
|
@ -704,7 +695,7 @@ void ClientList::Process() {
|
|||
struct in_addr in;
|
||||
in.s_addr = client->getConnection()->GetRemoteIP();
|
||||
net.numclients--;
|
||||
cout << Timer::GetCurrentTime2() << " Removing client from ip: " << inet_ntoa(in) << " port: " << ntohs(client->getConnection()->GetRemotePort()) << " Name: " << client->GetAccountName() << endl;
|
||||
LogWrite(LOGIN__INFO, 0, "Login", "Removing client from ip: %s on port %i, Account Name: %s", inet_ntoa(in), ntohs(client->getConnection()->GetRemotePort()), client->GetAccountName());
|
||||
client->getConnection()->SetState(CLOSED);
|
||||
net.UpdateWindowTitle();
|
||||
client_list.erase(client);
|
||||
|
|
|
@ -44,7 +44,6 @@ public:
|
|||
account_id = in_account->getLoginAccountID();
|
||||
}
|
||||
int16 GetVersion(){ return version; }
|
||||
int16 GetOrigVersion(){ return origversion; }
|
||||
char* GetKey() { return key; }
|
||||
void SetKey(char* in_key) { strcpy(key,in_key); }
|
||||
int32 GetIP() { return ip; }
|
||||
|
@ -95,7 +94,6 @@ private:
|
|||
bool start;
|
||||
bool needs_world_list;
|
||||
int16 version;
|
||||
int16 origversion;
|
||||
char bannedreason[30];
|
||||
eLoginMode LoginMode;
|
||||
PacketStruct* createRequest;
|
||||
|
|
|
@ -73,6 +73,9 @@ int main(int argc, char** argv){
|
|||
|
||||
LogStart();
|
||||
|
||||
LogParseConfigs();
|
||||
net.WelcomeHeader();
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
if(!net.ReadLoginConfig())
|
||||
|
@ -161,20 +164,23 @@ void NetConnection::HitKey(int keyhit)
|
|||
world_list.ListWorldsToConsole();
|
||||
break;
|
||||
}
|
||||
case '1':
|
||||
world_list.SendWorldChanged(1, true);
|
||||
break;
|
||||
case '2':
|
||||
world_list.SendWorldChanged(1, false);
|
||||
case 'v':
|
||||
case 'V':
|
||||
{
|
||||
printf("========Version Info=========\n");
|
||||
printf("%s %s\n", EQ2EMU_MODULE, CURRENT_VERSION);
|
||||
printf("Last Compiled on %s %s\n", COMPILE_DATE, COMPILE_TIME);
|
||||
printf("=============================\n\n");
|
||||
break;
|
||||
}
|
||||
case 'H':
|
||||
case 'h': {
|
||||
printf("============================\n");
|
||||
printf("===========Help=============\n");
|
||||
printf("Available Commands:\n");
|
||||
printf("l = Listing of World Servers\n");
|
||||
printf("v = Login Version\n");
|
||||
// printf("0 = Kick all connected world servers\n");
|
||||
printf("============================\n");
|
||||
printf("============================\n\n");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -283,11 +289,60 @@ void NetConnection::UpdateWindowTitle(char* iNewTitle) {
|
|||
#ifdef WIN32
|
||||
char tmp[500];
|
||||
if (iNewTitle) {
|
||||
snprintf(tmp, sizeof(tmp), "%s", iNewTitle);
|
||||
snprintf(tmp, sizeof(tmp), "Login: %s", iNewTitle);
|
||||
}
|
||||
else {
|
||||
snprintf(tmp, sizeof(tmp), "%i Server(s), %i Client(s) Connected", net.numservers, net.numclients);
|
||||
snprintf(tmp, sizeof(tmp), "%s, Version: %s: %i Server(s), %i Client(s) Connected", EQ2EMU_MODULE, CURRENT_VERSION, net.numservers, net.numclients);
|
||||
}
|
||||
SetConsoleTitle(tmp);
|
||||
#endif
|
||||
}
|
||||
|
||||
void NetConnection::WelcomeHeader()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
SetConsoleTextAttribute(console, FOREGROUND_WHITE_BOLD);
|
||||
#endif
|
||||
printf("Module: %s, Version: %s", EQ2EMU_MODULE, CURRENT_VERSION);
|
||||
#ifdef _WIN32
|
||||
SetConsoleTextAttribute(console, FOREGROUND_YELLOW_BOLD);
|
||||
#endif
|
||||
printf("\n\nCopyright (C) 2007-2020 EQ2Emulator. https://www.eq2emu.com \n\n");
|
||||
printf("EQ2Emulator is free software: you can redistribute it and/or modify\n");
|
||||
printf("it under the terms of the GNU General Public License as published by\n");
|
||||
printf("the Free Software Foundation, either version 3 of the License, or\n");
|
||||
printf("(at your option) any later version.\n\n");
|
||||
printf("EQ2Emulator is distributed in the hope that it will be useful,\n");
|
||||
printf("but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
|
||||
printf("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n");
|
||||
printf("GNU General Public License for more details.\n\n");
|
||||
#ifdef _WIN32
|
||||
SetConsoleTextAttribute(console, FOREGROUND_GREEN_BOLD);
|
||||
#endif
|
||||
printf(" /$$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$$$ \n");
|
||||
printf("| $$_____/ /$$__ $$ /$$__ $$| $$_____/ \n");
|
||||
printf("| $$ | $$ \\ $$|__/ \\ $$| $$ /$$$$$$/$$$$ /$$ /$$\n");
|
||||
printf("| $$$$$ | $$ | $$ /$$$$$$/| $$$$$ | $$_ $$_ $$| $$ | $$\n");
|
||||
printf("| $$__/ | $$ | $$ /$$____/ | $$__/ | $$ \\ $$ \\ $$| $$ | $$\n");
|
||||
printf("| $$ | $$/$$ $$| $$ | $$ | $$ | $$ | $$| $$ | $$\n");
|
||||
printf("| $$$$$$$$| $$$$$$/| $$$$$$$$| $$$$$$$$| $$ | $$ | $$| $$$$$$/\n");
|
||||
printf("|________/ \\____ $$$|________/|________/|__/ |__/ |__/ \\______/ \n");
|
||||
printf(" \\__/ \n\n");
|
||||
#ifdef _WIN32
|
||||
SetConsoleTextAttribute(console, FOREGROUND_MAGENTA_BOLD);
|
||||
#endif
|
||||
printf(" Website : https://eq2emu.com \n");
|
||||
printf(" Wiki : http://eq2emu.com:3001/ \n");
|
||||
printf(" Git : http://git.eq2emu.com \n");
|
||||
printf(" Discord : https://discord.gg/j92Ay9H \n\n");
|
||||
#ifdef _WIN32
|
||||
SetConsoleTextAttribute(console, FOREGROUND_WHITE_BOLD);
|
||||
#endif
|
||||
printf("For more detailed logging, modify 'Level' param the log_config.xml file.\n\n");
|
||||
#ifdef _WIN32
|
||||
SetConsoleTextAttribute(console, FOREGROUND_WHITE);
|
||||
#endif
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
|
||||
bool IsAllowingAccountCreation() { return allowAccountCreation; }
|
||||
|
||||
void WelcomeHeader();
|
||||
protected:
|
||||
friend class LWorld;
|
||||
bool Uplink_WrongVersion;
|
||||
|
|
|
@ -129,7 +129,7 @@ int main(int argc, char** argv) {
|
|||
LogStart();
|
||||
|
||||
LogParseConfigs();
|
||||
WelcomeHeader();
|
||||
net.WelcomeHeader();
|
||||
|
||||
LogWrite(INIT__INFO, 0, "Init", "Starting EQ2Emulator WorldServer...");
|
||||
//int32 server_startup = time(NULL);
|
||||
|
@ -963,17 +963,17 @@ void ZoneAuth::RemoveAuth(ZoneAuthRequest *zar) {
|
|||
}
|
||||
}
|
||||
|
||||
void WelcomeHeader()
|
||||
void NetConnection::WelcomeHeader()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
SetConsoleTextAttribute(console, FOREGROUND_WHITE_BOLD);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
SetConsoleTextAttribute(console, FOREGROUND_WHITE_BOLD);
|
||||
#endif
|
||||
printf("Module: %s, Version: %s", EQ2EMU_MODULE, CURRENT_VERSION);
|
||||
#ifdef _WIN32
|
||||
SetConsoleTextAttribute(console, FOREGROUND_YELLOW_BOLD);
|
||||
#endif
|
||||
printf("\n\nCopyright (C) 2007-2011 EQ2Emulator. http://eq2emulator.net/ \n\n");
|
||||
#ifdef _WIN32
|
||||
SetConsoleTextAttribute(console, FOREGROUND_YELLOW_BOLD);
|
||||
#endif
|
||||
printf("\n\nCopyright (C) 2007-2020 EQ2Emulator. https://www.eq2emu.com \n\n");
|
||||
printf("EQ2Emulator is free software: you can redistribute it and/or modify\n");
|
||||
printf("it under the terms of the GNU General Public License as published by\n");
|
||||
printf("the Free Software Foundation, either version 3 of the License, or\n");
|
||||
|
@ -982,9 +982,9 @@ void WelcomeHeader()
|
|||
printf("but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
|
||||
printf("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n");
|
||||
printf("GNU General Public License for more details.\n\n");
|
||||
#ifdef _WIN32
|
||||
SetConsoleTextAttribute(console, FOREGROUND_GREEN_BOLD);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
SetConsoleTextAttribute(console, FOREGROUND_GREEN_BOLD);
|
||||
#endif
|
||||
printf(" /$$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$$$ \n");
|
||||
printf("| $$_____/ /$$__ $$ /$$__ $$| $$_____/ \n");
|
||||
printf("| $$ | $$ \\ $$|__/ \\ $$| $$ /$$$$$$/$$$$ /$$ /$$\n");
|
||||
|
@ -994,20 +994,20 @@ void WelcomeHeader()
|
|||
printf("| $$$$$$$$| $$$$$$/| $$$$$$$$| $$$$$$$$| $$ | $$ | $$| $$$$$$/\n");
|
||||
printf("|________/ \\____ $$$|________/|________/|__/ |__/ |__/ \\______/ \n");
|
||||
printf(" \\__/ \n\n");
|
||||
#ifdef _WIN32
|
||||
SetConsoleTextAttribute(console, FOREGROUND_MAGENTA_BOLD);
|
||||
#endif
|
||||
printf(" Website : http://eq2emulator.net \n");
|
||||
printf(" Forums : http://eq2emulator.net/phpBB3/ \n");
|
||||
printf(" Contributors: http://eq2emulator.net/wiki/index.php/Developer:Contributors \n");
|
||||
printf(" SVN : http://svn.eq2emulator.net/svn/eq2server \n\n");
|
||||
#ifdef _WIN32
|
||||
SetConsoleTextAttribute(console, FOREGROUND_WHITE_BOLD);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
SetConsoleTextAttribute(console, FOREGROUND_MAGENTA_BOLD);
|
||||
#endif
|
||||
printf(" Website : https://eq2emu.com \n");
|
||||
printf(" Wiki : http://eq2emu.com:3001/ \n");
|
||||
printf(" Git : http://git.eq2emu.com \n");
|
||||
printf(" Discord : https://discord.gg/j92Ay9H \n\n");
|
||||
#ifdef _WIN32
|
||||
SetConsoleTextAttribute(console, FOREGROUND_WHITE_BOLD);
|
||||
#endif
|
||||
printf("For more detailed logging, modify 'Level' param the log_config.xml file.\n\n");
|
||||
#ifdef _WIN32
|
||||
SetConsoleTextAttribute(console, FOREGROUND_WHITE);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
SetConsoleTextAttribute(console, FOREGROUND_WHITE);
|
||||
#endif
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
ThreadReturnType EQ2ConsoleListener(void *tmp);
|
||||
void CatchSignal(int sig_num);
|
||||
void UpdateWindowTitle(char* iNewTitle);
|
||||
void WelcomeHeader();
|
||||
|
||||
#define PORT 9000
|
||||
#define LOGIN_PORT 9100
|
||||
|
@ -70,6 +69,8 @@ public:
|
|||
~NetConnection() { }
|
||||
|
||||
bool ReadLoginINI();
|
||||
void WelcomeHeader();
|
||||
|
||||
bool LoginServerInfo;
|
||||
bool UpdateStats;
|
||||
char* GetLoginInfo(int16* oPort);
|
||||
|
|
|
@ -132,8 +132,13 @@ struct sockaddr_in address;
|
|||
fcntl(sock, F_SETFL, O_NONBLOCK);
|
||||
#endif
|
||||
//moved these because on windows the output was delayed and causing the console window to look bad
|
||||
LogWrite(WORLD__DEBUG, 0, "World", "Starting factory Reader");
|
||||
LogWrite(WORLD__DEBUG, 0, "World", "Starting factory Writer");
|
||||
#ifdef LOGIN
|
||||
LogWrite(LOGIN__DEBUG, 0, "Login", "Starting factory Reader");
|
||||
LogWrite(LOGIN__DEBUG, 0, "Login", "Starting factory Writer");
|
||||
#elif WORLD
|
||||
LogWrite(WORLD__DEBUG, 0, "World", "Starting factory Reader");
|
||||
LogWrite(WORLD__DEBUG, 0, "World", "Starting factory Writer");
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
_beginthread(EQStreamFactoryReaderLoop,0, this);
|
||||
_beginthread(EQStreamFactoryWriterLoop,0, this);
|
||||
|
@ -297,7 +302,12 @@ void EQStreamFactory::CheckTimeout(bool remove_all)
|
|||
//give it a little time for everybody to finish with it
|
||||
} else {
|
||||
//everybody is done, we can delete it now
|
||||
|
||||
#ifdef LOGIN
|
||||
LogWrite(LOGIN__DEBUG, 0, "Login", "Removing connection...");
|
||||
#else
|
||||
LogWrite(WORLD__DEBUG, 0, "World", "Removing connection...");
|
||||
#endif
|
||||
map<string,EQStream *>::iterator temp=stream_itr;
|
||||
stream_itr++;
|
||||
//let whoever has the stream outside delete it
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "LogTypes.h"
|
||||
|
||||
#ifndef VERSION_H
|
||||
#define VERSION_H
|
||||
|
||||
|
@ -36,9 +38,9 @@
|
|||
#endif
|
||||
|
||||
#if defined(LOGIN)
|
||||
#define CURRENT_VERSION "0.8.1-gemini2"
|
||||
#define CURRENT_VERSION "0.8.1-cancer1"
|
||||
#elif defined(WORLD)
|
||||
#define CURRENT_VERSION "0.8.1-gemini2"
|
||||
#define CURRENT_VERSION "0.8.1-cancer1"
|
||||
#else
|
||||
#define CURRENT_VERSION "0.7.3-dev"
|
||||
#endif
|
||||
|
@ -52,4 +54,3 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue