Add enable/disable log query functionality (#2294)

* Add enable/disable log query functionality

This change adds the ability for server owners to allow log querying
from inside the client.  In the event the functionality is not allowed a
result is returned indicating the functionality is disabled.

* Added translation

Added the ability for the disabled messages to be translated.
This commit is contained in:
woogerboy21 2016-12-06 15:37:36 -05:00 committed by Zach H
parent c90c4ea41f
commit a6f1f4c01d
5 changed files with 56 additions and 3 deletions

View file

@ -64,6 +64,7 @@ public:
virtual bool getClientIDRequiredEnabled() const { return false; }
virtual bool getRegOnlyServerEnabled() const { return false; }
virtual bool getMaxUserLimitEnabled() const { return false; }
virtual bool getEnableLogQuery() const { return false; }
virtual int getIdleClientTimeout() const { return 0; }
virtual int getClientKeepAlive() const { return 0; }
virtual int getMaxGameInactivityTime() const { return 9999999; }

View file

@ -288,6 +288,10 @@ command_counting_interval=10
max_command_count_per_interval=20
[logging]
; Admin/Moderators can query the stored logs for information when looking up reports by various players. This
; option can allow or disallow them from doing so.
; !!NOTE!! Enabling this feature puts a very high CPU and DISK load on the server, enable with caution.
enablelogquery=false
; Servatrice can log user messages to the database table cockatrice_log.
; These messages can come from different sources; each source can be enabled separately.

View file

@ -825,4 +825,8 @@ int Servatrice::getISLNetworkPort() const {
int Servatrice::getIdleClientTimeout() const {
return settingsCache->value("server/idleclienttimeout", 3600).toInt();
}
bool Servatrice::getEnableLogQuery() const {
return settingsCache->value("logging/enablelogquery", false).toBool();
}

View file

@ -189,6 +189,7 @@ public:
bool getRegistrationEnabled() const;
bool getRequireEmailForRegistrationEnabled() const;
bool getRequireEmailActivationEnabled() const;
bool getEnableLogQuery() const;
int getIdleClientTimeout() const;
int getServerID() const;
int getMaxGameInactivityTime() const;

View file

@ -653,9 +653,52 @@ Response::ResponseCode AbstractServerSocketInterface::cmdGetLogHistory(const Com
int maximumResults = cmd.maximum_results();
Response_ViewLogHistory *re = new Response_ViewLogHistory;
QListIterator<ServerInfo_ChatMessage> messageIterator(sqlInterface->getMessageLogHistory(userName,ipAddress,gameName,gameID,message,chatType,gameType,roomType,dateRange,maximumResults));
while (messageIterator.hasNext())
re->add_log_message()->CopyFrom(messageIterator.next());
if (servatrice->getEnableLogQuery()) {
QListIterator<ServerInfo_ChatMessage> messageIterator(sqlInterface->getMessageLogHistory(userName, ipAddress, gameName, gameID, message, chatType, gameType, roomType, dateRange, maximumResults));
while (messageIterator.hasNext())
re->add_log_message()->CopyFrom(messageIterator.next());
} else {
ServerInfo_ChatMessage chatMessage;
//create dummy chat message for room tab in the event the query is for room messages (and possibly not others)
chatMessage.set_time(QString(tr("Log query disabled, please contact server owner for details.")).toStdString());
chatMessage.set_sender_id(QString("").toStdString());
chatMessage.set_sender_name(QString("").toStdString());
chatMessage.set_sender_ip(QString("").toStdString());
chatMessage.set_message(QString("").toStdString());
chatMessage.set_target_type(QString("room").toStdString());
chatMessage.set_target_id(QString("").toStdString());
chatMessage.set_target_name(QString("").toStdString());
messageList << chatMessage;
//create dummy chat message for room tab in the event the query is for game messages (and possibly not others)
chatMessage.set_time(QString(tr("Log query disabled, please contact server owner for details.")).toStdString());
chatMessage.set_sender_id(QString("").toStdString());
chatMessage.set_sender_name(QString("").toStdString());
chatMessage.set_sender_ip(QString("").toStdString());
chatMessage.set_message(QString("").toStdString());
chatMessage.set_target_type(QString("game").toStdString());
chatMessage.set_target_id(QString("").toStdString());
chatMessage.set_target_name(QString("").toStdString());
messageList << chatMessage;
//create dummy chat message for room tab in the event the query is for chat messages (and possibly not others)
chatMessage.set_time(QString(tr("Log query disabled, please contact server owner for details.")).toStdString());
chatMessage.set_sender_id(QString("").toStdString());
chatMessage.set_sender_name(QString("").toStdString());
chatMessage.set_sender_ip(QString("").toStdString());
chatMessage.set_message(QString("").toStdString());
chatMessage.set_target_type(QString("chat").toStdString());
chatMessage.set_target_id(QString("").toStdString());
chatMessage.set_target_name(QString("").toStdString());
messageList << chatMessage;
QListIterator<ServerInfo_ChatMessage> messageIterator(messageList);
while (messageIterator.hasNext())
re->add_log_message()->CopyFrom(messageIterator.next());
}
rc.setResponseExtension(re);
return Response::RespOk;
}