QXmpp  Version: 1.6.0
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_SIGNALS:
24  void ready();
25 
26 private Q_SLOTS:
27  void slotConnected();
28  void slotReadyRead();
29 
30 private:
31  QString m_proxyHost;
32  quint16 m_proxyPort;
33  QString m_hostName;
34  quint16 m_hostPort;
35  int m_step;
36 };
37 
38 class QXMPP_EXPORT QXmppSocksServer : public QObject
39 {
40  Q_OBJECT
41 
42 public:
43  QXmppSocksServer(QObject *parent = nullptr);
44  void close();
45  bool listen(quint16 port = 0);
46 
47  quint16 serverPort() const;
48 
49 Q_SIGNALS:
50  void newConnection(QTcpSocket *socket, QString hostName, quint16 port);
51 
52 private Q_SLOTS:
53  void slotNewConnection();
54  void slotReadyRead();
55 
56 private:
57  QTcpServer *m_server;
58  QTcpServer *m_server_v6;
59  QMap<QTcpSocket *, int> m_states;
60 };
61 
62 #endif