extra server logging, server memory leak fixed, m12
This commit is contained in:
parent
380a8b2d41
commit
c8813bb2aa
6 changed files with 27 additions and 13 deletions
|
@ -57,8 +57,10 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
|
|||
return authState;
|
||||
|
||||
if (authState == PasswordRight) {
|
||||
if (users.contains(name))
|
||||
if (users.contains(name)) {
|
||||
qDebug("Login denied: would overwrite old session");
|
||||
return WouldOverwriteOldSession;
|
||||
}
|
||||
} else if (authState == UnknownUser) {
|
||||
// Change user name so that no two users have the same names,
|
||||
// don't interfere with registered user names though.
|
||||
|
|
|
@ -58,8 +58,8 @@ void Server_ProtocolHandler::prepareDestroy()
|
|||
while (i.hasNext())
|
||||
delete i.next().value();
|
||||
QMapIterator<QString, ServerInfo_User *> j(ignoreList);
|
||||
while (i.hasNext())
|
||||
delete i.next().value();
|
||||
while (j.hasNext())
|
||||
delete j.next().value();
|
||||
}
|
||||
|
||||
void Server_ProtocolHandler::playerRemovedFromGame(Server_Game *game)
|
||||
|
|
|
@ -172,6 +172,10 @@
|
|||
<name>M11</name>
|
||||
<longname>Magic 2011</longname>
|
||||
</set>
|
||||
<set import="1">
|
||||
<name>M12</name>
|
||||
<longname>Magic 2012</longname>
|
||||
</set>
|
||||
<set import="1">
|
||||
<name>COM</name>
|
||||
<longname>Magic: The Gathering-Commander</longname>
|
||||
|
|
|
@ -37,9 +37,8 @@ void Servatrice_TcpServer::incomingConnection(int socketDescriptor)
|
|||
} else {
|
||||
QTcpSocket *socket = new QTcpSocket;
|
||||
socket->setSocketDescriptor(socketDescriptor);
|
||||
logger->logMessage(QString("incoming connection: %1").arg(socket->peerAddress().toString()));
|
||||
|
||||
new ServerSocketInterface(server, socket);
|
||||
ServerSocketInterface *ssi = new ServerSocketInterface(server, socket);
|
||||
logger->logMessage(QString("incoming connection: %1").arg(socket->peerAddress().toString()), ssi);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,18 +187,27 @@ AuthenticationResult Servatrice::checkUserPassword(Server_ProtocolHandler *handl
|
|||
QSqlQuery query;
|
||||
query.prepare("select a.password, time_to_sec(timediff(now(), date_add(b.time_from, interval b.minutes minute))) < 0, b.minutes <=> 0 from " + dbPrefix + "_users a left join " + dbPrefix + "_bans b on b.id_user = a.id and b.time_from = (select max(c.time_from) from " + dbPrefix + "_bans c where c.id_user = a.id) where a.name = :name and a.active = 1");
|
||||
query.bindValue(":name", user);
|
||||
if (!execSqlQuery(query))
|
||||
if (!execSqlQuery(query)) {
|
||||
qDebug("Login denied: SQL error");
|
||||
return PasswordWrong;
|
||||
}
|
||||
|
||||
if (query.next()) {
|
||||
if (query.value(1).toInt() || query.value(2).toInt())
|
||||
if (query.value(1).toInt() || query.value(2).toInt()) {
|
||||
qDebug("Login denied: banned");
|
||||
return PasswordWrong;
|
||||
if (query.value(0).toString() == password)
|
||||
}
|
||||
if (query.value(0).toString() == password) {
|
||||
qDebug("Login accepted: password right");
|
||||
return PasswordRight;
|
||||
else
|
||||
} else {
|
||||
qDebug("Login denied: password wrong");
|
||||
return PasswordWrong;
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
qDebug("Login accepted: unknown user");
|
||||
return UnknownUser;
|
||||
}
|
||||
} else
|
||||
return UnknownUser;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ void ServerLogger::logMessage(QString message, ServerSocketInterface *ssi)
|
|||
bufferMutex.lock();
|
||||
QString ssiString;
|
||||
if (ssi)
|
||||
ssiString = QString::number((qulonglong) ssi) + " ";
|
||||
ssiString = QString::number((qulonglong) ssi, 16) + " ";
|
||||
buffer.append(QDateTime::currentDateTime().toString() + " " + QString::number((qulonglong) QThread::currentThread(), 16) + " " + ssiString + message);
|
||||
bufferMutex.unlock();
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ ServerSocketInterface::ServerSocketInterface(Servatrice *_server, QTcpSocket *_s
|
|||
|
||||
ServerSocketInterface::~ServerSocketInterface()
|
||||
{
|
||||
logger->logMessage("ServerSocketInterface destructor");
|
||||
logger->logMessage("ServerSocketInterface destructor", this);
|
||||
|
||||
prepareDestroy();
|
||||
|
||||
|
|
Loading…
Reference in a new issue