diff --git a/include/Common.h b/include/Common.h index 2cf15b9..f448937 100644 --- a/include/Common.h +++ b/include/Common.h @@ -7,6 +7,7 @@ extern TSentry Sentry; #include #include #include +#include #include #include #include @@ -40,8 +41,6 @@ public: std::string Resource { "Resources" }; std::string MapName { "/levels/gridmap_v2/info.json" }; std::string Key {}; - std::string SSLKeyPath { "./.ssl/HttpServer/key.pem" }; - std::string SSLCertPath { "./.ssl/HttpServer/cert.pem" }; bool HTTPServerEnabled { false }; int MaxPlayers { 10 }; bool Private { true }; diff --git a/src/Http.cpp b/src/Http.cpp index fd67fb5..ad88fb0 100644 --- a/src/Http.cpp +++ b/src/Http.cpp @@ -149,15 +149,8 @@ Http::Server::THttpServerInstance::THttpServerInstance() { } void Http::Server::THttpServerInstance::operator()() { - beammp_info("HTTP(S) Server started on port " + std::to_string(Application::Settings.HTTPServerPort)); - std::unique_ptr HttpLibServerInstance; - if (Application::Settings.HTTPServerUseSSL) { - HttpLibServerInstance = std::make_unique( - reinterpret_cast(Http::Server::THttpServerInstance::CertFilePath.c_str()), - reinterpret_cast(Http::Server::THttpServerInstance::KeyFilePath.c_str())); - } else { - HttpLibServerInstance = std::make_unique(); - } + beammp_info("HTTP Server started on port " + std::to_string(Application::Settings.HTTPServerPort)); + std::unique_ptr HttpLibServerInstance = std::make_unique(); // todo: make this IP agnostic so people can set their own IP HttpLibServerInstance->Get("/", [](const httplib::Request&, httplib::Response& res) { res.set_content("

Hello World!

BeamMP Server can now serve HTTP requests!

", "text/html"); diff --git a/src/TConfig.cpp b/src/TConfig.cpp index f1c3126..ee1a936 100644 --- a/src/TConfig.cpp +++ b/src/TConfig.cpp @@ -20,11 +20,8 @@ static constexpr std::string_view StrAuthKey = "AuthKey"; static constexpr std::string_view StrSendErrors = "SendErrors"; static constexpr std::string_view StrSendErrorsMessageEnabled = "SendErrorsShowMessage"; static constexpr std::string_view StrHTTPServerEnabled = "HTTPServerEnabled"; -static constexpr std::string_view StrHTTPServerUseSSL = "UseSSL"; // HTTP -static constexpr std::string_view StrSSLKeyPath = "SSLKeyPath"; -static constexpr std::string_view StrSSLCertPath = "SSLCertPath"; static constexpr std::string_view StrHTTPServerPort = "HTTPServerPort"; TConfig::TConfig(const std::string& ConfigFileName) @@ -75,11 +72,7 @@ void TConfig::FlushToFile() { SetComment(data["General"][StrSendErrors.data()].comments(), " You can turn on/off the SendErrors message you get on startup here"); data["General"][StrSendErrorsMessageEnabled.data()] = Application::Settings.SendErrorsMessageEnabled; SetComment(data["General"][StrSendErrorsMessageEnabled.data()].comments(), " If SendErrors is `true`, the server will send helpful info about crashes and other issues back to the BeamMP developers. This info may include your config, who is on your server at the time of the error, and similar general information. This kind of data is vital in helping us diagnose and fix issues faster. This has no impact on server performance. You can opt-out of this system by setting this to `false`"); - data["HTTP"][StrSSLKeyPath.data()] = Application::Settings.SSLKeyPath; - data["HTTP"][StrSSLCertPath.data()] = Application::Settings.SSLCertPath; data["HTTP"][StrHTTPServerPort.data()] = Application::Settings.HTTPServerPort; - data["HTTP"][StrHTTPServerUseSSL.data()] = Application::Settings.HTTPServerUseSSL; - SetComment(data["HTTP"][StrHTTPServerUseSSL.data()].comments(), " Recommended to keep enabled. With SSL the server will serve https and requires valid key and cert files"); data["HTTP"][StrHTTPServerEnabled.data()] = Application::Settings.HTTPServerEnabled; SetComment(data["HTTP"][StrHTTPServerEnabled.data()].comments(), " Enables the internal HTTP server"); std::ofstream Stream(mConfigFileName); @@ -161,11 +154,8 @@ void TConfig::ParseFromFile(std::string_view name) { TryReadValue(data, "General", StrSendErrors, Application::Settings.SendErrors); TryReadValue(data, "General", StrSendErrorsMessageEnabled, Application::Settings.SendErrorsMessageEnabled); // HTTP - TryReadValue(data, "HTTP", StrSSLKeyPath, Application::Settings.SSLKeyPath); - TryReadValue(data, "HTTP", StrSSLCertPath, Application::Settings.SSLCertPath); TryReadValue(data, "HTTP", StrHTTPServerPort, Application::Settings.HTTPServerPort); TryReadValue(data, "HTTP", StrHTTPServerEnabled, Application::Settings.HTTPServerEnabled); - TryReadValue(data, "HTTP", StrHTTPServerUseSSL, Application::Settings.HTTPServerUseSSL); } catch (const std::exception& err) { beammp_error("Error parsing config file value: " + std::string(err.what())); mFailed = true; @@ -199,8 +189,6 @@ void TConfig::PrintDebug() { beammp_debug(std::string(StrName) + ": \"" + Application::Settings.ServerName + "\""); beammp_debug(std::string(StrDescription) + ": \"" + Application::Settings.ServerDesc + "\""); beammp_debug(std::string(StrResourceFolder) + ": \"" + Application::Settings.Resource + "\""); - beammp_debug(std::string(StrSSLKeyPath) + ": \"" + Application::Settings.SSLKeyPath + "\""); - beammp_debug(std::string(StrSSLCertPath) + ": \"" + Application::Settings.SSLCertPath + "\""); beammp_debug(std::string(StrHTTPServerPort) + ": \"" + std::to_string(Application::Settings.HTTPServerPort) + "\""); // special! beammp_debug("Key Length: " + std::to_string(Application::Settings.Key.length()) + ""); diff --git a/src/main.cpp b/src/main.cpp index 8b2f3c5..c43feda 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -165,7 +165,6 @@ int BeamMPServerMain(MainArguments Arguments) { Application::CheckForUpdates(); if (Application::Settings.HTTPServerEnabled) { - Http::Server::SetupEnvironment(); Http::Server::THttpServerInstance HttpServerInstance {}; }