X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fidentserver.h;h=6c7340db9a6f9d2d27b98639961d701b467c72c9;hp=4d4aecc5185214392b17dc6ffbdd90b40ca8f568;hb=8bdfd0d16857c508f543298ad98f6262127f2886;hpb=41b9d689945e784b160a25d12076600ff4b7ae90 diff --git a/src/core/identserver.h b/src/core/identserver.h index 4d4aecc5..6c7340db 100644 --- a/src/core/identserver.h +++ b/src/core/identserver.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2018 by the Quassel Project * + * Copyright (C) 2005-2019 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -20,45 +20,67 @@ #pragma once +#include + +#include +#include +#include +#include #include #include #include "coreidentity.h" -struct Request { - QTcpSocket *socket; +struct Request +{ + QPointer socket; uint16_t localPort; + uint16_t remotePort; QString query; qint64 transactionId; qint64 requestId; - friend bool operator==(const Request &a, const Request &b); + friend bool operator==(const Request& a, const Request& b); + + void respondSuccess(const QString& user); + void respondError(const QString& error); + + const static int DISCONNECTION_TIMEOUT = 500; }; -class IdentServer : public QObject { -Q_OBJECT +class IdentServer : public QObject +{ + Q_OBJECT + public: - IdentServer(bool strict, QObject *parent); - ~IdentServer() override; + IdentServer(QObject* parent = nullptr); bool startListening(); - void stopListening(const QString &msg); + void stopListening(const QString& msg); qint64 addWaitingSocket(); + public slots: - bool addSocket(const CoreIdentity *identity, const QHostAddress &localAddress, quint16 localPort, const QHostAddress &peerAddress, quint16 peerPort, qint64 socketId); - bool removeSocket(const CoreIdentity *identity, const QHostAddress &localAddress, quint16 localPort, const QHostAddress &peerAddress, quint16 peerPort, qint64 socketId); + void addSocket(const CoreIdentity* identity, + const QHostAddress& localAddress, + quint16 localPort, + const QHostAddress& peerAddress, + quint16 peerPort, + qint64 socketId); + void removeSocket(const CoreIdentity* identity, + const QHostAddress& localAddress, + quint16 localPort, + const QHostAddress& peerAddress, + quint16 peerPort, + qint64 socketId); private slots: void incomingConnection(); void respond(); private: - bool responseAvailable(Request request); - void responseUnavailable(Request request); - - QString sysIdentForIdentity(const CoreIdentity *identity) const; + bool responseAvailable(Request request) const; - bool hasSocketsBelowId(qint64 socketId); + qint64 lowestSocketId() const; void processWaiting(qint64 socketId); @@ -66,11 +88,9 @@ private: QTcpServer _server, _v6server; - bool _strict; - QHash _connections; std::list _requestQueue; std::list _waiting; - qint64 _socketId; - qint64 _requestId; + qint64 _socketId{0}; + qint64 _requestId{0}; };