hide login passwords from server log; call logDebugMessage in S_PH thread instead of Server thread

This commit is contained in:
Max-Wilhelm Bruker 2012-06-03 19:23:15 +02:00
parent 2a5050fdc4
commit 80439762cf
7 changed files with 20 additions and 11 deletions

View file

@ -191,7 +191,6 @@ void Server::addClient(Server_ProtocolHandler *client)
{ {
QWriteLocker locker(&clientsLock); QWriteLocker locker(&clientsLock);
clients << client; clients << client;
connect(client, SIGNAL(logDebugMessage(QString, void *)), this, SIGNAL(logDebugMessage(QString, void *)));
} }
void Server::removeClient(Server_ProtocolHandler *client) void Server::removeClient(Server_ProtocolHandler *client)

View file

@ -35,7 +35,6 @@ class Server : public QObject
signals: signals:
void pingClockTimeout(); void pingClockTimeout();
void sigSendIslMessage(const IslMessage &message, int serverId); void sigSendIslMessage(const IslMessage &message, int serverId);
void logDebugMessage(QString message, void *caller);
void endSession(qint64 sessionId); void endSession(qint64 sessionId);
private slots: private slots:
void broadcastRoomUpdate(const ServerInfo_Room &roomInfo, bool sendToIsl = false); void broadcastRoomUpdate(const ServerInfo_Room &roomInfo, bool sendToIsl = false);

View file

