Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qsocks5socketengine.cpp File Reference

(d44d19dd98e20cb4163dea8e0fafb8f03bdc7f5c)

#include "qsocks5socketengine_p.h"
#include "qtcpsocket.h"
#include "qudpsocket.h"
#include "qtcpserver.h"
#include "qdebug.h"
#include "qhash.h"
#include "qqueue.h"
#include "qdeadlinetimer.h"
#include "qelapsedtimer.h"
#include "qmutex.h"
#include "qthread.h"
#include "qcoreapplication.h"
#include "qurl.h"
#include "qauthenticator.h"
#include "private/qiodevice_p.h"
#include "private/qringbuffer_p.h"
#include <qendian.h>
#include <qnetworkinterface.h>
#include <QtCore/qpointer.h>
#include <memory>
#include "moc_qsocks5socketengine_p.cpp"
+ Include dependency graph for qsocks5socketengine.cpp:

Go to the source code of this file.

Classes

struct  QSocks5Data
 
struct  QSocks5ConnectData
 
struct  QSocks5BindData
 
struct  QSocks5RevivedDatagram
 
struct  QSocks5UdpAssociateData
 
class  QSocks5BindStore
 

Macros

#define MAX_DATA_DUMP   256
 
#define Q_INIT_CHECK(returnValue)
 
#define S5_VERSION_5   0x05
 
#define S5_CONNECT   0x01
 
#define S5_BIND   0x02
 
#define S5_UDP_ASSOCIATE   0x03
 
#define S5_IP_V4   0x01
 
#define S5_DOMAINNAME   0x03
 
#define S5_IP_V6   0x04
 
#define S5_SUCCESS   0x00
 
#define S5_R_ERROR_SOCKS_FAILURE   0x01
 
#define S5_R_ERROR_CON_NOT_ALLOWED   0x02
 
#define S5_R_ERROR_NET_UNREACH   0x03
 
#define S5_R_ERROR_HOST_UNREACH   0x04
 
#define S5_R_ERROR_CONN_REFUSED   0x05
 
#define S5_R_ERROR_TTL   0x06
 
#define S5_R_ERROR_CMD_NOT_SUPPORTED   0x07
 
#define S5_R_ERROR_ADD_TYPE_NOT_SUPORTED   0x08
 
#define S5_AUTHMETHOD_NONE   0x00
 
#define S5_AUTHMETHOD_PASSWORD   0x02
 
#define S5_AUTHMETHOD_NOTACCEPTABLE   0xFF
 
#define S5_PASSWORDAUTH_VERSION   0x01
 
#define QSOCKS5_DEBUG   if (0) qDebug()
 
#define QSOCKS5_Q_DEBUG   if (0) qDebug()
 
#define QSOCKS5_D_DEBUG   if (0) qDebug()
 

Functions

static QString dump (const QByteArray &)
 
static bool qt_socks5_set_host_address_and_port (const QHostAddress &address, quint16 port, QByteArray *pBuf)
 
static bool qt_socks5_set_host_name_and_port (const QString &hostname, quint16 port, QByteArray *pBuf)
 
static int qt_socks5_get_host_address_and_port (const QByteArray &buf, QHostAddress *pAddress, quint16 *pPort, int *pPos)
 
static int nextDescriptor ()
 

Variables

static const int MaxWriteBufferSize = 128*1024
 
static constexpr auto Socks5BlockingBindTimeout = 5s
 
static QString s5StateToString (QSocks5SocketEnginePrivate::Socks5State)
 

Macro Definition Documentation

◆ MAX_DATA_DUMP

#define MAX_DATA_DUMP   256

Definition at line 37 of file qsocks5socketengine.cpp.

◆ Q_INIT_CHECK

#define Q_INIT_CHECK ( returnValue)
Value:
do { \
if (!d->data) { \
return returnValue; \
} } while (0)

Definition at line 40 of file qsocks5socketengine.cpp.

Referenced by QSocks5SocketEngine::hasPendingDatagrams().

◆ QSOCKS5_D_DEBUG

◆ QSOCKS5_DEBUG

◆ QSOCKS5_Q_DEBUG

◆ S5_AUTHMETHOD_NONE

#define S5_AUTHMETHOD_NONE   0x00

◆ S5_AUTHMETHOD_NOTACCEPTABLE

#define S5_AUTHMETHOD_NOTACCEPTABLE   0xFF

◆ S5_AUTHMETHOD_PASSWORD

#define S5_AUTHMETHOD_PASSWORD   0x02

