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;
|
return authState;
|
||||||
|
|
||||||
if (authState == PasswordRight) {
|
if (authState == PasswordRight) {
|
||||||
if (users.contains(name))
|
if (users.contains(name)) {
|
||||||
|
qDebug("Login denied: would overwrite old session");
|
||||||
return WouldOverwriteOldSession;
|
return WouldOverwriteOldSession;
|
||||||
|
}
|
||||||
} else if (authState == UnknownUser) {
|
} else if (authState == UnknownUser) {
|
||||||
// Change user name so that no two users have the same names,
|
// Change user name so that no two users have the same names,
|
||||||
// don't interfere with registered user names though.
|
// don't interfere with registered user names though.
|
||||||
|
|
|
@ -58,8 +58,8 @@ void Server_ProtocolHandler::prepareDestroy()
|
||||||
while (i.hasNext())
|
while (i.hasNext())
|
||||||
delete i.next().value();
|
delete i.next().value();
|
||||||
QMapIterator<QString, ServerInfo_User *> j(ignoreList);
|
QMapIterator<QString, ServerInfo_User *> j(ignoreList);
|
||||||
while (i.hasNext())
|
while (j.hasNext())
|
||||||
delete i.next().value();
|
delete j.next().value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server_ProtocolHandler::playerRemovedFromGame(Server_Game *game)
|
void Server_ProtocolHandler::playerRemovedFromGame(Server_Game *game)
|
||||||
|
|
|
@ -172,6 +172,10 @@
|
||||||
<name>M11</name>
|
<name>M11</name>
|
||||||
<longname>Magic 2011</longname>
|
<longname>Magic 2011</longname>
|
||||||
</set>
|
</set>
|
||||||
|
<set import="1">
|
||||||
|
<name>M12</name>
|
||||||
|
<longname>Magic 2012</longname>
|
||||||
|
</set>
|
||||||
<set import="1">
|
<set import="1">
|
||||||
<name>COM</name>
|
<name>COM</name>
|
||||||
<longname>Magic: The Gathering-Commander</longname>
|
<longname>Magic: The Gathering-Commander</longname>
|
||||||
|
|
|
@ -37,9 +37,8 @@ void Servatrice_TcpServer::incomingConnection(int socketDescriptor)
|
||||||
} else {
|
} else {
|
||||||
QTcpSocket *socket = new QTcpSocket;
|
QTcpSocket *socket = new QTcpSocket;
|
||||||
socket->setSocketDescriptor(socketDescriptor);
|
socket->setSocketDescriptor(socketDescriptor);
|
||||||
logger->logMessage(QString("incoming connection: %1").arg(socket->peerAddress().toString()));
|
ServerSocketInterface *ssi = new ServerSocketInterface(server, socket);
|
||||||
|
logger->logMessage(QString("incoming connection: %1").arg(socket->peerAddress().toString()), ssi);
|
||||||
new ServerSocketInterface(server, socket);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,18 +187,27 @@ AuthenticationResult Servatrice::checkUserPassword(Server_ProtocolHandler *handl
|
||||||
QSqlQuery query;
|
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.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);
|
query.bindValue(":name", user);
|
||||||
if (!execSqlQuery(query))
|
if (!execSqlQuery(query)) {
|
||||||
|
qDebug("Login denied: SQL error");
|
||||||
return PasswordWrong;
|
return PasswordWrong;
|
||||||
|
}
|
||||||
|
|
||||||
if (query.next()) {
|
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;
|
return PasswordWrong;
|
||||||
if (query.value(0).toString() == password)
|
}
|
||||||
|
if (query.value(0).toString() == password) {
|
||||||
|
qDebug("Login accepted: password right");
|
||||||
return PasswordRight;
|
return PasswordRight;
|
||||||
else
|
} else {
|
||||||
|
qDebug("Login denied: password wrong");
|
||||||
return PasswordWrong;
|
return PasswordWrong;
|
||||||
} else
|
}
|
||||||
|
} else {
|
||||||
|
qDebug("Login accepted: unknown user");
|
||||||
return UnknownUser;
|
return UnknownUser;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
return UnknownUser;
|
return UnknownUser;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ void ServerLogger::logMessage(QString message, ServerSocketInterface *ssi)
|
||||||
bufferMutex.lock();
|
bufferMutex.lock();
|
||||||
QString ssiString;
|
QString ssiString;
|
||||||
if (ssi)
|
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);
|
buffer.append(QDateTime::currentDateTime().toString() + " " + QString::number((qulonglong) QThread::currentThread(), 16) + " " + ssiString + message);
|
||||||
bufferMutex.unlock();
|
bufferMutex.unlock();
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ ServerSocketInterface::ServerSocketInterface(Servatrice *_server, QTcpSocket *_s
|
||||||
|
|
||||||
ServerSocketInterface::~ServerSocketInterface()
|
ServerSocketInterface::~ServerSocketInterface()
|
||||||
{
|
{
|
||||||
logger->logMessage("ServerSocketInterface destructor");
|
logger->logMessage("ServerSocketInterface destructor", this);
|
||||||
|
|
||||||
prepareDestroy();
|
prepareDestroy();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue