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.
This commit is contained in:
parent
b808d3824b
commit
749bc5d6f5
4 changed files with 16 additions and 8 deletions
|
@ -62,7 +62,7 @@ public:
|
||||||
virtual bool getGameShouldPing() const { return false; }
|
virtual bool getGameShouldPing() const { return false; }
|
||||||
virtual bool getClientIdRequired() const { return false; }
|
virtual bool getClientIdRequired() const { return false; }
|
||||||
virtual bool getRegOnlyServer() 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 getPingClockInterval() const { return 0; }
|
||||||
virtual int getMaxGameInactivityTime() const { return 9999999; }
|
virtual int getMaxGameInactivityTime() const { return 9999999; }
|
||||||
virtual int getMaxPlayerInactivityTime() const { return 9999999; }
|
virtual int getMaxPlayerInactivityTime() const { return 9999999; }
|
||||||
|
|
|
@ -384,7 +384,7 @@ Response::ResponseCode Server_ProtocolHandler::cmdPing(const Command_Ping & /*cm
|
||||||
Response::ResponseCode Server_ProtocolHandler::cmdLogin(const Command_Login &cmd, ResponseContainer &rc)
|
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
|
// 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()) {
|
if (server->getUsersCount() >= server->getMaxUserLimit()) {
|
||||||
qDebug() << "Max Users Total Limit Reached, please increase the max_users_total setting.";
|
qDebug() << "Max Users Total Limit Reached, please increase the max_users_total setting.";
|
||||||
return Response::RespServerFull;
|
return Response::RespServerFull;
|
||||||
|
|
|
@ -234,11 +234,11 @@ bool Servatrice::initServer()
|
||||||
|
|
||||||
qDebug() << "Store Replays: " << settingsCache->value("game/store_replays", true).toBool();
|
qDebug() << "Store Replays: " << settingsCache->value("game/store_replays", true).toBool();
|
||||||
qDebug() << "Client ID Required: " << clientIdRequired;
|
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;
|
qDebug() << "Maximum user limit enabled: " << maxUserLimitEnabled;
|
||||||
|
|
||||||
if (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;
|
qDebug() << "Maximum total user limit: " << maxUserLimit;
|
||||||
int maxTcpUserLimit = settingsCache->value("security/max_users_tcp", 500).toInt();
|
int maxTcpUserLimit = settingsCache->value("security/max_users_tcp", 500).toInt();
|
||||||
qDebug() << "Maximum tcp user limit: " << maxTcpUserLimit;
|
qDebug() << "Maximum tcp user limit: " << maxTcpUserLimit;
|
||||||
|
@ -725,3 +725,11 @@ void Servatrice::doSendIslMessage(const IslMessage &msg, int serverId)
|
||||||
interface->transmitMessage(msg);
|
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();
|
||||||
|
}
|
|
@ -134,14 +134,14 @@ private:
|
||||||
int uptime;
|
int uptime;
|
||||||
QMutex txBytesMutex, rxBytesMutex;
|
QMutex txBytesMutex, rxBytesMutex;
|
||||||
quint64 txBytes, rxBytes;
|
quint64 txBytes, rxBytes;
|
||||||
int maxGameInactivityTime, maxPlayerInactivityTime, maxUserLimit;
|
int maxGameInactivityTime, maxPlayerInactivityTime;
|
||||||
int maxUsersPerAddress, messageCountingInterval, maxMessageCountPerInterval, maxMessageSizePerInterval, maxGamesPerUser, commandCountingInterval, maxCommandCountPerInterval, pingClockInterval;
|
int maxUsersPerAddress, messageCountingInterval, maxMessageCountPerInterval, maxMessageSizePerInterval, maxGamesPerUser, commandCountingInterval, maxCommandCountPerInterval, pingClockInterval;
|
||||||
|
|
||||||
QString shutdownReason;
|
QString shutdownReason;
|
||||||
int shutdownMinutes;
|
int shutdownMinutes;
|
||||||
int nextShutdownMessageMinutes;
|
int nextShutdownMessageMinutes;
|
||||||
QTimer *shutdownTimer;
|
QTimer *shutdownTimer;
|
||||||
bool isFirstShutdownMessage, clientIdRequired, regServerOnly, maxUserLimitEnabled;
|
bool isFirstShutdownMessage, clientIdRequired, regServerOnly;
|
||||||
|
|
||||||
mutable QMutex serverListMutex;
|
mutable QMutex serverListMutex;
|
||||||
QList<ServerProperties> serverList;
|
QList<ServerProperties> serverList;
|
||||||
|
@ -164,7 +164,7 @@ public:
|
||||||
bool getGameShouldPing() const { return true; }
|
bool getGameShouldPing() const { return true; }
|
||||||
bool getClientIdRequired() const { return clientIdRequired; }
|
bool getClientIdRequired() const { return clientIdRequired; }
|
||||||
bool getRegOnlyServer() const { return regServerOnly; }
|
bool getRegOnlyServer() const { return regServerOnly; }
|
||||||
bool getmaxUserLimitEnabled() const {return maxUserLimitEnabled; }
|
bool getMaxUserLimitEnabled() const;
|
||||||
int getPingClockInterval() const { return pingClockInterval; }
|
int getPingClockInterval() const { return pingClockInterval; }
|
||||||
int getMaxGameInactivityTime() const { return maxGameInactivityTime; }
|
int getMaxGameInactivityTime() const { return maxGameInactivityTime; }
|
||||||
int getMaxPlayerInactivityTime() const { return maxPlayerInactivityTime; }
|
int getMaxPlayerInactivityTime() const { return maxPlayerInactivityTime; }
|
||||||
|
@ -175,7 +175,7 @@ public:
|
||||||
int getMaxGamesPerUser() const { return maxGamesPerUser; }
|
int getMaxGamesPerUser() const { return maxGamesPerUser; }
|
||||||
int getCommandCountingInterval() const { return commandCountingInterval; }
|
int getCommandCountingInterval() const { return commandCountingInterval; }
|
||||||
int getMaxCommandCountPerInterval() const { return maxCommandCountPerInterval; }
|
int getMaxCommandCountPerInterval() const { return maxCommandCountPerInterval; }
|
||||||
int getMaxUserLimit() const { return maxUserLimit; }
|
int getMaxUserLimit() const;
|
||||||
AuthenticationMethod getAuthenticationMethod() const { return authenticationMethod; }
|
AuthenticationMethod getAuthenticationMethod() const { return authenticationMethod; }
|
||||||
QString getDbPrefix() const { return dbPrefix; }
|
QString getDbPrefix() const { return dbPrefix; }
|
||||||
int getServerId() const { return serverId; }
|
int getServerId() const { return serverId; }
|
||||||
|
|
Loading…
Reference in a new issue