mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-05-16 19:41:21 +00:00
diagnostics
log checksum Update WorldServer.cpp Update WorldServer.cpp lotta this Update WorldServer.cpp Update WorldServer.cpp Update WorldServer.cpp Update Logger.cpp logs Update WorldServer.cpp
This commit is contained in:
parent
0c948a8df6
commit
c305af7172
@ -1,7 +1,7 @@
|
|||||||
#include "Diagnostics.h"
|
#include "Diagnostics.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
#define _XOPEN_SOURCE
|
||||||
// If we're on Win32, we'll include our minidump writer
|
// If we're on Win32, we'll include our minidump writer
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ LONG CALLBACK unhandled_handler(EXCEPTION_POINTERS* e) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__linux__) //&& !defined(__clang__) // backtrace is a gcc exclusive system library
|
// #if defined(__linux__) //&& !defined(__clang__) // backtrace is a gcc exclusive system library
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
#include <ucontext.h>
|
#include <ucontext.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -219,16 +219,16 @@ void MakeBacktrace() {
|
|||||||
|
|
||||||
std::set_terminate(OnTerminate);
|
std::set_terminate(OnTerminate);
|
||||||
}
|
}
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
void Diagnostics::Initialize() {
|
void Diagnostics::Initialize() {
|
||||||
#ifdef _WIN32
|
// #ifdef _WIN32
|
||||||
SetUnhandledExceptionFilter(unhandled_handler);
|
// SetUnhandledExceptionFilter(unhandled_handler);
|
||||||
#elif defined(__linux__) //&& !defined(__clang__)
|
// #elif defined(__linux__) //&& !defined(__clang__)
|
||||||
MakeBacktrace();
|
MakeBacktrace();
|
||||||
#else
|
// #else
|
||||||
fprintf(stderr, "Diagnostics not supported on this platform.\n");
|
// fprintf(stderr, "Diagnostics not supported on this platform.\n");
|
||||||
#endif
|
// #endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Diagnostics::m_ProcessName{};
|
std::string Diagnostics::m_ProcessName{};
|
||||||
|
@ -58,6 +58,7 @@ void Logger::vLog(const char* format, va_list args) {
|
|||||||
for (const auto& writer : m_Writers) {
|
for (const auto& writer : m_Writers) {
|
||||||
writer->Log(timeStr, message);
|
writer->Log(timeStr, message);
|
||||||
}
|
}
|
||||||
|
Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::Log(const char* className, const char* format, ...) {
|
void Logger::Log(const char* className, const char* format, ...) {
|
||||||
|
@ -267,8 +267,6 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
// pre calculate the FDB checksum
|
// pre calculate the FDB checksum
|
||||||
if (Game::config->GetValue("check_fdb") == "1") {
|
if (Game::config->GetValue("check_fdb") == "1") {
|
||||||
std::ifstream fileStream;
|
|
||||||
|
|
||||||
static const std::vector<std::string> aliases = {
|
static const std::vector<std::string> aliases = {
|
||||||
"CDServers.fdb",
|
"CDServers.fdb",
|
||||||
"cdserver.fdb",
|
"cdserver.fdb",
|
||||||
@ -277,31 +275,29 @@ int main(int argc, char** argv) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (const auto& file : aliases) {
|
for (const auto& file : aliases) {
|
||||||
fileStream.open(Game::assetManager->GetResPath() / file, std::ios::binary | std::ios::in);
|
auto cdclient = Game::assetManager->GetFile("cdclient.fdb");
|
||||||
if (fileStream.is_open()) {
|
if (cdclient) {
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const int32_t bufferSize = 1024;
|
const int32_t bufferSize = 1024;
|
||||||
MD5 md5;
|
MD5 md5;
|
||||||
|
|
||||||
char fileStreamBuffer[1024] = {};
|
char fileStreamBuffer[1024] = {};
|
||||||
|
|
||||||
while (!fileStream.eof()) {
|
while (!cdclient.eof()) {
|
||||||
memset(fileStreamBuffer, 0, bufferSize);
|
memset(fileStreamBuffer, 0, bufferSize);
|
||||||
fileStream.read(fileStreamBuffer, bufferSize);
|
cdclient.read(fileStreamBuffer, bufferSize);
|
||||||
md5.update(fileStreamBuffer, fileStream.gcount());
|
md5.update(fileStreamBuffer, cdclient.gcount());
|
||||||
}
|
}
|
||||||
|
|
||||||
fileStream.close();
|
|
||||||
|
|
||||||
const char* nullTerminateBuffer = "\0";
|
const char* nullTerminateBuffer = "\0";
|
||||||
md5.update(nullTerminateBuffer, 1); // null terminate the data
|
md5.update(nullTerminateBuffer, 1); // null terminate the data
|
||||||
md5.finalize();
|
md5.finalize();
|
||||||
databaseChecksum = md5.hexdigest();
|
databaseChecksum = md5.hexdigest();
|
||||||
|
|
||||||
LOG("FDB Checksum calculated as: %s", databaseChecksum.c_str());
|
LOG("FDB Checksum calculated as: %s", databaseChecksum.c_str());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t currentFrameDelta = highFrameDelta;
|
uint32_t currentFrameDelta = highFrameDelta;
|
||||||
@ -869,10 +865,12 @@ void HandlePacket(Packet* packet) {
|
|||||||
Game::server->Disconnect(packet->systemAddress, eServerDisconnectIdentifiers::CHARACTER_NOT_FOUND);
|
Game::server->Disconnect(packet->systemAddress, eServerDisconnectIdentifiers::CHARACTER_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
LOG("server %s client %s", databaseChecksum.c_str(), clientDatabaseChecksum.string.c_str());
|
||||||
|
|
||||||
// Developers may skip this check
|
// Developers may skip this check
|
||||||
if (clientDatabaseChecksum.string != databaseChecksum) {
|
if (clientDatabaseChecksum.string != databaseChecksum) {
|
||||||
|
|
||||||
|
LOG("");
|
||||||
if (accountInfo->maxGmLevel < eGameMasterLevel::DEVELOPER) {
|
if (accountInfo->maxGmLevel < eGameMasterLevel::DEVELOPER) {
|
||||||
LOG("Client's database checksum does not match the server's, aborting connection.");
|
LOG("Client's database checksum does not match the server's, aborting connection.");
|
||||||
std::vector<Stamp> stamps;
|
std::vector<Stamp> stamps;
|
||||||
@ -884,6 +882,7 @@ void HandlePacket(Packet* packet) {
|
|||||||
Game::config->GetValue("cdclient_mismatch_message"), "", 0, "", stamps);
|
Game::config->GetValue("cdclient_mismatch_message"), "", 0, "", stamps);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
LOG("");
|
||||||
AMFArrayValue args;
|
AMFArrayValue args;
|
||||||
|
|
||||||
args.Insert("title", Game::config->GetValue("cdclient_mismatch_title"));
|
args.Insert("title", Game::config->GetValue("cdclient_mismatch_title"));
|
||||||
@ -896,18 +895,21 @@ void HandlePacket(Packet* packet) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG("");
|
||||||
//Request the session info from Master:
|
//Request the session info from Master:
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, MessageType::Master::REQUEST_SESSION_KEY);
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, MessageType::Master::REQUEST_SESSION_KEY);
|
||||||
bitStream.Write(username);
|
bitStream.Write(username);
|
||||||
Game::server->SendToMaster(bitStream);
|
Game::server->SendToMaster(bitStream);
|
||||||
|
|
||||||
|
LOG("");
|
||||||
//Insert info into our pending list
|
//Insert info into our pending list
|
||||||
tempSessionInfo info;
|
tempSessionInfo info;
|
||||||
info.sysAddr = SystemAddress(packet->systemAddress);
|
info.sysAddr = SystemAddress(packet->systemAddress);
|
||||||
info.hash = sessionKey.GetAsString();
|
info.hash = sessionKey.GetAsString();
|
||||||
m_PendingUsers.insert(std::make_pair(username.GetAsString(), info));
|
m_PendingUsers.insert(std::make_pair(username.GetAsString(), info));
|
||||||
|
|
||||||
|
LOG("");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user