log moderation stats in the uptime table (#3215)

This commit is contained in:
Zach H 2018-05-02 17:31:54 -04:00 committed by GitHub
parent 661e00f563
commit 2520d07ef2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 136 additions and 121 deletions

View file

@ -53,10 +53,6 @@ Server::Server(QObject *parent) : QObject(parent), nextLocalGameId(0), tcpUserCo
Qt::QueuedConnection);
}
Server::~Server()
{
}
void Server::prepareDestroy()
{
roomsLock.lockForWrite();
@ -146,8 +142,8 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session,
users.insert(name, session);
qDebug() << "Server::loginUser:" << session << "name=" << name;
data.set_session_id(
databaseInterface->startSession(name, session->getAddress(), clientid, session->getConnectionType()));
data.set_session_id(static_cast<google::protobuf::uint64>(
databaseInterface->startSession(name, session->getAddress(), clientid, session->getConnectionType())));
databaseInterface->unlockSessionTables();
usersBySessionId.insert(data.session_id(), session);
@ -158,9 +154,9 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session,
Event_UserJoined event;
event.mutable_user_info()->CopyFrom(session->copyUserInfo(false));
SessionEvent *se = Server_ProtocolHandler::prepareSessionEvent(event);
for (int i = 0; i < clients.size(); ++i)
if (clients[i]->getAcceptsUserListChanges())
clients[i]->sendProtocolItem(*se);
for (auto &client : clients)
if (client->getAcceptsUserListChanges())
client->sendProtocolItem(*se);
delete se;
event.mutable_user_info()->CopyFrom(session->copyUserInfo(true, true, true));
@ -240,9 +236,9 @@ void Server::removeClient(Server_ProtocolHandler *client)
Event_UserLeft event;
event.set_name(data->name());
SessionEvent *se = Server_ProtocolHandler::prepareSessionEvent(event);
for (int i = 0; i < clients.size(); ++i)
if (clients[i]->getAcceptsUserListChanges())
clients[i]->sendProtocolItem(*se);
for (auto &client : clients)
if (client->getAcceptsUserListChanges())
client->sendProtocolItem(*se);
sendIsl_SessionEvent(*se);
delete se;
@ -260,12 +256,12 @@ void Server::removeClient(Server_ProtocolHandler *client)
<< users.size() << "users left";
}
QList<QString> Server::getOnlineModeratorList()
QList<QString> Server::getOnlineModeratorList() const
{
// clients list should be locked by calling function prior to iteration otherwise sigfaults may occur
QList<QString> results;
for (int i = 0; i < clients.size(); ++i) {
ServerInfo_User *data = clients[i]->getUserInfo();
for (auto &client : clients) {
ServerInfo_User *data = client->getUserInfo();
// TODO: this line should be updated in the event there is any type of new user level created
if (data &&
@ -288,9 +284,9 @@ void Server::externalUserJoined(const ServerInfo_User &userInfo)
event.mutable_user_info()->CopyFrom(userInfo);
SessionEvent *se = Server_ProtocolHandler::prepareSessionEvent(event);
for (int i = 0; i < clients.size(); ++i)
if (clients[i]->getAcceptsUserListChanges())
clients[i]->sendProtocolItem(*se);
for (auto &client : clients)
if (client->getAcceptsUserListChanges())
client->sendProtocolItem(*se);
delete se;
clientsLock.unlock();
@ -338,9 +334,9 @@ void Server::externalUserLeft(const QString &userName)
SessionEvent *se = Server_ProtocolHandler::prepareSessionEvent(event);
clientsLock.lockForRead();
for (int i = 0; i < clients.size(); ++i)
if (clients[i]->getAcceptsUserListChanges())
clients[i]->sendProtocolItem(*se);
for (auto &client : clients)
if (client->getAcceptsUserListChanges())
client->sendProtocolItem(*se);
clientsLock.unlock();
delete se;
}
@ -428,7 +424,7 @@ void Server::externalJoinGameCommandReceived(const Command_JoinGame &cmd,
userInterface->sendResponseContainer(responseContainer, responseCode);
} catch (Response::ResponseCode &code) {
Response response;
response.set_cmd_id(cmdId);
response.set_cmd_id(static_cast<google::protobuf::uint64>(cmdId));
response.set_response_code(code);
sendIsl_Response(response, serverId, sessionId);
@ -443,7 +439,7 @@ void Server::externalGameCommandContainerReceived(const CommandContainer &cont,
// This function is always called from the main thread via signal/slot.
try {
ResponseContainer responseContainer(cont.cmd_id());
ResponseContainer responseContainer(static_cast<int>(cont.cmd_id()));
Response::ResponseCode finalResponseCode = Response::RespOk;
QReadLocker roomsLocker(&roomsLock);
@ -531,9 +527,9 @@ void Server::broadcastRoomUpdate(const ServerInfo_Room &roomInfo, bool sendToIsl
SessionEvent *se = Server_ProtocolHandler::prepareSessionEvent(event);
clientsLock.lockForRead();
for (int i = 0; i < clients.size(); ++i)
if (clients[i]->getAcceptsRoomListChanges())
clients[i]->sendProtocolItem(*se);
for (auto &client : clients)
if (client->getAcceptsRoomListChanges())
client->sendProtocolItem(*se);
clientsLock.unlock();
if (sendToIsl)
@ -575,7 +571,7 @@ void Server::sendIsl_Response(const Response &item, int serverId, qint64 session
IslMessage msg;
msg.set_message_type(IslMessage::RESPONSE);
if (sessionId != -1)
msg.set_session_id(sessionId);
msg.set_session_id(static_cast<google::protobuf::uint64>(sessionId));
msg.mutable_response()->CopyFrom(item);
emit sigSendIslMessage(msg, serverId);
@ -586,7 +582,7 @@ void Server::sendIsl_SessionEvent(const SessionEvent &item, int serverId, qint64
IslMessage msg;
msg.set_message_type(IslMessage::SESSION_EVENT);
if (sessionId != -1)
msg.set_session_id(sessionId);
msg.set_session_id(static_cast<google::protobuf::uint64>(sessionId));
msg.mutable_session_event()->CopyFrom(item);
emit sigSendIslMessage(msg, serverId);
@ -597,7 +593,7 @@ void Server::sendIsl_GameEventContainer(const GameEventContainer &item, int serv
IslMessage msg;
msg.set_message_type(IslMessage::GAME_EVENT_CONTAINER);
if (sessionId != -1)
msg.set_session_id(sessionId);
msg.set_session_id(static_cast<google::protobuf::uint64>(sessionId));
msg.mutable_game_event_container()->CopyFrom(item);
emit sigSendIslMessage(msg, serverId);
@ -608,7 +604,7 @@ void Server::sendIsl_RoomEvent(const RoomEvent &item, int serverId, qint64 sessi
IslMessage msg;
msg.set_message_type(IslMessage::ROOM_EVENT);
if (sessionId != -1)
msg.set_session_id(sessionId);
msg.set_session_id(static_cast<google::protobuf::uint64>(sessionId));
msg.mutable_room_event()->CopyFrom(item);
emit sigSendIslMessage(msg, serverId);
@ -618,12 +614,12 @@ void Server::sendIsl_GameCommand(const CommandContainer &item, int serverId, qin
{
IslMessage msg;
msg.set_message_type(IslMessage::GAME_COMMAND_CONTAINER);
msg.set_session_id(sessionId);
msg.set_session_id(static_cast<google::protobuf::uint64>(sessionId));
msg.set_player_id(playerId);
CommandContainer *cont = msg.mutable_game_command();
cont->CopyFrom(item);
cont->set_room_id(roomId);
cont->set_room_id(static_cast<google::protobuf::uint32>(roomId));
emit sigSendIslMessage(msg, serverId);
}
@ -632,11 +628,11 @@ void Server::sendIsl_RoomCommand(const CommandContainer &item, int serverId, qin
{
IslMessage msg;
msg.set_message_type(IslMessage::ROOM_COMMAND_CONTAINER);
msg.set_session_id(sessionId);
msg.set_session_id(static_cast<google::protobuf::uint64>(sessionId));
CommandContainer *cont = msg.mutable_room_command();
cont->CopyFrom(item);
cont->set_room_id(roomId);
cont->set_room_id(static_cast<google::protobuf::uint32>(roomId));
emit sigSendIslMessage(msg, serverId);
}

View file

@ -56,8 +56,8 @@ private slots:
public:
mutable QReadWriteLock clientsLock, roomsLock; // locking order: roomsLock before clientsLock
Server(QObject *parent = 0);
~Server();
Server(QObject *parent = nullptr);
~Server() = default;
AuthenticationResult loginUser(Server_ProtocolHandler *session,
QString &name,
const QString &password,
@ -87,7 +87,7 @@ public:
}
void addClient(Server_ProtocolHandler *player);
void removeClient(Server_ProtocolHandler *player);
QList<QString> getOnlineModeratorList();
QList<QString> getOnlineModeratorList() const;
virtual QString getLoginMessage() const
{
return QString();
@ -187,8 +187,6 @@ public:
void sendIsl_GameCommand(const CommandContainer &item, int serverId, qint64 sessionId, int roomId, int playerId);
void sendIsl_RoomCommand(const CommandContainer &item, int serverId, qint64 sessionId, int roomId);
void addExternalUser(const ServerInfo_User &userInfo);
void removeExternalUser(const QString &userName);
const QMap<QString, Server_AbstractUserInterface *> &getExternalUsers() const
{
return externalUsers;

View file

@ -0,0 +1,6 @@
-- Servatrice db migration from version 24 to version 25
ALTER TABLE cockatrice_uptime ADD COLUMN mods_count int(11) NOT NULL DEFAULT 0;
ALTER TABLE cockatrice_uptime ADD COLUMN mods_list TEXT;
UPDATE cockatrice_schema_version SET version=25 WHERE version=24;

View file

@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS `cockatrice_schema_version` (
PRIMARY KEY (`version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
INSERT INTO cockatrice_schema_version VALUES(24);
INSERT INTO cockatrice_schema_version VALUES(25);
-- users and user data tables
CREATE TABLE IF NOT EXISTS `cockatrice_users` (
@ -164,6 +164,8 @@ CREATE TABLE IF NOT EXISTS `cockatrice_uptime` (
`timest` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`uptime` int(11) NOT NULL,
`users_count` int(11) NOT NULL,
`mods_count` int(11) NOT NULL DEFAULT 0,
`mods_list` TEXT,
`games_count` int(11) NOT NULL,
`rx_bytes` int(11) NOT NULL,
`tx_bytes` int(11) NOT NULL,

View file

@ -37,6 +37,7 @@
#include <QFile>
#include <QSqlQuery>
#include <QString>
#include <QStringList>
#include <QTimer>
#include <iostream>
@ -47,10 +48,10 @@ Servatrice_GameServer::Servatrice_GameServer(Servatrice *_server,
: QTcpServer(parent), server(_server)
{
for (int i = 0; i < _numberPools; ++i) {
Servatrice_DatabaseInterface *newDatabaseInterface = new Servatrice_DatabaseInterface(i, server);
Servatrice_ConnectionPool *newPool = new Servatrice_ConnectionPool(newDatabaseInterface);
auto newDatabaseInterface = new Servatrice_DatabaseInterface(i, server);
auto newPool = new Servatrice_ConnectionPool(newDatabaseInterface);
QThread *newThread = new QThread;
auto newThread = new QThread;
newThread->setObjectName("pool_" + QString::number(i));
newPool->moveToThread(newThread);
newDatabaseInterface->moveToThread(newThread);
@ -78,7 +79,7 @@ void Servatrice_GameServer::incomingConnection(qintptr socketDescriptor)
{
Servatrice_ConnectionPool *pool = findLeastUsedConnectionPool();
TcpServerSocketInterface *ssi = new TcpServerSocketInterface(server, pool->getDatabaseInterface());
auto ssi = new TcpServerSocketInterface(server, pool->getDatabaseInterface());
ssi->moveToThread(pool->thread());
pool->addClient();
connect(ssi, SIGNAL(destroyed()), pool, SLOT(removeClient()));
@ -113,9 +114,8 @@ Servatrice_WebsocketGameServer::Servatrice_WebsocketGameServer(Servatrice *_serv
: QWebSocketServer("Servatrice", QWebSocketServer::NonSecureMode, parent), server(_server)
{
// Qt limitation: websockets can't be moved to another thread
Servatrice_DatabaseInterface *newDatabaseInterface =
new Servatrice_DatabaseInterface(WEBSOCKET_POOL_NUMBER, server);
Servatrice_ConnectionPool *newPool = new Servatrice_ConnectionPool(newDatabaseInterface);
auto newDatabaseInterface = new Servatrice_DatabaseInterface(WEBSOCKET_POOL_NUMBER, server);
auto newPool = new Servatrice_ConnectionPool(newDatabaseInterface);
server->addDatabaseInterface(thread(), newDatabaseInterface);
newDatabaseInterface->initDatabase(_sqlDatabase);
@ -139,7 +139,7 @@ void Servatrice_WebsocketGameServer::onNewConnection()
{
Servatrice_ConnectionPool *pool = findLeastUsedConnectionPool();
WebsocketServerSocketInterface *ssi = new WebsocketServerSocketInterface(server, pool->getDatabaseInterface());
auto ssi = new WebsocketServerSocketInterface(server, pool->getDatabaseInterface());
// ssi->moveToThread(pool->thread());
pool->addClient();
connect(ssi, SIGNAL(destroyed()), pool, SLOT(removeClient()));
@ -167,10 +167,10 @@ Servatrice_ConnectionPool *Servatrice_WebsocketGameServer::findLeastUsedConnecti
void Servatrice_IslServer::incomingConnection(qintptr socketDescriptor)
{
QThread *thread = new QThread;
auto thread = new QThread;
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
IslInterface *interface = new IslInterface(socketDescriptor, cert, privateKey, server);
auto interface = new IslInterface(static_cast<int>(socketDescriptor), cert, privateKey, server);
interface->moveToThread(thread);
connect(interface, SIGNAL(destroyed()), thread, SLOT(quit()));
@ -179,7 +179,7 @@ void Servatrice_IslServer::incomingConnection(qintptr socketDescriptor)
}
Servatrice::Servatrice(QObject *parent)
: Server(parent), authenticationMethod(AuthenticationNone), uptime(0), shutdownTimer(0),
: Server(parent), authenticationMethod(AuthenticationNone), uptime(0), shutdownTimer(nullptr),
isFirstShutdownMessage(true)
{
qRegisterMetaType<QSqlDatabase>("QSqlDatabase");
@ -191,8 +191,8 @@ Servatrice::~Servatrice()
// clients live in other threads, we need to lock them
clientsLock.lockForRead();
for (int i = 0; i < clients.size(); ++i)
QMetaObject::invokeMethod(clients.at(i), "prepareDestroy", Qt::QueuedConnection);
for (auto client : clients)
QMetaObject::invokeMethod(client, "prepareDestroy", Qt::QueuedConnection);
clientsLock.unlock();
// client destruction is asynchronous, wait for all clients to be gone
@ -316,7 +316,7 @@ bool Servatrice::initServer()
gameTypes.append(query2->value(0).toString());
addRoom(new Server_Room(query->value(0).toInt(), query->value(7).toInt(), query->value(1).toString(),
query->value(2).toString(), query->value(3).toString().toLower(),
query->value(4).toString().toLower(), query->value(5).toInt(),
query->value(4).toString().toLower(), static_cast<bool>(query->value(5).toInt()),
query->value(6).toString(), gameTypes, this));
}
} else {
@ -362,7 +362,7 @@ bool Servatrice::initServer()
const QDateTime currentTime = QDateTime::currentDateTime();
if (currentTime < cert.effectiveDate() || currentTime > cert.expiryDate() || cert.isBlacklisted())
throw(QString("Invalid certificate."));
throw QString("Invalid certificate.");
qDebug() << "Loading private key...";
QFile keyFile(getISLNetworkSSLKeyFile());
@ -380,7 +380,7 @@ bool Servatrice::initServer()
continue;
}
QThread *thread = new QThread;
auto *thread = new QThread;
thread->setObjectName("isl_" + QString::number(prop.id));
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
@ -395,7 +395,7 @@ bool Servatrice::initServer()
qDebug() << "Starting ISL server on port" << getISLNetworkPort();
islServer = new Servatrice_IslServer(this, cert, key, this);
if (islServer->listen(QHostAddress::Any, getISLNetworkPort()))
if (islServer->listen(QHostAddress::Any, static_cast<quint16>(getISLNetworkPort())))
qDebug() << "ISL server listening.";
else
throw QString("islServer->listen()");
@ -422,7 +422,7 @@ bool Servatrice::initServer()
new Servatrice_GameServer(this, getNumberOfTCPPools(), servatriceDatabaseInterface->getDatabase(), this);
gameServer->setMaxPendingConnections(1000);
qDebug() << "Starting server on port" << getServerTCPPort();
if (gameServer->listen(QHostAddress::Any, getServerTCPPort()))
if (gameServer->listen(QHostAddress::Any, static_cast<quint16>(getServerTCPPort())))
qDebug() << "Server listening.";
else {
qDebug() << "gameServer->listen(): Error:" << gameServer->errorString();
@ -437,7 +437,7 @@ bool Servatrice::initServer()
servatriceDatabaseInterface->getDatabase(), this);
websocketGameServer->setMaxPendingConnections(1000);
qDebug() << "Starting websocket server on port" << getServerWebSocketPort();
if (websocketGameServer->listen(QHostAddress::Any, getServerWebSocketPort()))
if (websocketGameServer->listen(QHostAddress::Any, static_cast<quint16>(getServerWebSocketPort())))
qDebug() << "Websocket server listening.";
else {
qDebug() << "websocketGameServer->listen(): Error:" << websocketGameServer->errorString();
@ -504,8 +504,8 @@ int Servatrice::getUsersWithAddress(const QHostAddress &address) const
{
int result = 0;
QReadLocker locker(&clientsLock);
for (int i = 0; i < clients.size(); ++i)
if (static_cast<AbstractServerSocketInterface *>(clients[i])->getPeerAddress() == address)
for (auto client : clients)
if (static_cast<AbstractServerSocketInterface *>(client)->getPeerAddress() == address)
++result;
return result;
@ -515,9 +515,9 @@ QList<AbstractServerSocketInterface *> Servatrice::getUsersWithAddressAsList(con
{
QList<AbstractServerSocketInterface *> result;
QReadLocker locker(&clientsLock);
for (int i = 0; i < clients.size(); ++i)
if (static_cast<AbstractServerSocketInterface *>(clients[i])->getPeerAddress() == address)
result.append(static_cast<AbstractServerSocketInterface *>(clients[i]));
for (auto client : clients)
if (static_cast<AbstractServerSocketInterface *>(client)->getPeerAddress() == address)
result.append(static_cast<AbstractServerSocketInterface *>(client));
return result;
}
@ -566,6 +566,11 @@ void Servatrice::statusUpdate()
return;
const int uc = getUsersCount(); // for correct mutex locking order
const QStringList mods_info = getOnlineModeratorList();
const int mc = mods_info.size();
const QString ml = mods_info.join(", ");
const int gc = getGamesCount();
uptime += statusUpdateClock->interval() / 1000;
@ -580,11 +585,14 @@ void Servatrice::statusUpdate()
rxBytesMutex.unlock();
QSqlQuery *query = servatriceDatabaseInterface->prepareQuery(
"insert into {prefix}_uptime (id_server, timest, uptime, users_count, games_count, tx_bytes, rx_bytes) "
"values(:id, NOW(), :uptime, :users_count, :games_count, :tx, :rx)");
"insert into {prefix}_uptime (id_server, timest, uptime, users_count, mods_count, mods_list, games_count, "
"tx_bytes, rx_bytes) values(:id, NOW(), :uptime, :users_count, :mods_count, :mods_list, :games_count, :tx, "
":rx)");
query->bindValue(":id", serverId);
query->bindValue(":uptime", uptime);
query->bindValue(":users_count", uc);
query->bindValue(":mods_count", mc);
query->bindValue(":mods_list", ml);
query->bindValue(":games_count", gc);
query->bindValue(":tx", tx);
query->bindValue(":rx", rx);
@ -592,19 +600,19 @@ void Servatrice::statusUpdate()
if (getRegistrationEnabled() && getEnableInternalSMTPClient()) {
if (getRequireEmailActivationEnabled()) {
QSqlQuery *query = servatriceDatabaseInterface->prepareQuery("select a.name, b.email, b.token from "
auto servDbSelQuery = servatriceDatabaseInterface->prepareQuery("select a.name, b.email, b.token from "
"{prefix}_activation_emails a left join "
"{prefix}_users b on a.name = b.name");
if (!servatriceDatabaseInterface->execSqlQuery(query))
if (!servatriceDatabaseInterface->execSqlQuery(servDbSelQuery))
return;
QSqlQuery *queryDelete =
auto *queryDelete =
servatriceDatabaseInterface->prepareQuery("delete from {prefix}_activation_emails where name = :name");
while (query->next()) {
const QString userName = query->value(0).toString();
const QString emailAddress = query->value(1).toString();
const QString token = query->value(2).toString();
while (servDbSelQuery->next()) {
const QString userName = servDbSelQuery->value(0).toString();
const QString emailAddress = servDbSelQuery->value(1).toString();
const QString token = servDbSelQuery->value(2).toString();
if (smtpClient->enqueueActivationTokenMail(userName, emailAddress, token)) {
queryDelete->bindValue(":name", userName);
@ -614,19 +622,19 @@ void Servatrice::statusUpdate()
}
if (getEnableForgotPassword()) {
QSqlQuery *query = servatriceDatabaseInterface->prepareQuery(
auto *forgotPwQuery = servatriceDatabaseInterface->prepareQuery(
"select a.name, b.email, b.token from {prefix}_forgot_password a left join {prefix}_users b on a.name "
"= b.name where a.emailed = 0");
if (!servatriceDatabaseInterface->execSqlQuery(query))
if (!servatriceDatabaseInterface->execSqlQuery(forgotPwQuery))
return;
QSqlQuery *queryDelete = servatriceDatabaseInterface->prepareQuery(
"update {prefix}_forgot_password set emailed = 1 where name = :name");
while (query->next()) {
const QString userName = query->value(0).toString();
const QString emailAddress = query->value(1).toString();
const QString token = query->value(2).toString();
while (forgotPwQuery->next()) {
const QString userName = forgotPwQuery->value(0).toString();
const QString emailAddress = forgotPwQuery->value(1).toString();
const QString token = forgotPwQuery->value(2).toString();
if (smtpClient->enqueueForgotPasswordTokenMail(userName, emailAddress, token)) {
queryDelete->bindValue(":name", userName);
@ -677,7 +685,7 @@ void Servatrice::shutdownTimeout()
if (shutdownMinutes) {
Event_ServerShutdown event;
event.set_reason(shutdownReason.toStdString());
event.set_minutes(shutdownMinutes);
event.set_minutes(static_cast<google::protobuf::uint32>(shutdownMinutes));
se = Server_ProtocolHandler::prepareSessionEvent(event);
} else {
Event_ConnectionClosed event;
@ -686,8 +694,8 @@ void Servatrice::shutdownTimeout()
}
clientsLock.lockForRead();
for (int i = 0; i < clients.size(); ++i)
clients[i]->sendProtocolItem(*se);
for (auto &client : clients)
client->sendProtocolItem(*se);
clientsLock.unlock();
delete se;

View file

@ -32,6 +32,7 @@
#include <QSqlDatabase>
#include <QSslCertificate>
#include <QSslKey>
#include <utility>
Q_DECLARE_METATYPE(QSqlDatabase)
@ -54,11 +55,14 @@ private:
QList<Servatrice_ConnectionPool *> connectionPools;
public:
Servatrice_GameServer(Servatrice *_server, int _numberPools, const QSqlDatabase &_sqlDatabase, QObject *parent = 0);
~Servatrice_GameServer();
Servatrice_GameServer(Servatrice *_server,
int _numberPools,
const QSqlDatabase &_sqlDatabase,
QObject *parent = nullptr);
~Servatrice_GameServer() override;
protected:
void incomingConnection(qintptr socketDescriptor);
void incomingConnection(qintptr socketDescriptor) override;
Servatrice_ConnectionPool *findLeastUsedConnectionPool();
};
@ -74,8 +78,8 @@ public:
Servatrice_WebsocketGameServer(Servatrice *_server,
int _numberPools,
const QSqlDatabase &_sqlDatabase,
QObject *parent = 0);
~Servatrice_WebsocketGameServer();
QObject *parent = nullptr);
~Servatrice_WebsocketGameServer() override;
protected:
Servatrice_ConnectionPool *findLeastUsedConnectionPool();
@ -96,13 +100,13 @@ public:
Servatrice_IslServer(Servatrice *_server,
const QSslCertificate &_cert,
const QSslKey &_privateKey,
QObject *parent = 0)
QObject *parent = nullptr)
: QTcpServer(parent), server(_server), cert(_cert), privateKey(_privateKey)
{
}
protected:
void incomingConnection(qintptr socketDescriptor);
void incomingConnection(qintptr socketDescriptor) override;
};
class ServerProperties
@ -117,11 +121,12 @@ public:
ServerProperties(int _id,
const QSslCertificate &_cert,
const QString &_hostname,
QString _hostname,
const QHostAddress &_address,
int _gamePort,
int _controlPort)
: id(_id), cert(_cert), hostname(_hostname), address(_address), gamePort(_gamePort), controlPort(_controlPort)
: id(_id), cert(_cert), hostname(std::move(_hostname)), address(_address), gamePort(_gamePort),
controlPort(_controlPort)
{
}
};
@ -141,7 +146,7 @@ private slots:
void shutdownTimeout();
protected:
void doSendIslMessage(const IslMessage &msg, int serverId);
void doSendIslMessage(const IslMessage &msg, int serverId) override;
private:
enum DatabaseType
@ -201,13 +206,13 @@ private:
public slots:
void scheduleShutdown(const QString &reason, int minutes);
void updateLoginMessage();
void setRequiredFeatures(const QString featureList);
void setRequiredFeatures(QString featureList);
public:
Servatrice(QObject *parent = 0);
~Servatrice();
explicit Servatrice(QObject *parent = nullptr);
~Servatrice() override;
bool initServer();
QMap<QString, bool> getServerRequiredFeatureList() const
QMap<QString, bool> getServerRequiredFeatureList() const override
{
return serverRequiredFeatureList;
}
@ -216,12 +221,12 @@ public:
return officialWarnings;
}
QString getServerName() const;
QString getLoginMessage() const
QString getLoginMessage() const override
{
QMutexLocker locker(&loginMessageMutex);
return loginMessage;
}
QString getRequiredFeatures() const;
QString getRequiredFeatures() const override;
QString getAuthenticationMethodString() const;
QString getDBTypeString() const;
QString getDbPrefix() const
@ -233,40 +238,40 @@ public:
{
return authenticationMethod;
}
bool permitUnregisteredUsers() const
bool permitUnregisteredUsers() const override
{
return authenticationMethod != AuthenticationNone;
}
bool getGameShouldPing() const
bool getGameShouldPing() const override
{
return true;
}
bool getClientIDRequiredEnabled() const;
bool getRegOnlyServerEnabled() const;
bool getMaxUserLimitEnabled() const;
bool getStoreReplaysEnabled() const;
bool getClientIDRequiredEnabled() const override;
bool getRegOnlyServerEnabled() const override;
bool getMaxUserLimitEnabled() const override;
bool getStoreReplaysEnabled() const override;
bool getRegistrationEnabled() const;
bool getRequireEmailForRegistrationEnabled() const;
bool getRequireEmailActivationEnabled() const;
bool getEnableLogQuery() const;
bool getEnableLogQuery() const override;
bool getEnableForgotPassword() const;
bool getEnableForgotPasswordChallenge() const;
bool getEnableAudit() const;
bool getEnableRegistrationAudit() const;
bool getEnableForgotPasswordAudit() const;
int getIdleClientTimeout() const;
int getServerID() const;
int getMaxGameInactivityTime() const;
int getMaxPlayerInactivityTime() const;
int getClientKeepAlive() const;
int getIdleClientTimeout() const override;
int getServerID() const override;
int getMaxGameInactivityTime() const override;
int getMaxPlayerInactivityTime() const override;
int getClientKeepAlive() const override;
int getMaxUsersPerAddress() const;
int getMessageCountingInterval() const;
int getMaxMessageCountPerInterval() const;
int getMaxMessageSizePerInterval() const;
int getMaxGamesPerUser() const;
int getCommandCountingInterval() const;
int getMaxCommandCountPerInterval() const;
int getMaxUserTotal() const;
int getMessageCountingInterval() const override;
int getMaxMessageCountPerInterval() const override;
int getMaxMessageSizePerInterval() const override;
int getMaxGamesPerUser() const override;
int getCommandCountingInterval() const override;
int getMaxCommandCountPerInterval() const override;
int getMaxUserTotal() const override;
int getMaxTcpUserLimit() const;
int getMaxWebSocketUserLimit() const;
int getUsersWithAddress(const QHostAddress &address) const;

View file

@ -9,7 +9,7 @@
#include "server.h"
#include "server_database_interface.h"
#define DATABASE_SCHEMA_VERSION 24
#define DATABASE_SCHEMA_VERSION 25
class Servatrice;