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