X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Fprotocols%2Fdatastream%2Fdatastreampeer.cpp;h=240560da9f74d6b396312dd7aa49a6db9154148e;hb=6718d7a1ccd42d7aae75e57d6974e0b1e0384044;hp=294dc6e68650658cb8c4c5b800df999945099c7b;hpb=b2169e5f4cbd3ce724c4808b62ddc2b8941219a5;p=quassel.git diff --git a/src/common/protocols/datastream/datastreampeer.cpp b/src/common/protocols/datastream/datastreampeer.cpp index 294dc6e6..240560da 100644 --- a/src/common/protocols/datastream/datastreampeer.cpp +++ b/src/common/protocols/datastream/datastreampeer.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2014 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 * @@ -19,17 +19,18 @@ ***************************************************************************/ #include - +#include #include #include #include "datastreampeer.h" #include "quassel.h" +#include "serializers/serializers.h" using namespace Protocol; -DataStreamPeer::DataStreamPeer(::AuthHandler *authHandler, QTcpSocket *socket, quint16 features, QObject *parent) - : RemotePeer(authHandler, socket, parent) +DataStreamPeer::DataStreamPeer(::AuthHandler *authHandler, QTcpSocket *socket, quint16 features, Compressor::CompressionLevel level, QObject *parent) + : RemotePeer(authHandler, socket, level, parent) { Q_UNUSED(features); } @@ -59,7 +60,8 @@ void DataStreamPeer::processMessage(const QByteArray &msg) QDataStream stream(msg); stream.setVersion(QDataStream::Qt_4_2); QVariantList list; - stream >> list; + if (!Serializers::deserialize(stream, features(), list)) + close("Peer sent corrupt data, closing down!"); if (stream.status() != QDataStream::Ok) { close("Peer sent corrupt data, closing down!"); return; @@ -117,7 +119,11 @@ void DataStreamPeer::handleHandshakeMessage(const QVariantList &mapData) } if (msgType == "ClientInit") { - handle(RegisterClient(m["ClientVersion"].toString(), false)); // UseSsl obsolete + handle(RegisterClient{Quassel::Features{m["FeatureList"].toStringList(), Quassel::LegacyFeatures(m["Features"].toUInt())}, + m["ClientVersion"].toString(), + m["ClientDate"].toString(), + false // UseSsl obsolete + }); } else if (msgType == "ClientInitReject") { @@ -125,12 +131,17 @@ void DataStreamPeer::handleHandshakeMessage(const QVariantList &mapData) } else if (msgType == "ClientInitAck") { - handle(ClientRegistered(m["CoreFeatures"].toUInt(), m["Configured"].toBool(), m["StorageBackends"].toList(), false, QDateTime())); // SupportsSsl and coreStartTime obsolete + handle(ClientRegistered{Quassel::Features{m["FeatureList"].toStringList(), Quassel::LegacyFeatures(m["CoreFeatures"].toUInt())}, + m["Configured"].toBool(), + m["StorageBackends"].toList(), + m["Authenticators"].toList(), + false // SupportsSsl obsolete + }); } else if (msgType == "CoreSetupData") { QVariantMap map = m["SetupData"].toMap(); - handle(SetupData(map["AdminUser"].toString(), map["AdminPasswd"].toString(), map["Backend"].toString(), map["ConnectionProperties"].toMap())); + handle(SetupData(map["AdminUser"].toString(), map["AdminPasswd"].toString(), map["Backend"].toString(), map["ConnectionProperties"].toMap(), map["Authenticator"].toString(), map["AuthProperties"].toMap())); } else if (msgType == "CoreSetupReject") { @@ -167,8 +178,10 @@ void DataStreamPeer::handleHandshakeMessage(const QVariantList &mapData) void DataStreamPeer::dispatch(const RegisterClient &msg) { QVariantMap m; m["MsgType"] = "ClientInit"; + m["Features"] = static_cast(msg.features.toLegacyFeatures()); + m["FeatureList"] = msg.features.toStringList(); m["ClientVersion"] = msg.clientVersion; - m["ClientDate"] = Quassel::buildInfo().buildDate; + m["ClientDate"] = msg.buildDate; writeMessage(m); } @@ -186,9 +199,17 @@ void DataStreamPeer::dispatch(const ClientDenied &msg) { void DataStreamPeer::dispatch(const ClientRegistered &msg) { QVariantMap m; m["MsgType"] = "ClientInitAck"; - m["CoreFeatures"] = msg.coreFeatures; - m["StorageBackends"] = msg.backendInfo; + if (hasFeature(Quassel::Feature::ExtendedFeatures)) { + m["FeatureList"] = msg.features.toStringList(); + } + else { + m["CoreFeatures"] = static_cast(msg.features.toLegacyFeatures()); + } m["LoginEnabled"] = m["Configured"] = msg.coreConfigured; + m["StorageBackends"] = msg.backendInfo; + if (hasFeature(Quassel::Feature::Authenticators)) { + m["Authenticators"] = msg.authenticatorInfo; + } writeMessage(m); } @@ -202,6 +223,10 @@ void DataStreamPeer::dispatch(const SetupData &msg) map["Backend"] = msg.backend; map["ConnectionProperties"] = msg.setupData; + // Auth backend properties. + map["Authenticator"] = msg.authenticator; + map["AuthProperties"] = msg.authSetupData; + QVariantMap m; m["MsgType"] = "CoreSetupData"; m["SetupData"] = map;