use correct settings group for command interval settings (#4257)
the settings command_counting_interval and max_command_count_per_interval are now in the [security] group as hinted by their location in servatrice.ini.example check values of comand interval settings before use
This commit is contained in:
parent
aa6a0313e9
commit
7e3a669af0
2 changed files with 13 additions and 7 deletions
|
@ -286,12 +286,14 @@ Response::ResponseCode Server_ProtocolHandler::processGameCommandContainer(const
|
||||||
if (!antifloodCommandsWhiteList.contains((GameCommand::GameCommandType)getPbExtension(sc)))
|
if (!antifloodCommandsWhiteList.contains((GameCommand::GameCommandType)getPbExtension(sc)))
|
||||||
++commandCountOverTime[0];
|
++commandCountOverTime[0];
|
||||||
|
|
||||||
for (int i = 0; i < commandCountOverTime.size(); ++i)
|
for (int i = 0; i < commandCountOverTime.size(); ++i) {
|
||||||
totalCount += commandCountOverTime[i];
|
totalCount += commandCountOverTime[i];
|
||||||
|
}
|
||||||
|
|
||||||
if (totalCount > maxCommandCountPerInterval)
|
if (maxCommandCountPerInterval > 0 && totalCount > maxCommandCountPerInterval) {
|
||||||
return Response::RespChatFlood;
|
return Response::RespChatFlood;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Response::ResponseCode resp = player->processGameCommand(sc, rc, ges);
|
Response::ResponseCode resp = player->processGameCommand(sc, rc, ges);
|
||||||
|
|
||||||
|
@ -733,13 +735,17 @@ Server_ProtocolHandler::cmdRoomSay(const Command_RoomSay &cmd, Server_Room *room
|
||||||
if (messageCountOverTime.isEmpty())
|
if (messageCountOverTime.isEmpty())
|
||||||
messageCountOverTime.prepend(0);
|
messageCountOverTime.prepend(0);
|
||||||
++messageCountOverTime[0];
|
++messageCountOverTime[0];
|
||||||
for (int i = 0; i < messageCountOverTime.size(); ++i)
|
for (int i = 0; i < messageCountOverTime.size(); ++i) {
|
||||||
totalCount += messageCountOverTime[i];
|
totalCount += messageCountOverTime[i];
|
||||||
|
}
|
||||||
|
|
||||||
if ((totalSize > server->getMaxMessageSizePerInterval()) ||
|
int maxMessageSizePerInterval = server->getMaxMessageSizePerInterval();
|
||||||
(totalCount > server->getMaxMessageCountPerInterval()))
|
int maxMessageCountPerInterval = server->getMaxMessageCountPerInterval();
|
||||||
|
if ((maxMessageSizePerInterval > 0 && totalSize > maxMessageSizePerInterval) ||
|
||||||
|
(maxMessageCountPerInterval > 0 && totalCount > maxMessageCountPerInterval)) {
|
||||||
return Response::RespChatFlood;
|
return Response::RespChatFlood;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
msg.replace(QChar('\n'), QChar(' '));
|
msg.replace(QChar('\n'), QChar(' '));
|
||||||
|
|
||||||
room->say(QString::fromStdString(userInfo->name()), msg);
|
room->say(QString::fromStdString(userInfo->name()), msg);
|
||||||
|
|
|
@ -955,12 +955,12 @@ int Servatrice::getMaxGamesPerUser() const
|
||||||
|
|
||||||
int Servatrice::getCommandCountingInterval() const
|
int Servatrice::getCommandCountingInterval() const
|
||||||
{
|
{
|
||||||
return settingsCache->value("game/command_counting_interval", 10).toInt();
|
return settingsCache->value("security/command_counting_interval", 10).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Servatrice::getMaxCommandCountPerInterval() const
|
int Servatrice::getMaxCommandCountPerInterval() const
|
||||||
{
|
{
|
||||||
return settingsCache->value("game/max_command_count_per_interval", 20).toInt();
|
return settingsCache->value("security/max_command_count_per_interval", 20).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Servatrice::getServerStatusUpdateTime() const
|
int Servatrice::getServerStatusUpdateTime() const
|
||||||
|
|
Loading…
Reference in a new issue