Handle edge cases for IW4x dedicated server (increases stability)

This commit is contained in:
Louvenarde 2023-10-21 19:52:15 +02:00
parent defdca0b93
commit fd5e229219
2 changed files with 12 additions and 1 deletions

View File

@ -437,6 +437,12 @@ namespace Components
static std::optional<std::string> InfoHandler([[maybe_unused]] mg_connection* c, [[maybe_unused]] const mg_http_message* hm) static std::optional<std::string> InfoHandler([[maybe_unused]] mg_connection* c, [[maybe_unused]] const mg_http_message* hm)
{ {
if (!(*Game::com_sv_running)->current.enabled)
{
// Game is not running ,cannot return info
return std::nullopt;
}
const auto status = ServerInfo::GetInfo(); const auto status = ServerInfo::GetInfo();
const auto host = ServerInfo::GetHostInfo(); const auto host = ServerInfo::GetHostInfo();
@ -586,6 +592,12 @@ namespace Components
Utils::String::Replace(url, "\\", "/"); Utils::String::Replace(url, "\\", "/");
if (url.size() <= 5)
{
mg_http_reply(c, 403, "Content-Type: text/html\r\n", "%s", "400 - Bad requestt");
return {};
}
url = url.substr(6); // Strip /file url = url.substr(6); // Strip /file
Utils::String::Replace(url, "%20", " "); Utils::String::Replace(url, "%20", " ");

View File

@ -208,7 +208,6 @@ namespace Components
nlohmann::json MapRotation::to_json() nlohmann::json MapRotation::to_json()
{ {
assert(!DedicatedRotation.empty());
return DedicatedRotation.to_json(); return DedicatedRotation.to_json();
} }