@ -127,8 +127,14 @@ Response::ResponseCode Server_ProtocolHandler::processSessionCommandContainer(co
Response::ResponseCode resp = Response::RespInvalidCommand; Response::ResponseCode resp = Response::RespInvalidCommand;
const SessionCommand &sc = cont.session_command(i); const SessionCommand &sc = cont.session_command(i);
const int num = getPbExtension(sc); const int num = getPbExtension(sc);
if (num != SessionCommand::PING) if (num != SessionCommand::PING) { // don't log ping commands
emit logDebugMessage(QString::fromStdString(sc.ShortDebugString()), this); if (num == SessionCommand::LOGIN) { // log login commands, but hide passwords
SessionCommand debugSc(sc);
debugSc.MutableExtension(Command_Login::ext)->clear_password();
logDebugMessage(QString::fromStdString(debugSc.ShortDebugString()));
} else
logDebugMessage(QString::fromStdString(sc.ShortDebugString()));
}
switch ((SessionCommand::SessionCommandType) num) { switch ((SessionCommand::SessionCommandType) num) {
case SessionCommand::PING: resp = cmdPing(sc.GetExtension(Command_Ping::ext), rc); break; case SessionCommand::PING: resp = cmdPing(sc.GetExtension(Command_Ping::ext), rc); break;
case SessionCommand::LOGIN: resp = cmdLogin(sc.GetExtension(Command_Login::ext), rc); break; case SessionCommand::LOGIN: resp = cmdLogin(sc.GetExtension(Command_Login::ext), rc); break;
@ -161,7 +167,7 @@ Response::ResponseCode Server_ProtocolHandler::processRoomCommandContainer(const
Response::ResponseCode resp = Response::RespInvalidCommand; Response::ResponseCode resp = Response::RespInvalidCommand;
const RoomCommand &sc = cont.room_command(i); const RoomCommand &sc = cont.room_command(i);
const int num = getPbExtension(sc); const int num = getPbExtension(sc);
emit logDebugMessage(QString::fromStdString(sc.ShortDebugString()), this); logDebugMessage(QString::fromStdString(sc.ShortDebugString()));
switch ((RoomCommand::RoomCommandType) num) { switch ((RoomCommand::RoomCommandType) num) {
case RoomCommand::LEAVE_ROOM: resp = cmdLeaveRoom(sc.GetExtension(Command_LeaveRoom::ext), room, rc); break; case RoomCommand::LEAVE_ROOM: resp = cmdLeaveRoom(sc.GetExtension(Command_LeaveRoom::ext), room, rc); break;
case RoomCommand::ROOM_SAY: resp = cmdRoomSay(sc.GetExtension(Command_RoomSay::ext), room, rc); break; case RoomCommand::ROOM_SAY: resp = cmdRoomSay(sc.GetExtension(Command_RoomSay::ext), room, rc); break;
@ -213,7 +219,7 @@ Response::ResponseCode Server_ProtocolHandler::processGameCommandContainer(const
Response::ResponseCode finalResponseCode = Response::RespOk; Response::ResponseCode finalResponseCode = Response::RespOk;
for (int i = cont.game_command_size() - 1; i >= 0; --i) { for (int i = cont.game_command_size() - 1; i >= 0; --i) {
const GameCommand &sc = cont.game_command(i); const GameCommand &sc = cont.game_command(i);
emit logDebugMessage(QString::fromStdString(sc.ShortDebugString()), this); logDebugMessage(QString("game %1 player %2: ").arg(cont.game_id()).arg(roomIdAndPlayerId.second) + QString::fromStdString(sc.ShortDebugString()));
Response::ResponseCode resp = player->processGameCommand(sc, rc, ges); Response::ResponseCode resp = player->processGameCommand(sc, rc, ges);
@ -237,7 +243,7 @@ Response::ResponseCode Server_ProtocolHandler::processModeratorCommandContainer(
Response::ResponseCode resp = Response::RespInvalidCommand; Response::ResponseCode resp = Response::RespInvalidCommand;
const ModeratorCommand &sc = cont.moderator_command(i); const ModeratorCommand &sc = cont.moderator_command(i);
const int num = getPbExtension(sc); const int num = getPbExtension(sc);
emit logDebugMessage(QString::fromStdString(sc.ShortDebugString()), this); logDebugMessage(QString::fromStdString(sc.ShortDebugString()));
resp = processExtendedModeratorCommand(num, sc, rc); resp = processExtendedModeratorCommand(num, sc, rc);
if (resp != Response::RespOk) if (resp != Response::RespOk)
@ -258,7 +264,7 @@ Response::ResponseCode Server_ProtocolHandler::processAdminCommandContainer(cons
Response::ResponseCode resp = Response::RespInvalidCommand; Response::ResponseCode resp = Response::RespInvalidCommand;
const AdminCommand &sc = cont.admin_command(i); const AdminCommand &sc = cont.admin_command(i);
const int num = getPbExtension(sc); const int num = getPbExtension(sc);
emit logDebugMessage(QString::fromStdString(sc.ShortDebugString()), this); logDebugMessage(QString::fromStdString(sc.ShortDebugString()));
resp = processExtendedAdminCommand(num, sc, rc); resp = processExtendedAdminCommand(num, sc, rc);
if (resp != Response::RespOk) if (resp != Response::RespOk)

View file

@ -49,6 +49,7 @@ protected:
AuthenticationResult authState; AuthenticationResult authState;
bool acceptsUserListChanges; bool acceptsUserListChanges;
bool acceptsRoomListChanges; bool acceptsRoomListChanges;
virtual void logDebugMessage(const QString &message) { }
private: private:
QList<int> messageSizeOverTime, messageCountOverTime; QList<int> messageSizeOverTime, messageCountOverTime;
int timeRunning, lastDataReceived; int timeRunning, lastDataReceived;
@ -79,8 +80,6 @@ private:
virtual Response::ResponseCode processExtendedAdminCommand(int cmdType, const AdminCommand &cmd, ResponseContainer &rc) { return Response::RespFunctionNotAllowed; } virtual Response::ResponseCode processExtendedAdminCommand(int cmdType, const AdminCommand &cmd, ResponseContainer &rc) { return Response::RespFunctionNotAllowed; }
private slots: private slots:
void pingClockTimeout(); void pingClockTimeout();
signals:
void logDebugMessage(const QString &message, void *session);
public slots: public slots:
void prepareDestroy(); void prepareDestroy();
public: public:

View file

@ -163,7 +163,6 @@ int main(int argc, char *argv[])
testHash(); testHash();
Servatrice *server = new Servatrice(settings); Servatrice *server = new Servatrice(settings);
QObject::connect(server, SIGNAL(logDebugMessage(QString, void *)), logger, SLOT(logMessage(QString, void *)));
QObject::connect(server, SIGNAL(destroyed()), &app, SLOT(quit()), Qt::QueuedConnection); QObject::connect(server, SIGNAL(destroyed()), &app, SLOT(quit()), Qt::QueuedConnection);
int retval = 0; int retval = 0;
if (server->initServer()) { if (server->initServer()) {

View file

@ -197,6 +197,11 @@ void ServerSocketInterface::transmitProtocolItem(const ServerMessage &item)
emit outputBufferChanged(); emit outputBufferChanged();
} }
void ServerSocketInterface::logDebugMessage(const QString &message)
{
logger->logMessage(message, this);
}
Response::ResponseCode ServerSocketInterface::processExtendedSessionCommand(int cmdType, const SessionCommand &cmd, ResponseContainer &rc) Response::ResponseCode ServerSocketInterface::processExtendedSessionCommand(int cmdType, const SessionCommand &cmd, ResponseContainer &rc)
{ {
switch ((SessionCommand::SessionCommandType) cmdType) { switch ((SessionCommand::SessionCommandType) cmdType) {

View file

@ -57,6 +57,8 @@ private slots:
void flushOutputBuffer(); void flushOutputBuffer();
signals: signals:
void outputBufferChanged(); void outputBufferChanged();
protected:
void logDebugMessage(const QString &message);
private: private:
QMutex outputBufferMutex; QMutex outputBufferMutex;
Servatrice *servatrice; Servatrice *servatrice;