hide login passwords from server log; call logDebugMessage in S_PH thread instead of Server thread
This commit is contained in:
parent
2a5050fdc4
commit
80439762cf
7 changed files with 20 additions and 11 deletions
|
@ -191,7 +191,6 @@ void Server::addClient(Server_ProtocolHandler *client)
|
|||
{
|
||||
QWriteLocker locker(&clientsLock);
|
||||
clients << client;
|
||||
connect(client, SIGNAL(logDebugMessage(QString, void *)), this, SIGNAL(logDebugMessage(QString, void *)));
|
||||
}
|
||||
|
||||
void Server::removeClient(Server_ProtocolHandler *client)
|
||||
|
|
|
@ -35,7 +35,6 @@ class Server : public QObject
|
|||
signals:
|
||||
void pingClockTimeout();
|
||||
void sigSendIslMessage(const IslMessage &message, int serverId);
|
||||
void logDebugMessage(QString message, void *caller);
|
||||
void endSession(qint64 sessionId);
|
||||
private slots:
|
||||
void broadcastRoomUpdate(const ServerInfo_Room &roomInfo, bool sendToIsl = false);
|
||||
|
|
|
@ -127,8 +127,14 @@ Response::ResponseCode Server_ProtocolHandler::processSessionCommandContainer(co
|
|||
Response::ResponseCode resp = Response::RespInvalidCommand;
|
||||
const SessionCommand &sc = cont.session_command(i);
|
||||
const int num = getPbExtension(sc);
|
||||
if (num != SessionCommand::PING)
|
||||
emit logDebugMessage(QString::fromStdString(sc.ShortDebugString()), this);
|
||||
if (num != SessionCommand::PING) { // don't log ping commands
|
||||
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) {
|
||||
case SessionCommand::PING: resp = cmdPing(sc.GetExtension(Command_Ping::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;
|
||||
const RoomCommand &sc = cont.room_command(i);
|
||||
const int num = getPbExtension(sc);
|
||||
emit logDebugMessage(QString::fromStdString(sc.ShortDebugString()), this);
|
||||
logDebugMessage(QString::fromStdString(sc.ShortDebugString()));
|
||||
switch ((RoomCommand::RoomCommandType) num) {
|
||||
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;
|
||||
|
@ -213,7 +219,7 @@ Response::ResponseCode Server_ProtocolHandler::processGameCommandContainer(const
|
|||
Response::ResponseCode finalResponseCode = Response::RespOk;
|
||||
for (int i = cont.game_command_size() - 1; i >= 0; --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);
|
||||
|
||||
|
@ -237,7 +243,7 @@ Response::ResponseCode Server_ProtocolHandler::processModeratorCommandContainer(
|
|||
Response::ResponseCode resp = Response::RespInvalidCommand;
|
||||
const ModeratorCommand &sc = cont.moderator_command(i);
|
||||
const int num = getPbExtension(sc);
|
||||
emit logDebugMessage(QString::fromStdString(sc.ShortDebugString()), this);
|
||||
logDebugMessage(QString::fromStdString(sc.ShortDebugString()));
|
||||
|
||||
resp = processExtendedModeratorCommand(num, sc, rc);
|
||||
if (resp != Response::RespOk)
|
||||
|
@ -258,7 +264,7 @@ Response::ResponseCode Server_ProtocolHandler::processAdminCommandContainer(cons
|
|||
Response::ResponseCode resp = Response::RespInvalidCommand;
|
||||
const AdminCommand &sc = cont.admin_command(i);
|
||||
const int num = getPbExtension(sc);
|
||||
emit logDebugMessage(QString::fromStdString(sc.ShortDebugString()), this);
|
||||
logDebugMessage(QString::fromStdString(sc.ShortDebugString()));
|
||||
|
||||
resp = processExtendedAdminCommand(num, sc, rc);
|
||||
if (resp != Response::RespOk)
|
||||
|
|
|
@ -49,6 +49,7 @@ protected:
|
|||
AuthenticationResult authState;
|
||||
bool acceptsUserListChanges;
|
||||
bool acceptsRoomListChanges;
|
||||
virtual void logDebugMessage(const QString &message) { }
|
||||
private:
|
||||
QList<int> messageSizeOverTime, messageCountOverTime;
|
||||
int timeRunning, lastDataReceived;
|
||||
|
@ -79,8 +80,6 @@ private:
|
|||
virtual Response::ResponseCode processExtendedAdminCommand(int cmdType, const AdminCommand &cmd, ResponseContainer &rc) { return Response::RespFunctionNotAllowed; }
|
||||
private slots:
|
||||
void pingClockTimeout();
|
||||
signals:
|
||||
void logDebugMessage(const QString &message, void *session);
|
||||
public slots:
|
||||
void prepareDestroy();
|
||||
public:
|
||||
|
|
|
@ -163,7 +163,6 @@ int main(int argc, char *argv[])
|
|||
testHash();
|
||||
|
||||
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);
|
||||
int retval = 0;
|
||||
if (server->initServer()) {
|
||||
|
|
|
@ -197,6 +197,11 @@ void ServerSocketInterface::transmitProtocolItem(const ServerMessage &item)
|
|||
emit outputBufferChanged();
|
||||
}
|
||||
|
||||
void ServerSocketInterface::logDebugMessage(const QString &message)
|
||||
{
|
||||
logger->logMessage(message, this);
|
||||
}
|
||||
|
||||
Response::ResponseCode ServerSocketInterface::processExtendedSessionCommand(int cmdType, const SessionCommand &cmd, ResponseContainer &rc)
|
||||
{
|
||||
switch ((SessionCommand::SessionCommandType) cmdType) {
|
||||
|
|
|
@ -57,6 +57,8 @@ private slots:
|
|||
void flushOutputBuffer();
|
||||
signals:
|
||||
void outputBufferChanged();
|
||||
protected:
|
||||
void logDebugMessage(const QString &message);
|
||||
private:
|
||||
QMutex outputBufferMutex;
|
||||
Servatrice *servatrice;
|
||||
|
|
Loading…
Reference in a new issue