From 433f14c352a0ae366cff2cbe03753b2198a77848 Mon Sep 17 00:00:00 2001 From: Alex <18037145+salcodes1@users.noreply.github.com> Date: Tue, 28 Dec 2021 03:31:33 +0200 Subject: [PATCH] partial commit --- r5dev/core/stdafx.h | 2 ++ r5dev/networksystem/r5net.h | 22 ++++++++++------------ r5dev/server/server.cpp | 11 ++++++++++- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/r5dev/core/stdafx.h b/r5dev/core/stdafx.h index c910af11..1de1db21 100644 --- a/r5dev/core/stdafx.h +++ b/r5dev/core/stdafx.h @@ -45,6 +45,8 @@ #include "public/include/httplib.h" #include "public/include/json.hpp" +#include "networksystem/net_structs.h" + #ifndef SDKLAUNCHER namespace { diff --git a/r5dev/networksystem/r5net.h b/r5dev/networksystem/r5net.h index 072412a2..455a985a 100644 --- a/r5dev/networksystem/r5net.h +++ b/r5dev/networksystem/r5net.h @@ -6,22 +6,20 @@ namespace R5Net class Client { public: - Client(std::string serverString) : m_HttpClient(serverString.c_str()) + Client(std::string masterServerConnectionString) : HttpClient(masterServerConnectionString.c_str()) { - m_HttpClient.set_connection_timeout(10); + HttpClient.set_connection_timeout(25); } - - std::vector GetServersList(std::string& svOutMessage); - bool PostServerHost(std::string& svOutMessage, std::string& svOutToken, const ServerListing& slServerListing); - bool GetServerByToken(ServerListing& slOutServer, std::string& svOutMessage, const std::string svToken); - bool GetClientIsBanned(std::string svIpAddress, std::int64_t nOriginID, std::string& svOutErrCl); - std::string GetSDKVersion(); - Client* pR5net = nullptr; - Client* GetR5Net() { return pR5net; } - private: - httplib::Client m_HttpClient; + R5NET_GET_ENDPOINT(GetGlobalStats, "/api/stats", GetGlobalStatsMSResponse) + R5NET_GET_ENDPOINT(GetGameServersList, "/api/game_servers/list", GetGameServersListMSResponse) + + R5NET_POST_ENDPOINT(UpdateMyGameServer, "/api/game_servers/update", UpdateGameServerMSRequest, UpdateGameServerMSResponse) + R5NET_POST_ENDPOINT(GetClientIsBanned, "/api/ban_system/is_user_banned", GetIsUserBannedMSRequest, GetIsUserBannedMSResponse) + + + }; } extern R5Net::Client* g_pR5net; diff --git a/r5dev/server/server.cpp b/r5dev/server/server.cpp index 02f42d66..a877c52f 100644 --- a/r5dev/server/server.cpp +++ b/r5dev/server/server.cpp @@ -12,7 +12,16 @@ void IsClientBanned(R5Net::Client* pR5net, const std::string svIPAddr, std::int64_t nNucleusID) { std::string svError = std::string(); - bool bCompBanned = pR5net && pR5net->GetClientIsBanned(svIPAddr, nNucleusID, svError); + + R5Net::GetIsUserBannedMSRequest req{nNucleusID, svIPAddr}; + R5Net::GetIsUserBannedMSResponse res = pR5net->GetClientIsBanned(req); + + switch (res.status) + { + // TODO: EVENTUALLY IMPLEMENT SITUATIONS WHERE REQUEST DIDNT SUCCEED + } + + bool bCompBanned = res.isBanned; if (bCompBanned) { while (bCompBanned)