Merge pull request #829 from ctrlaltca/antiflood

Anti flood for game commands; fix #753
This commit is contained in:
ctrlaltca 2015-03-22 22:08:25 +01:00
commit 88b242b34d
8 changed files with 69 additions and 8 deletions

View file

@ -130,7 +130,7 @@ max_users_per_address=4
; IP addresses listed (ignoring the max_users_per_address). Default is "127.0.0.1,::1"; example: "192.73.233.244,81.4.100.74"
trusted_sources="127.0.0.1,::1"
; Servatrice can avoid users from flooding rooms with large number messages in an interval of time.
; Servatrice can avoid users from flooding rooms with large number of messages in an interval of time.
; This setting defines the length in seconds of the considered interval; default is 10
message_counting_interval=10
@ -143,6 +143,12 @@ max_message_count_per_interval=10
; Maximum number of games a single user can create; default is 5
max_games_per_user=5
; Servatrice can avoid users from flooding games with large number of game commands in an interval of time.
; This setting defines the length in seconds of the considered interval; default is 10
command_counting_interval=10
; Maximum number of game commands in an interval before new commands gets dropped; default is 10
max_command_count_per_interval=10
[logging]

View file

@ -259,6 +259,8 @@ bool Servatrice::initServer()
maxMessageCountPerInterval = settingsCache->value("security/max_message_count_per_interval", 10).toInt();
maxMessageSizePerInterval = settingsCache->value("security/max_message_size_per_interval", 1000).toInt();
maxGamesPerUser = settingsCache->value("security/max_games_per_user", 5).toInt();
commandCountingInterval = settingsCache->value("game/command_counting_interval", 10).toInt();
maxCommandCountPerInterval = settingsCache->value("game/max_command_count_per_interval", 10).toInt();
try { if (settingsCache->value("servernetwork/active", 0).toInt()) {
qDebug() << "Connecting to ISL network.";

View file

@ -115,8 +115,8 @@ private:
QMutex txBytesMutex, rxBytesMutex;
quint64 txBytes, rxBytes;
int maxGameInactivityTime, maxPlayerInactivityTime;
int maxUsersPerAddress, messageCountingInterval, maxMessageCountPerInterval, maxMessageSizePerInterval, maxGamesPerUser;
int maxUsersPerAddress, messageCountingInterval, maxMessageCountPerInterval, maxMessageSizePerInterval, maxGamesPerUser, commandCountingInterval, maxCommandCountPerInterval;
QString shutdownReason;
int shutdownMinutes;
QTimer *shutdownTimer;
@ -143,6 +143,8 @@ public:
int getMaxMessageCountPerInterval() const { return maxMessageCountPerInterval; }
int getMaxMessageSizePerInterval() const { return maxMessageSizePerInterval; }
int getMaxGamesPerUser() const { return maxGamesPerUser; }
int getCommandCountingInterval() const { return commandCountingInterval; }
int getMaxCommandCountPerInterval() const { return maxCommandCountPerInterval; }
AuthenticationMethod getAuthenticationMethod() const { return authenticationMethod; }
QString getDbPrefix() const { return dbPrefix; }
int getServerId() const { return serverId; }