QXmpp  Version: 1.15.1
QXmppSocks.h
1 // SPDX-FileCopyrightText: 2010 Jeremy LainĂ© <jeremy.laine@m4x.org>
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 
5 #ifndef QXMPPSOCKS_H
6 #define QXMPPSOCKS_H
7 
8 #include "QXmppGlobal.h"
9 
10 #include <QHostAddress>
11 #include <QTcpSocket>
12 
13 class QTcpServer;
14 
15 class QXMPP_EXPORT QXmppSocksClient : public QTcpSocket
16 {
17  Q_OBJECT
18 
19 public:
20  QXmppSocksClient(const QString &proxyHost, quint16 proxyPort, QObject *parent = nullptr);
21  void connectToHost(const QString &hostName, quint16 hostPort);
22 
23  Q_SIGNAL void ready();
24 
25 private:
26  Q_SLOT void slotConnected();
27  Q_SLOT void slotReadyRead();
28 
29  QString m_proxyHost;
30  quint16 m_proxyPort;
31  QString m_hostName;
32  quint16 m_hostPort;
33  int m_step;
34 };
35 
36 class QXMPP_EXPORT QXmppSocksServer : public QObject
37 {
38  Q_OBJECT
39 
40 public:
41  QXmppSocksServer(QObject *parent = nullptr);
42  void close();
43  bool listen(quint16 port = 0);
44 
45  quint16 serverPort() const;
46 
47  Q_SIGNAL void newConnection(QTcpSocket *socket, QString hostName, quint16 port);
48 
49 private:
50  Q_SLOT void slotNewConnection();
51  Q_SLOT void slotReadyRead();
52 
53  QTcpServer *m_server;
54  QTcpServer *m_server_v6;
55  QMap<QTcpSocket *, int> m_states;
56 };
57 
58 #endif