X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcore.cpp;h=46a0d6c0a23919bdce1f8e4bc1065e874a7adad4;hp=93a6d13c94876d41af9cbc9cea7ec22b5f1318a8;hb=fe654bfe2e86149b18de76111ddb38985d505dd3;hpb=f824db0e31b54969e0b7fa0b5405b1e9173d482c diff --git a/src/core/core.cpp b/src/core/core.cpp index 93a6d13c..46a0d6c0 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -244,20 +244,66 @@ bool Core::startListening() { bool success = false; uint port = Quassel::optionValue("port").toUInt(); - if(_server.listen(QHostAddress::Any, port)) { - quInfo() << "Listening for GUI clients on IPv4 port" << _server.serverPort() - << "using protocol version" << Quassel::buildInfo().protocolVersion; - success = true; - } - if(_v6server.listen(QHostAddress::AnyIPv6, port)) { - quInfo() << "Listening for GUI clients on IPv6 port" << _v6server.serverPort() - << "using protocol version" << Quassel::buildInfo().protocolVersion; - success = true; - } - - if(!success) { - qCritical() << qPrintable(QString("Could not open GUI client port %1: %2").arg(port).arg(_server.errorString())); + const QString listen = Quassel::optionValue("listen"); + const QStringList listen_list = listen.split(",", QString::SkipEmptyParts); + if(listen_list.size() > 0) { + foreach (const QString listen_term, listen_list) { // TODO: handle multiple interfaces for same TCP version gracefully + QHostAddress addr; + if(!addr.setAddress(listen_term)) { + qCritical() << qPrintable( + tr("Invalid listen address %1") + .arg(listen_term) + ); + } else { + switch(addr.protocol()) { + case QAbstractSocket::IPv4Protocol: + if(_server.listen(addr, port)) { + quInfo() << qPrintable( + tr("Listening for GUI clients on IPv4 %1 port %2 using protocol version %3") + .arg(addr.toString()) + .arg(_server.serverPort()) + .arg(Quassel::buildInfo().protocolVersion) + ); + success = true; + } else + quWarning() << qPrintable( + tr("Could not open IPv4 interface %1:%2: %3") + .arg(addr.toString()) + .arg(port) + .arg(_server.errorString())); + break; + case QAbstractSocket::IPv6Protocol: + if(_v6server.listen(addr, port)) { + quInfo() << qPrintable( + tr("Listening for GUI clients on IPv6 %1 port %2 using protocol version %3") + .arg(addr.toString()) + .arg(_v6server.serverPort()) + .arg(Quassel::buildInfo().protocolVersion) + ); + success = true; + } else { + // if v4 succeeded on Any, the port will be already in use - don't display the error then + // FIXME: handle this more sanely, make sure we can listen to both v4 and v6 by default! + if(!success || _v6server.serverError() != QAbstractSocket::AddressInUseError) + quWarning() << qPrintable( + tr("Could not open IPv6 interface %1:%2: %3") + .arg(addr.toString()) + .arg(port) + .arg(_v6server.errorString())); + } + break; + default: + qCritical() << qPrintable( + tr("Invalid listen address %1, unknown network protocol") + .arg(listen_term) + ); + break; + } + } + } } + if(!success) + quError() << qPrintable(tr("Could not open any network interfaces to listen on!")); return success; } @@ -350,7 +396,7 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) { #ifdef HAVE_SSL SslServer *sslServer = qobject_cast(&_server); QSslSocket *sslSocket = qobject_cast(socket); - bool supportSsl = (bool)sslServer && (bool)sslSocket && sslServer->certIsValid(); + bool supportSsl = (bool)sslServer && (bool)sslSocket && sslServer->isCertValid(); #else bool supportSsl = false; #endif