QXmpp Version: 1.4.0
Loading...
Searching...
No Matches
QXmppSocks.h
1/*
2 * Copyright (C) 2008-2021 The QXmpp developers
3 *
4 * Author:
5 * Jeremy Lainé
6 *
7 * Source:
8 * https://github.com/qxmpp-project/qxmpp
9 *
10 * This file is a part of QXmpp library.
11 *
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
16 *
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
21 *
22 */
23
24#ifndef QXMPPSOCKS_H
25#define QXMPPSOCKS_H
26
27#include "QXmppGlobal.h"
28
29#include <QHostAddress>
30#include <QTcpSocket>
31
32class QTcpServer;
33
34class QXMPP_EXPORT QXmppSocksClient : public QTcpSocket
35{
36 Q_OBJECT
37
38public:
39 QXmppSocksClient(const QString &proxyHost, quint16 proxyPort, QObject *parent = nullptr);
40 void connectToHost(const QString &hostName, quint16 hostPort);
41
42Q_SIGNALS:
43 void ready();
44
45private Q_SLOTS:
46 void slotConnected();
47 void slotReadyRead();
48
49private:
50 QString m_proxyHost;
51 quint16 m_proxyPort;
52 QString m_hostName;
53 quint16 m_hostPort;
54 int m_step;
55};
56
57class QXMPP_EXPORT QXmppSocksServer : public QObject
58{
59 Q_OBJECT
60
61public:
62 QXmppSocksServer(QObject *parent = nullptr);
63 void close();
64 bool listen(quint16 port = 0);
65
66 quint16 serverPort() const;
67
68Q_SIGNALS:
69 void newConnection(QTcpSocket *socket, QString hostName, quint16 port);
70
71private Q_SLOTS:
72 void slotNewConnection();
73 void slotReadyRead();
74
75private:
76 QTcpServer *m_server;
77 QTcpServer *m_server_v6;
78 QMap<QTcpSocket *, int> m_states;
79};
80
81#endif