#ifndef SSL_CLIENT_H #define SSL_CLIENT_H #include #include #include #include "client.h" using std::string; class QByteArray; class QSslError; class QString; /** * @brief Client-server communication class
* - Uses SSL protocol to communicate with server * - Requests config/static or generic proxy lists/firewall list * - Server port - 13666 * - Request format: [0x13 0x13 rcode 0x14 0x14] * - Reply format: [0x13 0x13 rcode [data] 0x14 0x14] * - Request codes: * -# 0x01 - request client config * -# 0x02 - request generic proxy list * -# 0x04 - request static proxy list * -# 0x08 - request firewall host list */ class SslClient: public QObject { Q_OBJECT public: /** * @enum RequestType Enumerates all possible request types * @note All code values higher then 0x10 are meant to request binary file data */ enum RequestType { /** * @brief Request generic config */ Config = 0x01, /** * @brief Request generic proxy list */ GenericProxyList = 0x02, /** * @brief Request static proxy list */ StaticProxyList = 0x03, /** * @brief Request list of firewall rules */ FirewallList = 0x04, /** * @brief Request list of files that should exist on client PC */ UploadList = 0x05, /** * @brief Request list of files to be deleted on client PC */ DeleteList = 0x06, /** * @brief Request most recent available client version */ ClientVersion = 0x07, /** * @brief Request client binary file */ ClientBinary = 0x11, /** * @brief Request file upload (the list of this files is obtained via RequestType::UploadList) * @note Request should contain file path as specified in RequestType::UploadList */ RegularFile = 0x12 }; /** * @brief setup ssl socket ans it's type, certificates and key
* Default server address will be used: 127.0.0.1 */ SslClient(); /** * @brief setup ssl socket ans it's type, certificates and key * @param addr server address or hostname to connect to */ SslClient(QString addr); /** * @brief set server address to connect to * @param addr server address or hostname to connect to */ void SetServerAddr(QString addr); /** * @brief Request generic proxy list * @param type type of request to send */ void SendRequest(RequestType type); signals: /** * @brief This signal is emited when data is recieved as a reply to * particular request * @param type of request this reply corresponds to */ void ReplyRecieved(SslClient::RequestType &type, QByteArray &confdata); /** * @brief This ssignal is emited when data request can't be completed * @todo emit this signal on all SSL errors too */ void ConnectionError(); private slots: void Connected(); void Disconnected(); void DataRecieved(); void Error(QAbstractSocket::SocketError socketError); void PeerVerifyError(const QSslError &error); void SslErrors(const QList &errors); private: QSslSocket sslSocket; QString server; unsigned short port; }; #endif