mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-07-12 17:54:04 +00:00
Fix unexpected type for backend region
This commit is contained in:
@@ -86,8 +86,6 @@ public:
|
||||
|
||||
static std::string GetBackendUrlForAuth();
|
||||
static std::string GetBackendUrlForSocketIO();
|
||||
static void TopLevelDomainFailed(bool failed);
|
||||
static std::string RegionToTopLevelDomain(const std::string region);
|
||||
static void CheckForUpdates();
|
||||
static std::array<uint8_t, 3> VersionStrToInts(const std::string& str);
|
||||
static bool IsOutdated(const Version& Current, const Version& Newest);
|
||||
|
||||
@@ -226,16 +226,22 @@ void TConfig::TryReadValue(toml::value& Table, const std::string& Category, cons
|
||||
if constexpr (std::is_same_v<T, std::string>) {
|
||||
if (Table[Category.c_str()][Key.data()].is_string())
|
||||
Application::Settings.set(key, Table[Category.c_str()][Key.data()].as_string());
|
||||
else if (Table[Category.c_str()][Key.data()].is_empty())
|
||||
beammp_debugf("Value '{}.{}' is empty", Category, Key);
|
||||
else
|
||||
beammp_warnf("Value '{}.{}' has unexpected type, expected type 'string'", Category, Key);
|
||||
} else if constexpr (std::is_same_v<T, int>) {
|
||||
if (Table[Category.c_str()][Key.data()].is_integer())
|
||||
Application::Settings.set(key, int(Table[Category.c_str()][Key.data()].as_integer()));
|
||||
else if (Table[Category.c_str()][Key.data()].is_empty())
|
||||
beammp_debugf("Value '{}.{}' is empty", Category, Key);
|
||||
else
|
||||
beammp_warnf("Value '{}.{}' has unexpected type, expected type 'integer'", Category, Key);
|
||||
} else if constexpr (std::is_same_v<T, bool>) {
|
||||
if (Table[Category.c_str()][Key.data()].is_boolean())
|
||||
Application::Settings.set(key, Table[Category.c_str()][Key.data()].as_boolean());
|
||||
else if (Table[Category.c_str()][Key.data()].is_empty())
|
||||
beammp_debugf("Value '{}.{}' is empty", Category, Key);
|
||||
else
|
||||
beammp_warnf("Value '{}.{}' has unexpected type, expected type 'boolean'", Category, Key);
|
||||
} else {
|
||||
|
||||
+2
-1
@@ -25,6 +25,7 @@
|
||||
#include "Http.h"
|
||||
#include "LuaAPI.h"
|
||||
#include "TLuaEngine.h"
|
||||
#include "RegionHandler.h"
|
||||
|
||||
#include <ctime>
|
||||
#include <lua.hpp>
|
||||
@@ -298,7 +299,7 @@ void TConsole::Command_NetTest(const std::string& cmd, const std::vector<std::st
|
||||
std::string T = Http::GET(
|
||||
Application::GetServerCheckUrl() + "/api/v2/beammp/" + std::to_string(Application::Settings.getAsInt(Settings::Key::General_Port)), &status);
|
||||
if (T == Http::ErrorString || status != 200) {
|
||||
Application::TopLevelDomainFailed();
|
||||
RegionHandler::TopLevelDomainFailed();
|
||||
T = Http::GET(Application::GetServerCheckUrl() + "/api/v2/beammp/" + std::to_string(Application::Settings.getAsInt(Settings::Key::General_Port)), &status);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "Client.h"
|
||||
#include "Common.h"
|
||||
#include "Http.h"
|
||||
#include "RegionHandler.h"
|
||||
// #include "SocketIO.h"
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
@@ -63,7 +64,7 @@ void THeartbeatThread::operator()() {
|
||||
for (const auto& Url : Application::GetBackendUrlsInOrder()) {
|
||||
T = Http::POST(Url + Target, Body, "application/json", &ResponseCode, { { "api-v", "2" } });
|
||||
if (T == Http::ErrorString || ResponseCode != 200) {
|
||||
Application::TopLevelDomainFailed();
|
||||
RegionHandler::TopLevelDomainFailed();
|
||||
T = Http::POST(Url + Target, Body, "application/json", &ResponseCode, { { "api-v", "2" } });
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@
|
||||
#include "Client.h"
|
||||
#include "Common.h"
|
||||
#include "LuaAPI.h"
|
||||
#include "RegionHandler.h"
|
||||
#include "TConnectionLimiter.h"
|
||||
#include "THeartbeatThread.h"
|
||||
#include "TLuaEngine.h"
|
||||
@@ -441,7 +442,7 @@ std::shared_ptr<TClient> TNetwork::Authentication(TConnection&& RawConnection) {
|
||||
unsigned int ResponseCode = 0;
|
||||
AuthResStr = Http::POST(Application::GetBackendUrlForAuth() + Target, AuthReq.dump(), "application/json", &ResponseCode);
|
||||
if (AuthResStr == Http::ErrorString || ResponseCode != 200) {
|
||||
Application::TopLevelDomainFailed();
|
||||
RegionHandler::TopLevelDomainFailed();
|
||||
AuthResStr = Http::POST(Application::GetBackendUrlForAuth() + Target, AuthReq.dump(), "application/json", &ResponseCode);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user