From 749bc5d6f58bac728e7f5d61a65c1890956c115c Mon Sep 17 00:00:00 2001 From: woogerboy21 Date: Mon, 24 Oct 2016 00:30:58 -0400 Subject: [PATCH] Fix dynamic user limit settings PR #2220 removed the ability to be able to change the max user limit count while the server is running requiring a restart to make the settings change. This PR reverts the behavior back to how it operated prior to the PR. --- common/server.h | 2 +- common/server_protocolhandler.cpp | 2 +- servatrice/src/servatrice.cpp | 12 ++++++++++-- servatrice/src/servatrice.h | 8 ++++---- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/common/server.h b/common/server.h index 6fd89c1c..3b4c0396 100644 --- a/common/server.h +++ b/common/server.h @@ -62,7 +62,7 @@ public: virtual bool getGameShouldPing() const { return false; } virtual bool getClientIdRequired() const { return false; } virtual bool getRegOnlyServer() const { return false; } - virtual bool getmaxUserLimitEnabled() const { return false; } + virtual bool getMaxUserLimitEnabled() const { return false; } virtual int getPingClockInterval() const { return 0; } virtual int getMaxGameInactivityTime() const { return 9999999; } virtual int getMaxPlayerInactivityTime() const { return 9999999; } diff --git a/common/server_protocolhandler.cpp b/common/server_protocolhandler.cpp index d18791d0..29bf34fd 100644 --- a/common/server_protocolhandler.cpp +++ b/common/server_protocolhandler.cpp @@ -384,7 +384,7 @@ Response::ResponseCode Server_ProtocolHandler::cmdPing(const Command_Ping & /*cm Response::ResponseCode Server_ProtocolHandler::cmdLogin(const Command_Login &cmd, ResponseContainer &rc) { // limit the number of users that can connect to the server based on configuration settings - if (server->getmaxUserLimitEnabled()) { + if (server->getMaxUserLimitEnabled()) { if (server->getUsersCount() >= server->getMaxUserLimit()) { qDebug() << "Max Users Total Limit Reached, please increase the max_users_total setting."; return Response::RespServerFull; diff --git a/servatrice/src/servatrice.cpp b/servatrice/src/servatrice.cpp index 3a58b3ef..56a2de46 100644 --- a/servatrice/src/servatrice.cpp +++ b/servatrice/src/servatrice.cpp @@ -234,11 +234,11 @@ bool Servatrice::initServer() qDebug() << "Store Replays: " << settingsCache->value("game/store_replays", true).toBool(); qDebug() << "Client ID Required: " << clientIdRequired; - maxUserLimitEnabled = settingsCache->value("security/enable_max_user_limit", false).toBool(); + bool maxUserLimitEnabled = settingsCache->value("security/enable_max_user_limit", false).toBool(); qDebug() << "Maximum user limit enabled: " << maxUserLimitEnabled; if (maxUserLimitEnabled){ - maxUserLimit = settingsCache->value("security/max_users_total", 500).toInt(); + int maxUserLimit = settingsCache->value("security/max_users_total", 500).toInt(); qDebug() << "Maximum total user limit: " << maxUserLimit; int maxTcpUserLimit = settingsCache->value("security/max_users_tcp", 500).toInt(); qDebug() << "Maximum tcp user limit: " << maxTcpUserLimit; @@ -725,3 +725,11 @@ void Servatrice::doSendIslMessage(const IslMessage &msg, int serverId) interface->transmitMessage(msg); } } + +int Servatrice::getMaxUserLimit() const { + return settingsCache->value("security/max_users_total", 500).toInt(); +} + +bool Servatrice::getMaxUserLimitEnabled() const { + return settingsCache->value("security/enable_max_user_limit", false).toBool(); +} \ No newline at end of file diff --git a/servatrice/src/servatrice.h b/servatrice/src/servatrice.h index 3cafae83..4e13ad09 100644 --- a/servatrice/src/servatrice.h +++ b/servatrice/src/servatrice.h @@ -134,14 +134,14 @@ private: int uptime; QMutex txBytesMutex, rxBytesMutex; quint64 txBytes, rxBytes; - int maxGameInactivityTime, maxPlayerInactivityTime, maxUserLimit; + int maxGameInactivityTime, maxPlayerInactivityTime; int maxUsersPerAddress, messageCountingInterval, maxMessageCountPerInterval, maxMessageSizePerInterval, maxGamesPerUser, commandCountingInterval, maxCommandCountPerInterval, pingClockInterval; QString shutdownReason; int shutdownMinutes; int nextShutdownMessageMinutes; QTimer *shutdownTimer; - bool isFirstShutdownMessage, clientIdRequired, regServerOnly, maxUserLimitEnabled; + bool isFirstShutdownMessage, clientIdRequired, regServerOnly; mutable QMutex serverListMutex; QList serverList; @@ -164,7 +164,7 @@ public: bool getGameShouldPing() const { return true; } bool getClientIdRequired() const { return clientIdRequired; } bool getRegOnlyServer() const { return regServerOnly; } - bool getmaxUserLimitEnabled() const {return maxUserLimitEnabled; } + bool getMaxUserLimitEnabled() const; int getPingClockInterval() const { return pingClockInterval; } int getMaxGameInactivityTime() const { return maxGameInactivityTime; } int getMaxPlayerInactivityTime() const { return maxPlayerInactivityTime; } @@ -175,7 +175,7 @@ public: int getMaxGamesPerUser() const { return maxGamesPerUser; } int getCommandCountingInterval() const { return commandCountingInterval; } int getMaxCommandCountPerInterval() const { return maxCommandCountPerInterval; } - int getMaxUserLimit() const { return maxUserLimit; } + int getMaxUserLimit() const; AuthenticationMethod getAuthenticationMethod() const { return authenticationMethod; } QString getDbPrefix() const { return dbPrefix; } int getServerId() const { return serverId; }