X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcore.cpp;h=01b341c8f46d0645d51db70998eb226d1f817a3b;hp=4a5a64ee05c75af6958c8a6160aa4d8f63bc1fd2;hb=a0c839394a714783966a4282b30b4025fe9fa76e;hpb=20d41ee02763e0d681cb32718174a63e66068666 diff --git a/src/core/core.cpp b/src/core/core.cpp index 4a5a64ee..01b341c8 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -85,7 +85,8 @@ void Core::init() { } } - connect(&server, SIGNAL(newConnection()), this, SLOT(incomingConnection())); + connect(&_server, SIGNAL(newConnection()), this, SLOT(incomingConnection())); + connect(&_v6server, SIGNAL(newConnection()), this, SLOT(incomingConnection())); if(!startListening(cs.port())) exit(1); // TODO make this less brutal } @@ -343,31 +344,33 @@ QHash Core::bufferLastSeenMsgIds(UserId user) { bool Core::startListening(uint 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(_server.listen(QHostAddress::Any, port)) { + quInfo() << "Listening for GUI clients on IPv6 port" << _server.serverPort() << "using protocol version" << Global::protocolVersion; + success = true; + } + if(_v6server.listen(QHostAddress::AnyIPv6, port)) { + quInfo() << "Listening for GUI clients on IPv4 port" << _v6server.serverPort() << "using protocol version" << Global::protocolVersion; + success = true; } if(!success) { - quError() << qPrintable(QString("Could not open GUI client port %1: %2").arg(port).arg(server.errorString())); - } else { - quInfo() << "Listening for GUI clients on port" << server.serverPort() << "using protocol version" << Global::protocolVersion; + quError() << qPrintable(QString("Could not open GUI client port %1: %2").arg(port).arg(_server.errorString())); } return success; } void Core::stopListening() { - server.close(); + _server.close(); + _v6server.close(); quInfo() << "No longer listening for GUI clients."; } void Core::incomingConnection() { - while(server.hasPendingConnections()) { - QTcpSocket *socket = server.nextPendingConnection(); + QTcpServer *server = qobject_cast(sender()); + Q_ASSERT(server); + while(server->hasPendingConnections()) { + QTcpSocket *socket = server->nextPendingConnection(); connect(socket, SIGNAL(disconnected()), this, SLOT(clientDisconnected())); connect(socket, SIGNAL(readyRead()), this, SLOT(clientHasData())); connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError))); @@ -376,8 +379,9 @@ void Core::incomingConnection() { blocksizes.insert(socket, (quint32)0); quInfo() << qPrintable(tr("Client connected from")) << qPrintable(socket->peerAddress().toString()); - if (!configured) { - server.close(); + if(!configured) { + _server.close(); + _v6server.close(); quDebug() << "Closing server for basic setup."; } } @@ -434,7 +438,7 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) { .arg(updays).arg(uphours,2,10,QChar('0')).arg(upmins,2,10,QChar('0')).arg(startTime().toString(Qt::TextDate)); #ifdef HAVE_SSL - SslServer *sslServer = qobject_cast(&server); + SslServer *sslServer = qobject_cast(&_server); QSslSocket *sslSocket = qobject_cast(socket); bool supportSsl = (bool)sslServer && (bool)sslSocket && sslServer->certIsValid(); #else