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

* fix compiling on arch

* redo all the logging in affected files
This commit is contained in:
ebbit1q 2026-04-05 21:52:46 +02:00 committed by GitHub
parent a46ab5cd68
commit 3ec9ae9772
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 219 additions and 148 deletions

View file

@ -3,6 +3,7 @@
#include "main.h"
#include "server_logger.h"
#include <QLoggingCategory>
#include <QSslSocket>
#include <google/protobuf/descriptor.h>
#include <libcockatrice/protocol/debug_pb_message.h>
@ -21,6 +22,8 @@
#include <server_protocolhandler.h>
#include <server_room.h>
inline Q_LOGGING_CATEGORY(IslInterfaceLog, "isl_interface");
void IslInterface::sharedCtor(const QSslCertificate &cert, const QSslKey &privateKey)
{
socket = new QSslSocket(this);
@ -113,10 +116,11 @@ void IslInterface::initServer()
socket->startServerEncryption();
if (!socket->waitForEncrypted(5000)) {
QList<QSslError> sslErrors(socket->sslHandshakeErrors());
if (sslErrors.isEmpty())
qDebug() << "[ISL] SSL handshake timeout, terminating connection";
else
qDebug() << "[ISL] SSL errors:" << sslErrors;
if (sslErrors.isEmpty()) {
qCDebug(IslInterfaceLog) << "SSL handshake timeout, terminating connection";
} else {
qCWarning(IslInterfaceLog) << "SSL errors:" << sslErrors;
}
deleteLater();
return;
}
@ -157,7 +161,7 @@ void IslInterface::initServer()
server->islLock.lockForWrite();
if (server->islConnectionExists(serverId)) {
qDebug() << "[ISL] Duplicate connection to #" << serverId << "terminating connection";
qCDebug(IslInterfaceLog) << "Duplicate connection to #" << serverId << "terminating connection";
deleteLater();
} else {
transmitMessage(message);
@ -180,27 +184,28 @@ void IslInterface::initClient()
expectedErrors.append(QSslError(QSslError::SelfSignedCertificate, peerCert));
socket->ignoreSslErrors(expectedErrors);
qDebug() << "[ISL] Connecting to #" << serverId << ":" << peerAddress << ":" << peerPort;
qCDebug(IslInterfaceLog) << "Connecting to #" << serverId << ":" << peerAddress << ":" << peerPort;
socket->connectToHostEncrypted(peerAddress, peerPort, peerHostName);
if (!socket->waitForConnected(5000)) {
qDebug() << "[ISL] Socket error:" << socket->errorString();
qCDebug(IslInterfaceLog) << "Socket error:" << socket->errorString();
deleteLater();
return;
}
if (!socket->waitForEncrypted(5000)) {
QList<QSslError> sslErrors(socket->sslHandshakeErrors());
if (sslErrors.isEmpty())
qDebug() << "[ISL] SSL handshake timeout, terminating connection";
else
qDebug() << "[ISL] SSL errors:" << sslErrors;
if (sslErrors.isEmpty()) {
qCDebug(IslInterfaceLog) << "SSL handshake timeout, terminating connection";
} else {
qCWarning(IslInterfaceLog) << "SSL errors:" << sslErrors;
}
deleteLater();
return;
}
server->islLock.lockForWrite();
if (server->islConnectionExists(serverId)) {
qDebug() << "[ISL] Duplicate connection to #" << serverId << "terminating connection";
qCDebug(IslInterfaceLog) << "Duplicate connection to #" << serverId << "terminating connection";
deleteLater();
return;
}
@ -242,17 +247,21 @@ void IslInterface::readClient()
return;
IslMessage newMessage;
newMessage.ParseFromArray(inputBuffer.data(), messageLength);
bool ok = newMessage.ParseFromArray(inputBuffer.data(), messageLength);
inputBuffer.remove(0, messageLength);
messageInProgress = false;
processMessage(newMessage);
if (ok) {
processMessage(newMessage);
} else {
qCWarning(IslInterfaceLog) << "parsing error!";
}
} while (!inputBuffer.isEmpty());
}
void IslInterface::catchSocketError(QAbstractSocket::SocketError socketError)
{
qDebug() << "[ISL] Socket error:" << socketError;
qCWarning(IslInterfaceLog) << "Socket error:" << socketError;
server->islLock.lockForWrite();
server->removeIslInterface(serverId);
@ -270,7 +279,10 @@ void IslInterface::transmitMessage(const IslMessage &item)
unsigned int size = static_cast<unsigned int>(item.ByteSize());
#endif
buf.resize(size + 4);
item.SerializeToArray(buf.data() + 4, size);
if (!item.SerializeToArray(buf.data() + 4, size)) {
qCWarning(IslInterfaceLog) << "transmit error!";
return;
}
buf.data()[3] = (unsigned char)size;
buf.data()[2] = (unsigned char)(size >> 8);
buf.data()[1] = (unsigned char)(size >> 16);
@ -368,7 +380,7 @@ void IslInterface::processSessionEvent(const SessionEvent &event, qint64 session
QReadLocker clientsLocker(&server->clientsLock);
Server_AbstractUserInterface *client = server->getUsersBySessionId().value(sessionId);
if (!client) {
qDebug() << "IslInterface::processSessionEvent: session id" << sessionId << "not found";
qCDebug(IslInterfaceLog) << "IslInterface::processSessionEvent: session id" << sessionId << "not found";
break;
}
const Event_GameJoined &gameJoined = event.GetExtension(Event_GameJoined::ext);
@ -382,7 +394,8 @@ void IslInterface::processSessionEvent(const SessionEvent &event, qint64 session
QReadLocker clientsLocker(&server->clientsLock);
Server_AbstractUserInterface *client = server->getUsersBySessionId().value(sessionId);
if (!client) {
qDebug() << "IslInterface::processSessionEvent: session id" << sessionId << "not found";
qCWarning(IslInterfaceLog)
<< "IslInterface::processSessionEvent: session id" << sessionId << "not found";
break;
}
@ -430,7 +443,7 @@ void IslInterface::processRoomCommand(const CommandContainer &cont, qint64 sessi
void IslInterface::processMessage(const IslMessage &item)
{
qDebug() << getSafeDebugString(item);
qCDebug(IslInterfaceLog) << getSafeDebugString(item);
switch (item.message_type()) {
case IslMessage::ROOM_COMMAND_CONTAINER: {