mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
fix compiling on arch (#6768)
Some checks failed
Build Desktop / Configure (push) Has been cancelled
Build Docker Image / amd64 & arm64 (push) Has been cancelled
Build Desktop / Debian 11 (push) Has been cancelled
Build Desktop / Debian 13 (push) Has been cancelled
Build Desktop / Debian 12 (push) Has been cancelled
Build Desktop / Fedora 43 (push) Has been cancelled
Build Desktop / Fedora 42 (push) Has been cancelled
Build Desktop / Servatrice_Debian 11 (push) Has been cancelled
Build Desktop / Ubuntu 24.04 (push) Has been cancelled
Build Desktop / Ubuntu 26.04 (push) Has been cancelled
Build Desktop / Ubuntu 22.04 (push) Has been cancelled
Build Desktop / Arch (push) Has been cancelled
Build Desktop / macOS 14 (push) Has been cancelled
Build Desktop / macOS 15 (push) Has been cancelled
Build Desktop / macOS 13 Intel (push) Has been cancelled
Build Desktop / macOS 15 Debug (push) Has been cancelled
Build Desktop / Windows 10 (push) Has been cancelled
Some checks failed
Build Desktop / Configure (push) Has been cancelled
Build Docker Image / amd64 & arm64 (push) Has been cancelled
Build Desktop / Debian 11 (push) Has been cancelled
Build Desktop / Debian 13 (push) Has been cancelled
Build Desktop / Debian 12 (push) Has been cancelled
Build Desktop / Fedora 43 (push) Has been cancelled
Build Desktop / Fedora 42 (push) Has been cancelled
Build Desktop / Servatrice_Debian 11 (push) Has been cancelled
Build Desktop / Ubuntu 24.04 (push) Has been cancelled
Build Desktop / Ubuntu 26.04 (push) Has been cancelled
Build Desktop / Ubuntu 22.04 (push) Has been cancelled
Build Desktop / Arch (push) Has been cancelled
Build Desktop / macOS 14 (push) Has been cancelled
Build Desktop / macOS 15 (push) Has been cancelled
Build Desktop / macOS 13 Intel (push) Has been cancelled
Build Desktop / macOS 15 Debug (push) Has been cancelled
Build Desktop / Windows 10 (push) Has been cancelled
* fix compiling on arch * redo all the logging in affected files
This commit is contained in:
parent
a46ab5cd68
commit
3ec9ae9772
7 changed files with 219 additions and 148 deletions
|
|
@ -31,6 +31,7 @@
|
|||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QHostAddress>
|
||||
#include <QLoggingCategory>
|
||||
#include <QRegularExpression>
|
||||
#include <QSqlError>
|
||||
#include <QSqlQuery>
|
||||
|
|
@ -83,6 +84,10 @@
|
|||
#include <server_room.h>
|
||||
#include <string>
|
||||
|
||||
inline Q_LOGGING_CATEGORY(AbstractServerSocketInterfaceLog, "abstract_server_socket_interface");
|
||||
inline Q_LOGGING_CATEGORY(TcpServerSocketInterfaceLog, "tcp_server_socket_interface");
|
||||
inline Q_LOGGING_CATEGORY(WebsocketServerSocketInterfaceLog, "websocket_server_socket_interface");
|
||||
|
||||
static const int protocolVersion = 14;
|
||||
|
||||
AbstractServerSocketInterface::AbstractServerSocketInterface(Servatrice *_server,
|
||||
|
|
@ -130,7 +135,7 @@ bool AbstractServerSocketInterface::initSession()
|
|||
|
||||
void AbstractServerSocketInterface::catchSocketError(QAbstractSocket::SocketError socketError)
|
||||
{
|
||||
qDebug() << "Socket error:" << socketError;
|
||||
qCWarning(AbstractServerSocketInterfaceLog) << "Socket error:" << socketError;
|
||||
|
||||
prepareDestroy();
|
||||
}
|
||||
|
|
@ -1100,7 +1105,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdBanFromServer(const Com
|
|||
clientIdQuery->bindValue(":client_id", nameFromStdString(cmd.clientid()));
|
||||
sqlInterface->execSqlQuery(clientIdQuery);
|
||||
if (!sqlInterface->execSqlQuery(clientIdQuery)) {
|
||||
qDebug("ClientID username ban lookup failed: SQL Error");
|
||||
qCWarning(AbstractServerSocketInterfaceLog) << "ClientID username ban lookup failed: SQL Error";
|
||||
} else {
|
||||
while (clientIdQuery->next()) {
|
||||
userName = clientIdQuery->value(0).toString();
|
||||
|
|
@ -1152,7 +1157,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRegisterAccount(const C
|
|||
{
|
||||
QString userName = nameFromStdString(cmd.user_name());
|
||||
QString clientId = nameFromStdString(cmd.clientid());
|
||||
qDebug() << "Got register command for user:" << userName;
|
||||
qCDebug(AbstractServerSocketInterfaceLog) << "Got register command for user:" << userName;
|
||||
|
||||
bool registrationEnabled = settingsCache->value("registration/enabled", false).toBool();
|
||||
if (!registrationEnabled) {
|
||||
|
|
@ -1289,7 +1294,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRegisterAccount(const C
|
|||
country, !requireEmailActivation);
|
||||
|
||||
if (regSucceeded) {
|
||||
qDebug() << "Accepted register command for user:" << userName;
|
||||
qCDebug(AbstractServerSocketInterfaceLog) << "Accepted register command for user:" << userName;
|
||||
if (requireEmailActivation) {
|
||||
QSqlQuery *query =
|
||||
sqlInterface->prepareQuery("insert into {prefix}_activation_emails (name) values(:name)");
|
||||
|
|
@ -1337,7 +1342,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdActivateAccount(const C
|
|||
clientId = "UNKNOWN";
|
||||
|
||||
if (sqlInterface->activateUser(userName, token)) {
|
||||
qDebug() << "Accepted activation for user" << userName;
|
||||
qCDebug(AbstractServerSocketInterfaceLog) << "Accepted activation for user" << userName;
|
||||
|
||||
if (servatrice->getEnableRegistrationAudit())
|
||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||
|
|
@ -1345,7 +1350,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdActivateAccount(const C
|
|||
|
||||
return Response::RespActivationAccepted;
|
||||
} else {
|
||||
qDebug() << "Failed activation for user" << userName;
|
||||
qCDebug(AbstractServerSocketInterfaceLog) << "Failed activation for user" << userName;
|
||||
|
||||
if (servatrice->getEnableRegistrationAudit())
|
||||
sqlInterface->addAuditRecord(userName.simplified(), this->getAddress(), clientId.simplified(),
|
||||
|
|
@ -1493,7 +1498,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdForgotPasswordRequest(c
|
|||
const QString userName = nameFromStdString(cmd.user_name());
|
||||
const QString clientId = nameFromStdString(cmd.clientid());
|
||||
|
||||
qDebug() << "Received reset password request from user:" << userName;
|
||||
qCDebug(AbstractServerSocketInterfaceLog) << "Received reset password request from user:" << userName;
|
||||
|
||||
if (!servatrice->getEnableForgotPassword()) {
|
||||
if (servatrice->getEnableForgotPasswordAudit())
|
||||
|
|
@ -1575,7 +1580,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdForgotPasswordReset(con
|
|||
Q_UNUSED(rc);
|
||||
QString userName = nameFromStdString(cmd.user_name());
|
||||
QString clientId = nameFromStdString(cmd.clientid());
|
||||
qDebug() << "Received reset password reset from user:" << userName;
|
||||
qCDebug(AbstractServerSocketInterfaceLog) << "Received reset password reset from user:" << userName;
|
||||
|
||||
if (!sqlInterface->doesForgotPasswordExist(userName)) {
|
||||
if (servatrice->getEnableForgotPasswordAudit())
|
||||
|
|
@ -1626,7 +1631,7 @@ AbstractServerSocketInterface::cmdForgotPasswordChallenge(const Command_ForgotPa
|
|||
const QString userName = nameFromStdString(cmd.user_name());
|
||||
const QString clientId = nameFromStdString(cmd.clientid());
|
||||
|
||||
qDebug() << "Received reset password challenge from user:" << userName;
|
||||
qCDebug(AbstractServerSocketInterfaceLog) << "Received reset password challenge from user:" << userName;
|
||||
|
||||
if (!servatrice->getEnableForgotPasswordChallenge()) {
|
||||
if (servatrice->getEnableForgotPasswordAudit()) {
|
||||
|
|
@ -1971,13 +1976,16 @@ void TcpServerSocketInterface::flushOutputQueue()
|
|||
unsigned int size = static_cast<unsigned int>(item.ByteSize());
|
||||
#endif
|
||||
buf.resize(size + 4);
|
||||
item.SerializeToArray(buf.data() + 4, size);
|
||||
buf.data()[3] = (unsigned char)size;
|
||||
buf.data()[2] = (unsigned char)(size >> 8);
|
||||
buf.data()[1] = (unsigned char)(size >> 16);
|
||||
buf.data()[0] = (unsigned char)(size >> 24);
|
||||
// In case socket->write() calls catchSocketError(), the mutex must not be locked during this call.
|
||||
writeToSocket(buf);
|
||||
if (item.SerializeToArray(buf.data() + 4, size)) {
|
||||
buf.data()[3] = (unsigned char)size;
|
||||
buf.data()[2] = (unsigned char)(size >> 8);
|
||||
buf.data()[1] = (unsigned char)(size >> 16);
|
||||
buf.data()[0] = (unsigned char)(size >> 24);
|
||||
// In case socket->write() calls catchSocketError(), the mutex must not be locked during this call.
|
||||
writeToSocket(buf);
|
||||
} else {
|
||||
qCWarning(TcpServerSocketInterfaceLog) << "serialisation error!";
|
||||
}
|
||||
|
||||
totalBytes += size + 4;
|
||||
locker.relock();
|
||||
|
|
@ -2010,41 +2018,48 @@ void TcpServerSocketInterface::readClient()
|
|||
return;
|
||||
|
||||
CommandContainer newCommandContainer;
|
||||
bool ok;
|
||||
try {
|
||||
newCommandContainer.ParseFromArray(inputBuffer.data(), messageLength);
|
||||
ok = newCommandContainer.ParseFromArray(inputBuffer.data(), messageLength);
|
||||
} catch (std::exception &e) {
|
||||
qDebug() << "Caught std::exception in" << __FILE__ << __LINE__ <<
|
||||
qCWarning(TcpServerSocketInterfaceLog) << "Caught std::exception in" << __FILE__ << __LINE__ <<
|
||||
#ifdef _MSC_VER // Visual Studio
|
||||
__FUNCTION__;
|
||||
__FUNCTION__
|
||||
#else
|
||||
__PRETTY_FUNCTION__;
|
||||
__PRETTY_FUNCTION__
|
||||
#endif
|
||||
qDebug() << "Exception:" << e.what();
|
||||
qDebug() << "Message coming from:" << getAddress();
|
||||
qDebug() << "Message length:" << messageLength;
|
||||
qDebug() << "Message content:" << inputBuffer.toHex();
|
||||
<< Qt::endl
|
||||
<< "Exception:" << e.what() << Qt::endl
|
||||
<< "Message coming from:" << getAddress() << Qt::endl
|
||||
<< "Message length:" << messageLength << Qt::endl
|
||||
<< "Message content:" << inputBuffer.toHex();
|
||||
} catch (...) {
|
||||
qDebug() << "Unhandled exception in" << __FILE__ << __LINE__ <<
|
||||
qCWarning(TcpServerSocketInterfaceLog) << "Unhandled exception in" << __FILE__ << __LINE__ <<
|
||||
#ifdef _MSC_VER // Visual Studio
|
||||
__FUNCTION__;
|
||||
__FUNCTION__
|
||||
#else
|
||||
__PRETTY_FUNCTION__;
|
||||
__PRETTY_FUNCTION__
|
||||
#endif
|
||||
qDebug() << "Message coming from:" << getAddress();
|
||||
<< Qt::endl
|
||||
<< "Message coming from:" << getAddress();
|
||||
}
|
||||
|
||||
inputBuffer.remove(0, messageLength);
|
||||
messageInProgress = false;
|
||||
|
||||
// dirty hack to make v13 client display the correct error message
|
||||
if (handshakeStarted)
|
||||
processCommandContainer(newCommandContainer);
|
||||
else if (!newCommandContainer.has_cmd_id()) {
|
||||
handshakeStarted = true;
|
||||
if (!initTcpSession())
|
||||
prepareDestroy();
|
||||
if (ok) {
|
||||
// dirty hack to make v13 client display the correct error message
|
||||
if (handshakeStarted)
|
||||
processCommandContainer(newCommandContainer);
|
||||
else if (!newCommandContainer.has_cmd_id()) {
|
||||
handshakeStarted = true;
|
||||
if (!initTcpSession())
|
||||
prepareDestroy();
|
||||
}
|
||||
// end of hack
|
||||
} else {
|
||||
qCWarning(TcpServerSocketInterfaceLog) << "parsing error!";
|
||||
}
|
||||
// end of hack
|
||||
|
||||
} while (!inputBuffer.isEmpty());
|
||||
}
|
||||
|
||||
|
|
@ -2172,9 +2187,12 @@ void WebsocketServerSocketInterface::flushOutputQueue()
|
|||
unsigned int size = static_cast<unsigned int>(item.ByteSize());
|
||||
#endif
|
||||
buf.resize(size);
|
||||
item.SerializeToArray(buf.data(), size);
|
||||
// In case socket->write() calls catchSocketError(), the mutex must not be locked during this call.
|
||||
writeToSocket(buf);
|
||||
if (item.SerializeToArray(buf.data(), size)) {
|
||||
// In case socket->write() calls catchSocketError(), the mutex must not be locked during this call.
|
||||
writeToSocket(buf);
|
||||
} else {
|
||||
qCWarning(TcpServerSocketInterfaceLog) << "serialisation error!";
|
||||
}
|
||||
|
||||
totalBytes += size;
|
||||
locker.relock();
|
||||
|
|
@ -2190,30 +2208,37 @@ void WebsocketServerSocketInterface::binaryMessageReceived(const QByteArray &mes
|
|||
servatrice->incRxBytes(message.size());
|
||||
|
||||
CommandContainer newCommandContainer;
|
||||
bool ok;
|
||||
try {
|
||||
newCommandContainer.ParseFromArray(message.data(), message.size());
|
||||
ok = newCommandContainer.ParseFromArray(message.data(), message.size());
|
||||
} catch (std::exception &e) {
|
||||
qDebug() << "Caught std::exception in" << __FILE__ << __LINE__ <<
|
||||
qCWarning(WebsocketServerSocketInterfaceLog) << "Caught std::exception in" << __FILE__ << __LINE__ <<
|
||||
#ifdef _MSC_VER // Visual Studio
|
||||
__FUNCTION__;
|
||||
__FUNCTION__
|
||||
#else
|
||||
__PRETTY_FUNCTION__;
|
||||
__PRETTY_FUNCTION__
|
||||
#endif
|
||||
qDebug() << "Exception:" << e.what();
|
||||
qDebug() << "Message coming from:" << getAddress();
|
||||
qDebug() << "Message length:" << message.size();
|
||||
qDebug() << "Message content:" << message.toHex();
|
||||
<< Qt::endl
|
||||
<< "Exception:" << e.what() << Qt::endl
|
||||
<< "Message coming from:" << getAddress() << Qt::endl
|
||||
<< "Message length:" << message.size() << Qt::endl
|
||||
<< "Message content:" << message.toHex();
|
||||
} catch (...) {
|
||||
qDebug() << "Unhandled exception in" << __FILE__ << __LINE__ <<
|
||||
qCWarning(WebsocketServerSocketInterfaceLog) << "Unhandled exception in" << __FILE__ << __LINE__ <<
|
||||
#ifdef _MSC_VER // Visual Studio
|
||||
__FUNCTION__;
|
||||
__FUNCTION__
|
||||
#else
|
||||
__PRETTY_FUNCTION__;
|
||||
__PRETTY_FUNCTION__
|
||||
#endif
|
||||
qDebug() << "Message coming from:" << getAddress();
|
||||
<< Qt::endl
|
||||
<< "Message coming from:" << getAddress();
|
||||
}
|
||||
|
||||
processCommandContainer(newCommandContainer);
|
||||
if (ok) {
|
||||
processCommandContainer(newCommandContainer);
|
||||
} else {
|
||||
qCWarning(WebsocketServerSocketInterfaceLog) << "parsing error!";
|
||||
}
|
||||
}
|
||||
|
||||
bool AbstractServerSocketInterface::isPasswordLongEnough(const int passwordLength)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue