diff options
author | Alex <b0ris@b0ris-satellite.localdomain> | 2011-11-03 03:03:34 +0200 |
---|---|---|
committer | Alex <b0ris@b0ris-satellite.localdomain> | 2011-11-03 03:03:34 +0200 |
commit | c0c86b6cab64186e97285e1b5b1ef13062926d87 (patch) | |
tree | ed36333b7a1fa009356daabea6f63235297729ea /client/SslClient.h | |
parent | 19b9a0e1b46399c91872288eba25e1502231df06 (diff) |
Initial SslClient implementation
Diffstat (limited to 'client/SslClient.h')
-rw-r--r-- | client/SslClient.h | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/client/SslClient.h b/client/SslClient.h new file mode 100644 index 0000000..77c3ff3 --- /dev/null +++ b/client/SslClient.h @@ -0,0 +1,91 @@ + +#ifndef SSL_CLIENT_H +#define SSL_CLIENT_H + +#include <QAbstractSocket> +#include <QObject> + +class QSslSocket; +class QSslError; +class QString; + +/** + * @brief Client-server communication class<br/> + * - Uses SSL protocol to communicate with server + * - Requests config/static or generic proxy lists/firewall list + * - Server port - 13666 + * - Request format: [0x13 0x13 code 0x14 0x14] + * - Reply format: [0x13 0x13 code [data] 0x14 0x14] + * - Request codes: + */ +class SslClient: QObject +{ + Q_OBJECT +public: + /** + * @enum RequestType Enumerate all possible request types + */ + enum RequestType + { + /** + * @brief Request generic config + */ + Config = 0x01, + /** + * @brief Request generic proxy list + */ + GenericProxyList = 0x02, + /** + * @brief Request static proxy list + */ + StaticProxyList = 0x04, + /** + * @brief Request list of firewalled hosts + */ + FirewallList = 0x08 + }; + + /** + * @brief setup ssl socket ans it's type, certificates and key<br/> + * 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(char* addr); + + /** + * @brief set server address to connect to + * @param addr server address or hostname to connect to + */ + void SetServerAddr(char* 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(RequestType type); +private slots: + void Connected(); + void Disconnected(); + void DataRecieved(); + void Error(QAbstractSocket::SocketError socketError); + void PeerVerifyError(const QSslError &error); + void SslErrors(const QList<QSslError> &errors); +private: + QSslSocket *sslSocket; + QString server; + unsigned short port; +}; + +#endif
\ No newline at end of file |