mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-07-18 20:54:05 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f738950934 | |||
| fbce8a946e | |||
| bd9b6212e2 | |||
| b112ee20d8 | |||
| 8593aeb21d | |||
| 840f9b9f9d | |||
| 9c3042280d |
+1
-1
@@ -127,7 +127,7 @@ private:
|
|||||||
static inline std::mutex mShutdownHandlersMutex {};
|
static inline std::mutex mShutdownHandlersMutex {};
|
||||||
static inline std::deque<TShutdownHandler> mShutdownHandlers {};
|
static inline std::deque<TShutdownHandler> mShutdownHandlers {};
|
||||||
|
|
||||||
static inline Version mVersion { 3, 8, 0 };
|
static inline Version mVersion { 3, 8, 1 };
|
||||||
};
|
};
|
||||||
|
|
||||||
void SplitString(std::string const& str, const char delim, std::vector<std::string>& out);
|
void SplitString(std::string const& str, const char delim, std::vector<std::string>& out);
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ void TClient::Disconnect(std::string_view Reason) {
|
|||||||
if (ec) {
|
if (ec) {
|
||||||
beammp_debugf("Failed to shutdown client socket: {}", ec.message());
|
beammp_debugf("Failed to shutdown client socket: {}", ec.message());
|
||||||
}
|
}
|
||||||
|
mSocket.cancel();
|
||||||
mSocket.close(ec);
|
mSocket.close(ec);
|
||||||
if (ec) {
|
if (ec) {
|
||||||
beammp_debugf("Failed to close client socket: {}", ec.message());
|
beammp_debugf("Failed to close client socket: {}", ec.message());
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ std::string Http::GET(const std::string& url, unsigned int* status) {
|
|||||||
CURLcode res;
|
CURLcode res;
|
||||||
char errbuf[CURL_ERROR_SIZE];
|
char errbuf[CURL_ERROR_SIZE];
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
||||||
|
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWriteCallback);
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWriteCallback);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&Ret);
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&Ret);
|
||||||
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10); // seconds
|
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10); // seconds
|
||||||
@@ -75,6 +76,7 @@ std::string Http::POST(const std::string& url, const std::string& body, const st
|
|||||||
CURLcode res;
|
CURLcode res;
|
||||||
char errbuf[CURL_ERROR_SIZE];
|
char errbuf[CURL_ERROR_SIZE];
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
||||||
|
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWriteCallback);
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWriteCallback);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&Ret);
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&Ret);
|
||||||
curl_easy_setopt(curl, CURLOPT_POST, 1);
|
curl_easy_setopt(curl, CURLOPT_POST, 1);
|
||||||
|
|||||||
+4
-2
@@ -62,7 +62,9 @@ static constexpr std::string_view StrPassword = "Password";
|
|||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
static constexpr std::string_view StrHideUpdateMessages = "ImScaredOfUpdates";
|
static constexpr std::string_view StrHideUpdateMessages = "ImScaredOfUpdates";
|
||||||
|
static constexpr std::string_view EnvStrHideUpdateMessages = "BEAMMP_IM_SCARED_OF_UPDATES";
|
||||||
static constexpr std::string_view StrUpdateReminderTime = "UpdateReminderTime";
|
static constexpr std::string_view StrUpdateReminderTime = "UpdateReminderTime";
|
||||||
|
static constexpr std::string_view EnvStrUpdateReminderTime = "BEAMMP_UPDATE_REMINDER_TIME";
|
||||||
|
|
||||||
TEST_CASE("TConfig::TConfig") {
|
TEST_CASE("TConfig::TConfig") {
|
||||||
const std::string CfgFile = "beammp_server_testconfig.toml";
|
const std::string CfgFile = "beammp_server_testconfig.toml";
|
||||||
@@ -263,8 +265,8 @@ void TConfig::ParseFromFile(std::string_view name) {
|
|||||||
TryReadValue(data, "General", StrLogChat, EnvStrLogChat, Settings::Key::General_LogChat);
|
TryReadValue(data, "General", StrLogChat, EnvStrLogChat, Settings::Key::General_LogChat);
|
||||||
TryReadValue(data, "General", StrAllowGuests, EnvStrAllowGuests, Settings::Key::General_AllowGuests);
|
TryReadValue(data, "General", StrAllowGuests, EnvStrAllowGuests, Settings::Key::General_AllowGuests);
|
||||||
// Misc
|
// Misc
|
||||||
TryReadValue(data, "Misc", StrHideUpdateMessages, "", Settings::Key::Misc_ImScaredOfUpdates);
|
TryReadValue(data, "Misc", StrHideUpdateMessages, EnvStrHideUpdateMessages, Settings::Key::Misc_ImScaredOfUpdates);
|
||||||
TryReadValue(data, "Misc", StrUpdateReminderTime, "", Settings::Key::Misc_UpdateReminderTime);
|
TryReadValue(data, "Misc", StrUpdateReminderTime, EnvStrUpdateReminderTime, Settings::Key::Misc_UpdateReminderTime);
|
||||||
|
|
||||||
} catch (const std::exception& err) {
|
} catch (const std::exception& err) {
|
||||||
beammp_error("Error parsing config file value: " + std::string(err.what()));
|
beammp_error("Error parsing config file value: " + std::string(err.what()));
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ static sol::protected_function AddTraceback(sol::state_view StateView, sol::prot
|
|||||||
static std::optional<sol::function> GetLuaHandler(sol::state_view StateView, const std::string Handler, const std::string EventName);
|
static std::optional<sol::function> GetLuaHandler(sol::state_view StateView, const std::string Handler, const std::string EventName);
|
||||||
|
|
||||||
static std::optional<sol::function> GetLuaHandler(sol::state_view StateView, const std::string Handler, const std::string EventName) {
|
static std::optional<sol::function> GetLuaHandler(sol::state_view StateView, const std::string Handler, const std::string EventName) {
|
||||||
|
if (!StateView)
|
||||||
|
return std::nullopt;
|
||||||
auto Res = StateView.safe_script("return " + Handler, sol::script_pass_on_error);
|
auto Res = StateView.safe_script("return " + Handler, sol::script_pass_on_error);
|
||||||
if (!Res.valid()) {
|
if (!Res.valid()) {
|
||||||
beammp_errorf("invalid handler for event \"{}\". handler: \"{}\"", EventName, Handler);
|
beammp_errorf("invalid handler for event \"{}\". handler: \"{}\"", EventName, Handler);
|
||||||
|
|||||||
Reference in New Issue
Block a user