X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fclientauthhandler.cpp;h=a3fc870d84343b761329fb683acd0bc5093f0070;hp=7ded71d820396d675a6479c5c94099c19fe76163;hb=39328183a6a87c6eb10a9dbbffcd5d65bf154a1f;hpb=d6f3eedebc7f9619b04dffc5f48faa792950fdcd diff --git a/src/client/clientauthhandler.cpp b/src/client/clientauthhandler.cpp index 7ded71d8..a3fc870d 100644 --- a/src/client/clientauthhandler.cpp +++ b/src/client/clientauthhandler.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2016 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -20,8 +20,6 @@ #include "clientauthhandler.h" -// TODO: support system application proxy (new in Qt 4.6) - #include #ifdef HAVE_SSL @@ -32,17 +30,14 @@ #include "client.h" #include "clientsettings.h" +#include "logmessage.h" #include "peerfactory.h" -#if QT_VERSION < 0x050000 -# include "../../3rdparty/sha512/sha512.h" -#endif - using namespace Protocol; ClientAuthHandler::ClientAuthHandler(CoreAccount account, QObject *parent) : AuthHandler(parent), - _peer(0), + _peer(nullptr), _account(account), _probing(false), _legacy(false), @@ -52,6 +47,12 @@ ClientAuthHandler::ClientAuthHandler(CoreAccount account, QObject *parent) } +Peer *ClientAuthHandler::peer() const +{ + return _peer; +} + + void ClientAuthHandler::connectToCore() { CoreAccountSettings s; @@ -75,10 +76,21 @@ void ClientAuthHandler::connectToCore() QTcpSocket *socket = new QTcpSocket(this); #endif -// TODO: Handle system proxy #ifndef QT_NO_NETWORKPROXY - if (_account.useProxy()) { - QNetworkProxy proxy(_account.proxyType(), _account.proxyHostName(), _account.proxyPort(), _account.proxyUser(), _account.proxyPassword()); + QNetworkProxy proxy; + proxy.setType(_account.proxyType()); + if (_account.proxyType() == QNetworkProxy::Socks5Proxy || + _account.proxyType() == QNetworkProxy::HttpProxy) { + proxy.setHostName(_account.proxyHostName()); + proxy.setPort(_account.proxyPort()); + proxy.setUser(_account.proxyUser()); + proxy.setPassword(_account.proxyPassword()); + } + + if (_account.proxyType() == QNetworkProxy::DefaultProxy) { + QNetworkProxyFactory::setUseSystemConfiguration(true); + } else { + QNetworkProxyFactory::setUseSystemConfiguration(false); socket->setProxy(proxy); } #endif @@ -288,7 +300,7 @@ void ClientAuthHandler::startRegistration() useSsl = _account.useSsl(); #endif - _peer->dispatch(RegisterClient(Quassel::buildInfo().fancyVersionString, Quassel::buildInfo().commitDate, useSsl)); + _peer->dispatch(RegisterClient(Quassel::Features{}, Quassel::buildInfo().fancyVersionString, Quassel::buildInfo().commitDate, useSsl)); } @@ -303,9 +315,9 @@ void ClientAuthHandler::handle(const ClientRegistered &msg) { _coreConfigured = msg.coreConfigured; _backendInfo = msg.backendInfo; - _authBackendInfo = msg.authBackendInfo; + _authenticatorInfo = msg.authenticatorInfo; - Client::setCoreFeatures(static_cast(msg.coreFeatures)); + _peer->setFeatures(std::move(msg.features)); // The legacy protocol enables SSL at this point if(_legacy && _account.useSsl()) @@ -317,12 +329,21 @@ void ClientAuthHandler::handle(const ClientRegistered &msg) void ClientAuthHandler::onConnectionReady() { + const auto &coreFeatures = _peer->features(); + auto unsupported = coreFeatures.toStringList(false); + if (!unsupported.isEmpty()) { + quInfo() << qPrintable(tr("Core does not support the following features: %1").arg(unsupported.join(", "))); + } + if (!coreFeatures.unknownFeatures().isEmpty()) { + quInfo() << qPrintable(tr("Core supports unknown features: %1").arg(coreFeatures.unknownFeatures().join(", "))); + } + emit connectionReady(); emit statusMessage(tr("Connected to %1").arg(_account.accountName())); if (!_coreConfigured) { // start wizard - emit startCoreSetup(_backendInfo, _authBackendInfo); + emit startCoreSetup(_backendInfo, _authenticatorInfo); } else // TODO: check if we need LoginEnabled login(); @@ -390,10 +411,10 @@ void ClientAuthHandler::handle(const LoginSuccess &msg) void ClientAuthHandler::handle(const SessionState &msg) { - disconnect(socket(), 0, this, 0); // this is the last message we shall ever get + disconnect(socket(), nullptr, this, nullptr); // this is the last message we shall ever get // give up ownership of the peer; CoreSession takes responsibility now - _peer->setParent(0); + _peer->setParent(nullptr); emit handshakeComplete(_peer, msg); } @@ -478,11 +499,7 @@ void ClientAuthHandler::onSslErrors() break; case ClientAuthHandler::DigestVersion::Sha2_512: -#if QT_VERSION >= 0x050000 calculatedDigest = socket->peerCertificate().digest(QCryptographicHash::Sha512); -#else - calculatedDigest = sha2_512(socket->peerCertificate().toDer()); -#endif break; default: @@ -500,11 +517,7 @@ void ClientAuthHandler::onSslErrors() } if (permanently) { -#if QT_VERSION >= 0x050000 s.setAccountValue("SslCert", socket->peerCertificate().digest(QCryptographicHash::Sha512)); -#else - s.setAccountValue("SslCert", sha2_512(socket->peerCertificate().toDer())); -#endif s.setAccountValue("SslCertDigestVersion", ClientAuthHandler::DigestVersion::Latest); } else { @@ -513,28 +526,11 @@ void ClientAuthHandler::onSslErrors() } } else if (knownDigestVersion != ClientAuthHandler::DigestVersion::Latest) { -#if QT_VERSION >= 0x050000 s.setAccountValue("SslCert", socket->peerCertificate().digest(QCryptographicHash::Sha512)); -#else - s.setAccountValue("SslCert", sha2_512(socket->peerCertificate().toDer())); -#endif s.setAccountValue("SslCertDigestVersion", ClientAuthHandler::DigestVersion::Latest); } socket->ignoreSslErrors(); } -#if QT_VERSION < 0x050000 -QByteArray ClientAuthHandler::sha2_512(const QByteArray &input) { - unsigned char output[64]; - sha512((unsigned char*) input.constData(), input.size(), output, false); - // QByteArray::fromRawData() cannot be used here because that constructor - // does not copy "output" and the data is clobbered when the variable goes - // out of scope. - QByteArray result; - result.append((char*) output, 64); - return result; -} -#endif - #endif /* HAVE_SSL */