Definition at line 63 of file qsocks5socketengine.cpp.

◆ S5_BIND

#define S5_BIND   0x02

◆ S5_CONNECT

#define S5_CONNECT   0x01

◆ S5_DOMAINNAME

#define S5_DOMAINNAME   0x03

◆ S5_IP_V4

#define S5_IP_V4   0x01

◆ S5_IP_V6

#define S5_IP_V6   0x04

◆ S5_PASSWORDAUTH_VERSION

#define S5_PASSWORDAUTH_VERSION   0x01

◆ S5_R_ERROR_ADD_TYPE_NOT_SUPORTED

#define S5_R_ERROR_ADD_TYPE_NOT_SUPORTED   0x08

Definition at line 60 of file qsocks5socketengine.cpp.

◆ S5_R_ERROR_CMD_NOT_SUPPORTED

#define S5_R_ERROR_CMD_NOT_SUPPORTED   0x07

Definition at line 59 of file qsocks5socketengine.cpp.

◆ S5_R_ERROR_CON_NOT_ALLOWED

#define S5_R_ERROR_CON_NOT_ALLOWED   0x02

Definition at line 54 of file qsocks5socketengine.cpp.

◆ S5_R_ERROR_CONN_REFUSED

#define S5_R_ERROR_CONN_REFUSED   0x05

Definition at line 57 of file qsocks5socketengine.cpp.

◆ S5_R_ERROR_HOST_UNREACH

#define S5_R_ERROR_HOST_UNREACH   0x04

Definition at line 56 of file qsocks5socketengine.cpp.

◆ S5_R_ERROR_NET_UNREACH

#define S5_R_ERROR_NET_UNREACH   0x03

Definition at line 55 of file qsocks5socketengine.cpp.

◆ S5_R_ERROR_SOCKS_FAILURE

#define S5_R_ERROR_SOCKS_FAILURE   0x01

Definition at line 53 of file qsocks5socketengine.cpp.

◆ S5_R_ERROR_TTL

#define S5_R_ERROR_TTL   0x06

Definition at line 58 of file qsocks5socketengine.cpp.

◆ S5_SUCCESS

#define S5_SUCCESS   0x00

◆ S5_UDP_ASSOCIATE

#define S5_UDP_ASSOCIATE   0x03

◆ S5_VERSION_5

Function Documentation

◆ dump()

◆ nextDescriptor()

static int nextDescriptor ( )
static

Definition at line 968 of file qsocks5socketengine.cpp.

References QBasicAtomicInteger< T >::fetchAndAddRelaxed().

Referenced by QSocks5SocketEngine::initialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qt_socks5_get_host_address_and_port()

static int qt_socks5_get_host_address_and_port ( const QByteArray & buf,
QHostAddress * pAddress,
quint16 * pPort,
int * pPos )
static

Definition at line 185 of file qsocks5socketengine.cpp.

References add(), i, pos, qDebug, QSOCKS5_DEBUG, ret, S5_DOMAINNAME, S5_IP_V4, and S5_IP_V6.

Referenced by QSocks5SocketEnginePrivate::_q_udpSocketReadNotification(), and QSocks5SocketEnginePrivate::parseRequestMethodReply().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qt_socks5_set_host_address_and_port()

static bool qt_socks5_set_host_address_and_port ( const QHostAddress & address,
quint16 port,
QByteArray * pBuf )
static

Definition at line 121 of file qsocks5socketengine.cpp.

References QByteArray::fromRawData(), QAbstractSocket::IPv4Protocol, QAbstractSocket::IPv6Protocol, ptr(), QSOCKS5_DEBUG, S5_IP_V4, and S5_IP_V6.

Referenced by QSocks5SocketEnginePrivate::sendRequestMethod(), and QSocks5SocketEngine::writeDatagram().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qt_socks5_set_host_name_and_port()

static bool qt_socks5_set_host_name_and_port ( const QString & hostname,
quint16 port,
QByteArray * pBuf )
static

Definition at line 154 of file qsocks5socketengine.cpp.

References QByteArray::append(), QByteArray::fromRawData(), ptr(), QSOCKS5_DEBUG, S5_DOMAINNAME, and QUrl::toAce().

Referenced by QSocks5SocketEnginePrivate::sendRequestMethod().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ MaxWriteBufferSize

const int MaxWriteBufferSize = 128*1024
static

◆ s5StateToString

◆ Socks5BlockingBindTimeout

constexpr auto Socks5BlockingBindTimeout = 5s
staticconstexpr

Definition at line 38 of file qsocks5socketengine.cpp.