diff --git a/src/Http.cpp b/src/Http.cpp index 2af767b..a20173d 100644 --- a/src/Http.cpp +++ b/src/Http.cpp @@ -172,7 +172,6 @@ Http::Server::THttpServerInstance::THttpServerInstance() { } void Http::Server::THttpServerInstance::operator()() try { - beammp_info("HTTP(S) Server started on port " + std::to_string(Application::Settings.HTTPServerPort)); std::unique_ptr HttpLibServerInstance; HttpLibServerInstance = std::make_unique(); // todo: make this IP agnostic so people can set their own IP @@ -214,10 +213,6 @@ void Http::Server::THttpServerInstance::operator()() try { beammp_debug("Http Server: " + Req.method + " " + Req.target + " -> " + std::to_string(Res.status)); }); Application::SetSubsystemStatus("HTTPServer", Application::Status::Good); - auto ret = HttpLibServerInstance->listen(Application::Settings.HTTPServerIP.c_str(), Application::Settings.HTTPServerPort); - if (!ret) { - beammp_error("Failed to start http server (failed to listen). Please ensure the http server is configured properly in the ServerConfig.toml, or turn it off if you don't need it."); - } } catch (const std::exception& e) { beammp_error("Failed to start http server. Please ensure the http server is configured properly in the ServerConfig.toml, or turn it off if you don't need it. Error: " + std::string(e.what())); } diff --git a/src/TConfig.cpp b/src/TConfig.cpp index c3d4b90..f0722c3 100644 --- a/src/TConfig.cpp +++ b/src/TConfig.cpp @@ -170,7 +170,7 @@ void TConfig::CreateConfigFile() { try { if (fs::exists("Server.cfg")) { // parse it (this is weird and bad and should be removed in some future version) - ParseOldFormat(); + // ParseOldFormat(); } } catch (const std::exception& e) { beammp_error("an error occurred and was ignored during config transfer: " + std::string(e.what())); @@ -179,55 +179,6 @@ void TConfig::CreateConfigFile() { FlushToFile(); } -void TConfig::TryReadValue(toml::value& Table, const std::string& Category, const std::string_view& Key, const std::string_view& Env, std::string& OutValue) { - if (!Env.empty()) { - // If this environment variable exists, return a C-String and check if it's empty or not - if (const char* envp = std::getenv(Env.data()); envp != nullptr && std::strcmp(envp, "") != 0) { - OutValue = std::string(envp); - return; - } - } - if (mDisableConfig) { - return; - } - if (Table[Category.c_str()][Key.data()].is_string()) { - OutValue = Table[Category.c_str()][Key.data()].as_string(); - } -} - -void TConfig::TryReadValue(toml::value& Table, const std::string& Category, const std::string_view& Key, const std::string_view& Env, bool& OutValue) { - if (!Env.empty()) { - // If this environment variable exists, return a C-String and check if it's empty or not - if (const char* envp = std::getenv(Env.data()); envp != nullptr && std::strcmp(envp, "") != 0) { - auto Str = std::string(envp); - OutValue = Str == "1" || Str == "true"; - return; - } - } - if (mDisableConfig) { - return; - } - if (Table[Category.c_str()][Key.data()].is_boolean()) { - OutValue = Table[Category.c_str()][Key.data()].as_boolean(); - } -} - -void TConfig::TryReadValue(toml::value& Table, const std::string& Category, const std::string_view& Key, const std::string_view& Env, int& OutValue) { - if (!Env.empty()) { - // If this environment variable exists, return a C-String and check if it's empty or not - if (const char* envp = std::getenv(Env.data()); envp != nullptr && std::strcmp(envp, "") != 0) { - OutValue = int(std::strtol(envp, nullptr, 10)); - return; - } - } - if (mDisableConfig) { - return; - } - if (Table[Category.c_str()][Key.data()].is_integer()) { - OutValue = int(Table[Category.c_str()][Key.data()].as_integer()); - } -} - // This arcane template magic is needed for using lambdas as overloaded visitors // See https://en.cppreference.com/w/cpp/utility/variant/visit for reference template diff --git a/src/THeartbeatThread.cpp b/src/THeartbeatThread.cpp index 2e282a4..77a3348 100644 --- a/src/THeartbeatThread.cpp +++ b/src/THeartbeatThread.cpp @@ -54,9 +54,6 @@ void THeartbeatThread::operator()() { Last = Body; LastNormalUpdateTime = Now; - if (!Application::Settings.CustomIP.empty()) { - Body += "&ip=" + Application::Settings.CustomIP; - } auto Target = "/heartbeat"; unsigned int ResponseCode = 0; diff --git a/src/TNetwork.cpp b/src/TNetwork.cpp index 9b17bce..a18b506 100644 --- a/src/TNetwork.cpp +++ b/src/TNetwork.cpp @@ -334,22 +334,6 @@ std::shared_ptr TNetwork::Authentication(TConnection&& RawConnection) { return nullptr; } - if(!Application::Settings.Password.empty()) { // ask password - if(!TCPSend(*Client, StringToVector("S"))) { - // TODO: handle - } - beammp_info("Waiting for password"); - Data = TCPRcv(*Client); - std::string Pass = std::string(reinterpret_cast(Data.data()), Data.size()); - if(Pass != HashPassword(Application::Settings.Password)) { - beammp_debug(Client->GetName() + " attempted to connect with a wrong password"); - ClientKick(*Client, "Wrong password!"); - return {}; - } else { - beammp_debug(Client->GetName() + " used the correct password"); - } - } - beammp_debug("Name -> " + Client->GetName() + ", Guest -> " + std::to_string(Client->IsGuest()) + ", Roles -> " + Client->GetRoles()); mServer.ForEachClient([&](const std::weak_ptr& ClientPtr) -> bool { std::shared_ptr Cl; diff --git a/src/TServer.cpp b/src/TServer.cpp index db1541a..9b9138d 100644 --- a/src/TServer.cpp +++ b/src/TServer.cpp @@ -123,17 +123,6 @@ TEST_CASE("GetPidVid") { TServer::TServer(const std::vector& Arguments) { beammp_info("BeamMP Server v" + Application::ServerVersionString()); Application::SetSubsystemStatus("Server", Application::Status::Starting); - if (Arguments.size() > 1) { - Application::Settings.CustomIP = Arguments[0]; - size_t n = std::count(Application::Settings.CustomIP.begin(), Application::Settings.CustomIP.end(), '.'); - auto p = Application::Settings.CustomIP.find_first_not_of(".0123456789"); - if (p != std::string::npos || n != 3 || Application::Settings.CustomIP.substr(0, 3) == "127") { - Application::Settings.CustomIP.clear(); - beammp_warn("IP Specified is invalid! Ignoring"); - } else { - beammp_info("server started with custom IP"); - } - } Application::SetSubsystemStatus("Server", Application::Status::Good); }