X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcore.cpp;h=4b4aa7256e261ee761915a3f95d36d1250b5696d;hp=25bdc8190d020c0b0f63a5464998241c8ead5d7f;hb=6ca804505c512deff72ff43533fa1d5ea0a3416a;hpb=79551d95b458b180e66353d079da1c2c947d8908 diff --git a/src/core/core.cpp b/src/core/core.cpp index 25bdc819..4b4aa725 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -340,12 +340,23 @@ QHash Core::bufferLastSeenMsgIds(UserId user) { /*** Network Management ***/ bool Core::startListening(uint port) { - if(!server.listen(QHostAddress::AnyIPv6, port)) { + bool success = false; + + // let's see if ipv6 is available + success = server.listen(QHostAddress::AnyIPv6, port); + + if(!success && server.serverError() == QAbstractSocket::UnsupportedSocketOperationError) { + // fall back to v4 + success = server.listen(QHostAddress::Any, port); + } + + if(!success) { qWarning("%s", qPrintable(QString("Could not open GUI client port %1: %2").arg(port).arg(server.errorString()))); - return false; + } else { + qDebug() << "Listening for GUI clients on port" << server.serverPort(); } - qDebug() << "Listening for GUI clients on port" << server.serverPort(); - return true; + + return success; } void Core::stopListening() { @@ -362,7 +373,7 @@ void Core::incomingConnection() { QVariantMap clientInfo; blocksizes.insert(socket, (quint32)0); - qDebug() << "Client connected from" << qPrintable(socket->peerAddress().toString()); + qDebug() << qPrintable(tr("Client connected from")) << qPrintable(socket->peerAddress().toString()); if (!configured) { server.close(); @@ -403,7 +414,7 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) { "This core needs at least client/core protocol version %1.
" "Please consider upgrading your client.").arg(Global::coreNeedsProtocol); SignalProxy::writeDataToDevice(socket, reply); - qWarning() << qPrintable(tr("Client %1 too old, rejecting.").arg(socket->peerAddress().toString())); + qWarning() << qPrintable(tr("Client")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr("too old, rejecting.")); socket->close(); return; } @@ -463,7 +474,7 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) { #ifndef QT_NO_OPENSSL // after we told the client that we are ssl capable we switch to ssl mode if(supportSsl && msg["UseSsl"].toBool()) { - qDebug() << "Starting TLS for Client:" << qPrintable(socket->peerAddress().toString()); + qDebug() << qPrintable(tr("Starting TLS for Client:")) << qPrintable(socket->peerAddress().toString()); connect(sslSocket, SIGNAL(sslErrors(const QList &)), this, SLOT(sslErrors(const QList &))); sslSocket->startServerEncryption(); } @@ -483,7 +494,7 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) { reply["MsgType"] = "ClientLoginReject"; reply["Error"] = tr("Client not initialized!
You need to send an init message before trying to login."); SignalProxy::writeDataToDevice(socket, reply); - qWarning() << qPrintable(tr("Client %1 did not send an init message before trying to login, rejecting.").arg(socket->peerAddress().toString())); + qWarning() << qPrintable(tr("Client")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr("did not send an init message before trying to login, rejecting.")); socket->close(); return; } if(msg["MsgType"] == "CoreSetupData") { @@ -509,7 +520,7 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) { } reply["MsgType"] = "ClientLoginAck"; SignalProxy::writeDataToDevice(socket, reply); - qDebug() << qPrintable(tr("Client %1 initialized and authenticated successfully as \"%2\" (UserId: %3).").arg(socket->peerAddress().toString(), msg["User"].toString()).arg(uid.toInt())); + qDebug() << qPrintable(tr("Client")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr("initialized and authenticated successfully as \"%1\" (UserId: %2).").arg(msg["User"].toString()).arg(uid.toInt())); setupClientSession(socket, uid); } } @@ -565,7 +576,7 @@ void Core::setupClientSession(QTcpSocket *socket, UserId uid) { blocksizes.remove(socket); clientInfo.remove(socket); if(!sess) { - qWarning() << qPrintable(tr("Could not initialize session for client %1!").arg(socket->peerAddress().toString())); + qWarning() << qPrintable(tr("Could not initialize session for client:")) << qPrintable(socket->peerAddress().toString()); socket->close(); } sess->addClient(socket);