X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fcore.cpp;h=47b4bbbd253a5a972b85e2e4d29b36eb336ac7aa;hb=b217278ce3ac1eddaa9e5047b50407fff31c9319;hp=792bff3f8dbd81c9c921d7a4ca8fe083cb77a02b;hpb=6659683b5fa4dcb6068d9f6fbe8dd7818498466f;p=quassel.git diff --git a/src/core/core.cpp b/src/core/core.cpp index 792bff3f..47b4bbbd 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::Any, 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; } @@ -456,7 +467,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(); } @@ -469,7 +480,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") { @@ -495,7 +506,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); } } @@ -551,7 +562,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);