mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-03 00:05:34 +00:00
Add HideUpdateMessages setting ("ImScaredOfUpdates") and periodic update reminders (every 5th heartbeat)
This commit is contained in:
parent
f8c58f363a
commit
de82caef33
@ -54,6 +54,7 @@ public:
|
||||
bool SendErrorsMessageEnabled { true };
|
||||
int HTTPServerPort { 8080 };
|
||||
bool HTTPServerUseSSL { true };
|
||||
bool HideUpdateMessages { false };
|
||||
[[nodiscard]] bool HasCustomIP() const { return !CustomIP.empty(); }
|
||||
};
|
||||
|
||||
|
@ -107,7 +107,7 @@ void Application::CheckForUpdates() {
|
||||
auto RemoteVersion = Version(VersionStrToInts(Response));
|
||||
if (IsOutdated(MyVersion, RemoteVersion)) {
|
||||
std::string RealVersionString = RemoteVersion.AsString();
|
||||
beammp_warn(std::string(ANSI_YELLOW_BOLD) + "NEW VERSION OUT! There's a new version (v" + RealVersionString + ") of the BeamMP-Server available! For more info visit https://wiki.beammp.com/en/home/server-maintenance#updating-the-server." + std::string(ANSI_RESET));
|
||||
beammp_warn(std::string(ANSI_YELLOW_BOLD) + "NEW VERSION IS OUT! Please update to the new version (v" + RealVersionString + ") of the BeamMP-Server! Download it here: https://beammp.com/! For a guide on how to update, visit: https://wiki.beammp.com/en/home/server-maintenance#updating-the-server" + std::string(ANSI_RESET));
|
||||
} else {
|
||||
beammp_info("Server up-to-date!");
|
||||
}
|
||||
|
@ -17,12 +17,15 @@ static constexpr std::string_view StrName = "Name";
|
||||
static constexpr std::string_view StrDescription = "Description";
|
||||
static constexpr std::string_view StrResourceFolder = "ResourceFolder";
|
||||
static constexpr std::string_view StrAuthKey = "AuthKey";
|
||||
|
||||
// Misc
|
||||
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";
|
||||
static constexpr std::string_view StrHideUpdateMessages = "ImScaredOfUpdates";
|
||||
|
||||
// HTTP
|
||||
static constexpr std::string_view StrHTTPServerEnabled = "HTTPServerEnabled";
|
||||
static constexpr std::string_view StrHTTPServerUseSSL = "UseSSL";
|
||||
static constexpr std::string_view StrSSLKeyPath = "SSLKeyPath";
|
||||
static constexpr std::string_view StrSSLCertPath = "SSLCertPath";
|
||||
static constexpr std::string_view StrHTTPServerPort = "HTTPServerPort";
|
||||
@ -59,7 +62,6 @@ void SetComment(CommentsT& Comments, const std::string& Comment) {
|
||||
*/
|
||||
void TConfig::FlushToFile() {
|
||||
auto data = toml::parse<toml::preserve_comments>(mConfigFileName);
|
||||
data["General"] = toml::table();
|
||||
data["General"][StrAuthKey.data()] = Application::Settings.Key;
|
||||
SetComment(data["General"][StrAuthKey.data()].comments(), " AuthKey has to be filled out in order to run the server");
|
||||
data["General"][StrDebug.data()] = Application::Settings.DebugModeEnabled;
|
||||
@ -71,10 +73,14 @@ void TConfig::FlushToFile() {
|
||||
data["General"][StrMap.data()] = Application::Settings.MapName;
|
||||
data["General"][StrDescription.data()] = Application::Settings.ServerDesc;
|
||||
data["General"][StrResourceFolder.data()] = Application::Settings.Resource;
|
||||
data["General"][StrSendErrors.data()] = Application::Settings.SendErrors;
|
||||
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`");
|
||||
// Misc
|
||||
data["Misc"][StrHideUpdateMessages.data()] = Application::Settings.HideUpdateMessages;
|
||||
SetComment(data["Misc"][StrHideUpdateMessages.data()].comments(), " Hides the periodic update message which notifies you of a new server version. You should really keep this on and always update as soon as possible. For more information visit https://wiki.beammp.com/en/home/server-maintenance#updating-the-server. An update message will always appear at startup regardless.");
|
||||
data["Misc"][StrSendErrors.data()] = Application::Settings.SendErrors;
|
||||
SetComment(data["Misc"][StrSendErrors.data()].comments(), " You can turn on/off the SendErrors message you get on startup here");
|
||||
data["Misc"][StrSendErrorsMessageEnabled.data()] = Application::Settings.SendErrorsMessageEnabled;
|
||||
SetComment(data["Misc"][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`");
|
||||
// HTTP
|
||||
data["HTTP"][StrSSLKeyPath.data()] = Application::Settings.SSLKeyPath;
|
||||
data["HTTP"][StrSSLCertPath.data()] = Application::Settings.SSLCertPath;
|
||||
data["HTTP"][StrHTTPServerPort.data()] = Application::Settings.HTTPServerPort;
|
||||
@ -82,7 +88,7 @@ void TConfig::FlushToFile() {
|
||||
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);
|
||||
std::ofstream Stream(mConfigFileName, std::ios::trunc | std::ios::out);
|
||||
Stream << data << std::flush;
|
||||
}
|
||||
|
||||
@ -158,8 +164,10 @@ void TConfig::ParseFromFile(std::string_view name) {
|
||||
TryReadValue(data, "General", StrDescription, Application::Settings.ServerDesc);
|
||||
TryReadValue(data, "General", StrResourceFolder, Application::Settings.Resource);
|
||||
TryReadValue(data, "General", StrAuthKey, Application::Settings.Key);
|
||||
TryReadValue(data, "General", StrSendErrors, Application::Settings.SendErrors);
|
||||
TryReadValue(data, "General", StrSendErrorsMessageEnabled, Application::Settings.SendErrorsMessageEnabled);
|
||||
// Misc
|
||||
TryReadValue(data, "Misc", StrSendErrors, Application::Settings.SendErrors);
|
||||
TryReadValue(data, "Misc", StrHideUpdateMessages, Application::Settings.HideUpdateMessages);
|
||||
TryReadValue(data, "Misc", StrSendErrorsMessageEnabled, Application::Settings.SendErrorsMessageEnabled);
|
||||
// HTTP
|
||||
TryReadValue(data, "HTTP", StrSSLKeyPath, Application::Settings.SSLKeyPath);
|
||||
TryReadValue(data, "HTTP", StrSSLCertPath, Application::Settings.SSLCertPath);
|
||||
|
@ -19,7 +19,9 @@ void THeartbeatThread::operator()() {
|
||||
|
||||
static std::chrono::high_resolution_clock::time_point LastNormalUpdateTime = std::chrono::high_resolution_clock::now();
|
||||
bool isAuth = false;
|
||||
size_t UpdateReminderCounter = 0;
|
||||
while (!mShutdown) {
|
||||
++UpdateReminderCounter;
|
||||
Body = GenerateCall();
|
||||
// a hot-change occurs when a setting has changed, to update the backend of that change.
|
||||
auto Now = std::chrono::high_resolution_clock::now();
|
||||
@ -128,6 +130,9 @@ void THeartbeatThread::operator()() {
|
||||
if (isAuth) {
|
||||
Application::SetSubsystemStatus("Heartbeat", Application::Status::Good);
|
||||
}
|
||||
if (!Application::Settings.HideUpdateMessages && UpdateReminderCounter % 5) {
|
||||
Application::CheckForUpdates();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user