X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fidentserver.h;h=3a2051aa0a20e9db656e9947cab85a27613102fe;hb=145a52eb79fed146731f85c23b60f0609e40e785;hp=5aa827373790d61a51bda8df762f9e92c7a6a9d2;hpb=9451580d19875b23ec52af64585496efb7268e0f;p=quassel.git diff --git a/src/core/identserver.h b/src/core/identserver.h index 5aa82737..3a2051aa 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-2020 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -20,32 +20,77 @@ #pragma once +#include + +#include +#include +#include +#include #include #include #include "coreidentity.h" -class IdentServer : public QObject { -Q_OBJECT +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); + + void respondSuccess(const QString& user); + void respondError(const QString& error); + + const static int DISCONNECTION_TIMEOUT = 500; +}; + +class IdentServer : public QObject +{ + Q_OBJECT + public: - IdentServer(bool strict, QObject *parent); - ~IdentServer(); + 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); - bool removeSocket(const CoreIdentity *identity, const QHostAddress &localAddress, quint16 localPort, const QHostAddress &peerAddress, quint16 peerPort); + 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: - QTcpServer _server, _v6server; + bool responseAvailable(Request request) const; + + qint64 lowestSocketId() const; - bool _strict; + void processWaiting(qint64 socketId); + + void removeWaitingSocket(qint64 socketId); + + QTcpServer _server, _v6server; QHash _connections; + std::list _requestQueue; + std::list _waiting; + qint64 _socketId{0}; + qint64 _requestId{0}; };