From ab9d36e0d86af052d24297e4de1056825120b91c Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sat, 29 Apr 2023 00:05:47 +0200 Subject: [PATCH] Send client's persona name to the master server Will be used on the master server for additional checking. --- r5dev/engine/server/server.cpp | 2 +- r5dev/engine/server/sv_main.cpp | 5 +++-- r5dev/engine/server/sv_main.h | 2 +- r5dev/networksystem/pylon.cpp | 4 +++- r5dev/networksystem/pylon.h | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/r5dev/engine/server/server.cpp b/r5dev/engine/server/server.cpp index a41f3a19..2bb47c4e 100644 --- a/r5dev/engine/server/server.cpp +++ b/r5dev/engine/server/server.cpp @@ -119,7 +119,7 @@ bool CServer::AuthClient(user_creds_s* pChallenge) if (sv_globalBanlist->GetBool()) { - std::thread th(SV_IsClientBanned, string(pszAddresBuffer), nNucleusID); + std::thread th(SV_IsClientBanned, string(pszAddresBuffer), nNucleusID, string(pszPersonaName)); th.detach(); } diff --git a/r5dev/engine/server/sv_main.cpp b/r5dev/engine/server/sv_main.cpp index ea7b72d7..37ef5818 100644 --- a/r5dev/engine/server/sv_main.cpp +++ b/r5dev/engine/server/sv_main.cpp @@ -15,11 +15,11 @@ //----------------------------------------------------------------------------- // Purpose: checks if particular client is banned on the comp server //----------------------------------------------------------------------------- -void SV_IsClientBanned(const string& svIPAddr, const uint64_t nNucleusID) +void SV_IsClientBanned(const string& svIPAddr, const uint64_t nNucleusID, const string& svPersonaName) { string svError; + bool bCompBanned = g_pMasterServer->CheckForBan(svIPAddr, nNucleusID, svPersonaName, svError); - bool bCompBanned = g_pMasterServer->CheckForBan(svIPAddr, nNucleusID, svError); if (bCompBanned) { if (!ThreadInMainThread()) @@ -50,6 +50,7 @@ void SV_ProcessBulkCheck(const BannedVec_t& bannedVec) void SV_CheckForBan(const BannedVec_t* pBannedVec /*= nullptr*/) { + Assert(ThreadInMainThread()); BannedVec_t bannedVec; for (int c = 0; c < MAX_PLAYERS; c++) // Loop through all possible client instances. diff --git a/r5dev/engine/server/sv_main.h b/r5dev/engine/server/sv_main.h index 3d7bf8f3..941f8eb8 100644 --- a/r5dev/engine/server/sv_main.h +++ b/r5dev/engine/server/sv_main.h @@ -27,7 +27,7 @@ inline bool* s_bIsDedicated = nullptr; void SV_InitGameDLL(); void SV_ShutdownGameDLL(); bool SV_ActivateServer(); -void SV_IsClientBanned(const string& svIPAddr, const uint64_t nNucleusID); +void SV_IsClientBanned(const string& svIPAddr, const uint64_t nNucleusID, const string& svPersonaName); void SV_CheckForBan(const BannedVec_t* pBannedVec = nullptr); /////////////////////////////////////////////////////////////////////////////// diff --git a/r5dev/networksystem/pylon.cpp b/r5dev/networksystem/pylon.cpp index 842e1643..e3e7e816 100644 --- a/r5dev/networksystem/pylon.cpp +++ b/r5dev/networksystem/pylon.cpp @@ -265,9 +265,11 @@ bool CPylon::GetBannedList(const BannedVec_t& inBannedVec, BannedVec_t& outBanne // &outReason - <- contains banned reason if any. // Output : True if banned, false if not banned. //----------------------------------------------------------------------------- -bool CPylon::CheckForBan(const string& ipAddress, const uint64_t nucleusId, string& outReason) const +bool CPylon::CheckForBan(const string& ipAddress, const uint64_t nucleusId, + const string& personaName, string& outReason) const { nlohmann::json requestJson = nlohmann::json::object(); + requestJson["name"] = personaName; requestJson["id"] = nucleusId; requestJson["ip"] = ipAddress; diff --git a/r5dev/networksystem/pylon.h b/r5dev/networksystem/pylon.h index c73eb909..3f72d963 100644 --- a/r5dev/networksystem/pylon.h +++ b/r5dev/networksystem/pylon.h @@ -11,7 +11,7 @@ public: bool PostServerHost(string& outMessage, string& svOutToken, const NetGameServer_t& netGameServer) const; bool GetBannedList(const BannedVec_t& inBannedVec, BannedVec_t& outBannedVec) const; - bool CheckForBan(const string& ipAddress, const uint64_t nucleusId, string& outReason) const; + bool CheckForBan(const string& ipAddress, const uint64_t nucleusId, const string& personaName, string& outReason) const; void ExtractError(const nlohmann::json& resultBody, string& outMessage, CURLINFO status, const char* errorText = nullptr) const; void ExtractError(const string& response, string& outMessage, CURLINFO status, const char* messageText = nullptr) const;