71 #define MAX_DATA_DUMP 256 72 #if !defined(Q_OS_WINCE) 73 #define SOCKS5_BLOCKING_BIND_TIMEOUT 5000 75 #define SOCKS5_BLOCKING_BIND_TIMEOUT 10000 78 #define Q_INIT_CHECK(returnValue) do { \ 83 #define S5_VERSION_5 0x05 84 #define S5_CONNECT 0x01 86 #define S5_UDP_ASSOCIATE 0x03 88 #define S5_DOMAINNAME 0x03 90 #define S5_SUCCESS 0x00 91 #define S5_R_ERROR_SOCKS_FAILURE 0x01 92 #define S5_R_ERROR_CON_NOT_ALLOWED 0x02 93 #define S5_R_ERROR_NET_UNREACH 0x03 94 #define S5_R_ERROR_HOST_UNREACH 0x04 95 #define S5_R_ERROR_CONN_REFUSED 0x05 96 #define S5_R_ERROR_TTL 0x06 97 #define S5_R_ERROR_CMD_NOT_SUPPORTED 0x07 98 #define S5_R_ERROR_ADD_TYPE_NOT_SUPORTED 0x08 100 #define S5_AUTHMETHOD_NONE 0x00 101 #define S5_AUTHMETHOD_PASSWORD 0x02 102 #define S5_AUTHMETHOD_NOTACCEPTABLE 0xFF 104 #define S5_PASSWORDAUTH_VERSION 0x01 106 #ifdef QSOCKS5SOCKETLAYER_DEBUG 107 # define QSOCKS5_Q_DEBUG qDebug() << this 108 # define QSOCKS5_D_DEBUG qDebug() << q_ptr 109 # define QSOCKS5_DEBUG qDebug() << "[QSocks5]" 136 uint val = (
unsigned char)buf.
at(i);
147 # define QSOCKS5_DEBUG if (0) qDebug() 148 # define QSOCKS5_Q_DEBUG if (0) qDebug() 149 # define QSOCKS5_D_DEBUG if (0) qDebug() 161 QSOCKS5_DEBUG <<
"setting [" << address <<
':' << port <<
']';
184 data.port = qToBigEndian<quint16>(port);
194 QSOCKS5_DEBUG <<
"setting [" << hostname <<
':' << port <<
']';
199 if (encodedHostName.
length() > 255)
204 buf.
append(encodedHostName);
211 data.port = qToBigEndian<quint16>(port);
226 const unsigned char *pBuf =
reinterpret_cast<const unsigned char*
>(buf.
constData());
230 if (buf.
size() - pos < 1) {
236 if (buf.
size() - pos < 4) {
245 if (buf.
size() - pos < 16) {
250 for (
int i = 0; i < 16; ++i)
256 qDebug() <<
"skipping hostname of len" <<
uint(pBuf[pos]);
257 pos +=
uchar(pBuf[pos]);
264 if (buf.
size() - pos < 2) {
292 return timeout < 0 ? 0 : timeout;
322 #ifndef QT_NO_UDPSOCKET 340 bool contains(
int socketDescriptor);
355 : mutex(
QMutex::Recursive)
359 if (app && app->
thread() != thread())
360 moveToThread(app->
thread());
370 if (
store.contains(socketDescriptor)) {
374 store.insert(socketDescriptor, bindData);
376 if (sweepTimerId == -1)
377 sweepTimerId = startTimer(60000);
383 return store.contains(socketDescriptor);
389 if (!
store.contains(socketDescriptor))
394 qWarning(
"Can not access socks5 bind data from different thread");
401 if (
store.isEmpty()) {
402 killTimer(sweepTimerId);
411 if (event->
timerId() == sweepTimerId) {
413 QMutableHashIterator<int, QSocks5BindData *>
it(
store);
414 while (it.hasNext()) {
416 if (it.value()->timeStamp.hasExpired(350000)) {
465 return unSeal(sealedSocket->
readAll(), buf);
470 this->userName = userName;
471 this->password = password;
485 char *buf = dataBuf.
data();
488 buf[pos++] = uname.
size();
489 memcpy(&buf[pos], uname.
data(), uname.
size());
491 buf[pos++] = passwd.
size();
492 memcpy(&buf[pos], passwd.
data(), passwd.
size());
493 return socket->
write(dataBuf) == dataBuf.size();
516 return QLatin1String(
"Socks5 user name or password incorrect");
523 , readNotificationEnabled(false)
524 , writeNotificationEnabled(false)
525 , exceptNotificationEnabled(false)
526 , socketDescriptor(-1)
533 , readNotificationActivated(false)
534 , writeNotificationActivated(false)
535 , readNotificationPending(false)
536 , writeNotificationPending(false)
537 , connectionNotificationPending(false)
554 #ifndef QT_NO_UDPSOCKET 559 #ifndef QT_NO_BEARERMANAGEMENT 566 #endif // QT_NO_UDPSOCKET 573 #ifndef QT_NO_BEARERMANAGEMENT 620 switch (controlSocketError) {
679 switch (socks5error) {
732 QSOCKS5_DEBUG <<
"authentication failure: retrying connection";
768 bool authComplete =
false;
790 bool authComplete =
false;
813 #ifndef QT_NO_UDPSOCKET 826 QSOCKS5_DEBUG <<
"error setting address" << address <<
" : " << port;
830 QSOCKS5_DEBUG <<
"error setting address" << address <<
" : " << port;
856 if (inBuf.
size() < 2) {
857 QSOCKS5_DEBUG <<
"need more data for request reply header .. put this data somewhere";
885 for (
int i = inBuf.
size() - 1; i >= 0 ; --i)
926 emit q->readNotification();
955 emit q->writeNotification();
975 emit q->connectionNotification();
996 delete d->data->authenticator;
997 delete d->data->controlSocket;
1000 delete d->connectData;
1001 #ifndef QT_NO_UDPSOCKET 1003 delete d->udpData->udpSocket;
1019 d->socketType =
type;
1038 QSocks5BindData *bindData = socks5BindStore()->retrieve(socketDescriptor);
1044 d->data =
d->connectData;
1048 d->data->controlSocket->setParent(
this);
1049 d->socketProtocol =
d->data->controlSocket->localAddress().protocol();
1074 if (
d->data->controlSocket->bytesAvailable() != 0)
1075 d->_q_controlSocketReadNotification();
1084 d->proxyInfo = networkProxy;
1090 return d->socketDescriptor;
1110 #ifndef QT_NO_UDPSOCKET 1121 qFatal(
"QSocks5SocketEngine::connectToHost: in QTcpServer mode");
1130 d->data->controlSocket->setReadBufferSize(65536);
1131 d->data->controlSocket->connectToHost(
d->proxyInfo.hostName(),
d->proxyInfo.port());
1144 d->peerName.clear();
1155 d->peerName = hostname;
1166 buf[2] =
data->authenticator->methodId();
1167 data->controlSocket->write(buf);
1168 socks5State = AuthenticationMethodsSent;
1174 <<
"bytes available" <<
data->controlSocket->bytesAvailable();
1176 if (
data->controlSocket->bytesAvailable() == 0) {
1177 QSOCKS5_D_DEBUG <<
"########## bogus read why do we get these ... on windows only";
1181 switch (socks5State) {
1182 case AuthenticationMethodsSent:
1183 parseAuthenticationMethodReply();
1185 case Authenticating:
1186 parseAuthenticatingReply();
1188 case RequestMethodSent:
1189 parseRequestMethodReply();
1193 if (!
data->authenticator->unSeal(
data->controlSocket, &buf)) {
1198 connectData->readBuffer += buf;
1199 emitReadNotification();
1205 if (mode == BindMode) {
1206 parseRequestMethodReply();
1212 qWarning(
"QSocks5SocketEnginePrivate::_q_controlSocketReadNotification: " 1213 "Unexpectedly received data while in state=%d and mode=%d",
1223 if (socks5State != Connected
1224 || (mode == ConnectMode
1225 &&
data->controlSocket->bytesToWrite()))
1228 emitWriteNotification();
1229 writeNotificationActivated =
false;
1241 && socks5State == Connected) {
1244 if (!readNotificationPending)
1245 connectData->readBuffer.clear();
1246 emitReadNotification();
1247 data->controlSocket->close();
1249 emitWriteNotification();
1251 || socks5State == AuthenticationMethodsSent
1252 || socks5State == Authenticating
1253 || socks5State == RequestMethodSent) {
1254 setErrorState(socks5State ==
Uninitialized ? ConnectError : ControlSocketError);
1255 data->controlSocket->close();
1256 emitConnectionNotification();
1258 q_func()->setError(
data->controlSocket->error(),
data->controlSocket->errorString());
1259 emitReadNotification();
1260 emitWriteNotification();
1274 #ifndef QT_NO_UDPSOCKET 1278 if (udpData->udpSocket->hasPendingDatagrams())
1279 const_cast<QSocks5SocketEnginePrivate *>(
this)->_q_udpSocketReadNotification();
1287 if (!udpData->udpSocket->hasPendingDatagrams()) {
1292 while (udpData->udpSocket->hasPendingDatagrams()) {
1293 QByteArray sealedBuf(udpData->udpSocket->pendingDatagramSize(), 0);
1295 udpData->udpSocket->readDatagram(sealedBuf.data(), sealedBuf.size());
1297 if (!
data->authenticator->unSeal(sealedBuf, &inBuf)) {
1298 QSOCKS5_D_DEBUG <<
"failed unsealing datagram discarding";
1304 if (inBuf.
size() < 4) {
1305 QSOCKS5_D_DEBUG <<
"bugus udp data, discarding";
1309 if (buf[pos++] != 0 || buf[pos++] != 0) {
1310 QSOCKS5_D_DEBUG <<
"invalid datagram discarding";
1313 if (buf[pos++] != 0) {
1314 QSOCKS5_D_DEBUG <<
"don't support fragmentation yet disgarding";
1318 QSOCKS5_D_DEBUG <<
"failed to get address from datagram disgarding";
1322 udpData->pendingDatagrams.enqueue(datagram);
1324 emitReadNotification();
1326 #endif // QT_NO_UDPSOCKET 1337 #ifndef QT_NO_UDPSOCKET 1347 #ifndef QT_NO_UDPSOCKET 1349 if (!
d->udpData->udpSocket->bind(address, port)) {
1351 setError(
d->udpData->udpSocket->error(),
d->udpData->udpSocket->errorString());
1354 d->localAddress =
d->udpData->udpSocket->localAddress();
1355 d->localPort =
d->udpData->udpSocket->localPort();
1359 d->localAddress = address;
1360 d->localPort = port;
1369 d->data->controlSocket->connectToHost(
d->proxyInfo.hostName(),
d->proxyInfo.port());
1370 if (!
d->waitForConnected(msecs, 0) ||
1373 QSOCKS5_Q_DEBUG <<
"waitForConnected to proxy server" <<
d->data->controlSocket->errorString();
1379 #ifndef QT_NO_UDPSOCKET 1382 d->udpData->associateAddress =
d->localAddress;
1384 d->udpData->associatePort =
d->localPort;
1387 #ifndef QT_NO_BEARERMANAGEMENT 1394 || dummy.
readDatagram(0,0, &
d->localAddress, &
d->localPort) != 0) {
1395 QSOCKS5_DEBUG <<
"udp actual address and port lookup failed";
1398 d->data->controlSocket->close();
1402 QSOCKS5_DEBUG <<
"udp actual address and port" <<
d->localAddress <<
':' <<
d->localPort;
1404 #endif // QT_NO_UDPSOCKET 1429 d->emitReadNotification();
1444 QSOCKS5_Q_DEBUG <<
"BindSuccess adding" <<
d->socketDescriptor <<
"to the bind store";
1445 d->data->controlSocket->disconnect();
1446 d->data->controlSocket->setParent(0);
1447 d->bindData->localAddress =
d->localAddress;
1448 d->bindData->localPort =
d->localPort;
1449 int sd =
d->socketDescriptor;
1450 socks5BindStore()->add(sd,
d->bindData);
1453 d->socketDescriptor = 0;
1467 if (
d->data &&
d->data->controlSocket) {
1472 while (!
d->data->controlSocket->bytesToWrite()) {
1477 d->data->controlSocket->close();
1479 #ifndef QT_NO_UDPSOCKET 1480 if (
d->udpData &&
d->udpData->udpSocket)
1481 d->udpData->udpSocket->close();
1489 return d->connectData->readBuffer.size();
1490 #ifndef QT_NO_UDPSOCKET 1492 && !
d->udpData->pendingDatagrams.isEmpty())
1493 return d->udpData->pendingDatagrams.first().data.size();
1503 if (
d->connectData->readBuffer.size() == 0) {
1515 qint64 copy = qMin<qint64>(
d->connectData->readBuffer.size(), maxlen);
1516 memcpy(data,
d->connectData->readBuffer.constData(), copy);
1517 d->connectData->readBuffer.remove(0, copy);
1520 #ifndef QT_NO_UDPSOCKET 1541 if (!
d->data->authenticator->seal(buf, &sealedBuf)) {
1545 qint64 written =
d->data->controlSocket->write(sealedBuf);
1550 d->data->controlSocket->waitForBytesWritten(0);
1553 #ifndef QT_NO_UDPSOCKET 1563 #ifndef QT_NO_UDPSOCKET 1564 #ifndef QT_NO_NETWORKINTERFACE 1593 #endif // QT_NO_NETWORKINTERFACE 1600 d->checkForDatagrams();
1602 if (
d->udpData->pendingDatagrams.isEmpty())
1606 int copyLen = qMin<int>(maxlen, datagram.
data.
size());
1611 *port = datagram.
port;
1640 if (!
d->data->authenticator->seal(outBuf, &sealedBuf)) {
1645 if (
d->udpData->udpSocket->writeDatagram(sealedBuf,
d->udpData->associateAddress,
d->udpData->associatePort) != sealedBuf.
size()) {
1648 setError(
d->udpData->udpSocket->error(),
d->udpData->udpSocket->errorString());
1661 d->checkForDatagrams();
1663 return !
d->udpData->pendingDatagrams.isEmpty();
1670 d->checkForDatagrams();
1672 if (!
d->udpData->pendingDatagrams.isEmpty())
1673 return d->udpData->pendingDatagrams.head().data.size();
1676 #endif // QT_NO_UDPSOCKET 1681 if (
d->data &&
d->data->controlSocket) {
1682 return d->data->controlSocket->bytesToWrite();
1691 if (
d->data &&
d->data->controlSocket) {
1704 if (
d->data &&
d->data->controlSocket) {
1721 mode == ConnectMode ? Connected :
1722 mode == BindMode ? BindSuccess :
1723 UdpAssociateSuccess;
1728 while (socks5State != wantedState) {
1748 d->readNotificationActivated =
false;
1754 if (!
d->waitForConnected(msecs, timedOut))
1762 while (!
d->readNotificationActivated) {
1767 setError(
d->data->controlSocket->error(),
d->data->controlSocket->errorString());
1773 #ifndef QT_NO_UDPSOCKET 1775 while (!
d->readNotificationActivated) {
1777 setError(
d->udpData->udpSocket->error(),
d->udpData->udpSocket->errorString());
1783 #endif // QT_NO_UDPSOCKET 1787 bool ret =
d->readNotificationActivated;
1788 d->readNotificationActivated =
false;
1804 if (!
d->waitForConnected(msecs, timedOut))
1812 if (
d->data->controlSocket->bytesToWrite())
1814 while ((msecs == -1 || stopWatch.
elapsed() < msecs)
1822 bool checkRead,
bool checkWrite,
1823 int msecs,
bool *timedOut)
1829 *readyToRead = canRead;
1835 *readyToWrite = canWrite;
1842 return d->readNotificationEnabled;
1851 bool emitSignal =
false;
1852 if (!
d->readNotificationEnabled
1855 emitSignal = !
d->connectData->readBuffer.isEmpty();
1856 #ifndef QT_NO_UDPSOCKET 1858 emitSignal = !
d->udpData->pendingDatagrams.isEmpty();
1866 d->readNotificationEnabled = enable;
1869 d->emitReadNotification();
1875 return d->writeNotificationEnabled;
1881 d->writeNotificationEnabled = enable;
1885 d->emitWriteNotification();
1886 d->writeNotificationActivated =
false;
1893 return d->exceptNotificationEnabled;
1899 d->exceptNotificationEnabled = enable;
1915 return engine.
take();
1921 if (socks5BindStore()->contains(socketDescriptor)) {
1928 #endif // QT_NO_SOCKS5 static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QNetworkProxy::ProxyType type() const
Returns the proxy type for this instance.
void _q_controlSocketStateChanged(QAbstractSocket::SocketState)
bool joinMulticastGroup(const QHostAddress &groupAddress, const QNetworkInterface &interface)
QTcpSocket * controlSocket
bool connectToHost(const QHostAddress &address, quint16 port)
bool blockSignals(bool b)
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke...
bool setOption(SocketOption option, int value)
qint64 bytesAvailable() const
The QUdpSocket class provides a UDP socket.
Q_IPV6ADDR toIPv6Address() const
Returns the IPv6 address as a Q_IPV6ADDR structure.
static double elapsed(qint64 after, qint64 before)
#define QT_END_NAMESPACE
This macro expands to.
SocketType
This enum describes the transport layer protocol.
virtual bool continueAuthenticate(QTcpSocket *socket, bool *completed)
The QMutex class provides access serialization between threads.
bool waitForReadyRead(int msecs=30000)
This function blocks until new data is available for reading and the QIODevice::readyRead() signal ha...
char * data()
Returns a pointer to the data stored in the byte array.
bool hasPendingDatagrams() const
qint64 bytesAvailable() const
Returns the number of incoming bytes that are waiting to be read.
bool flush()
This function writes as much as possible from the internal write buffer to the underlying network soc...
bool readNotificationActivated
bool setMulticastInterface(const QNetworkInterface &iface)
#define it(className, varName)
QByteArray & append(char c)
Appends the character ch to this byte array.
#define S5_AUTHMETHOD_NOTACCEPTABLE
QSocks5SocketEnginePrivate()
bool isExceptionNotificationEnabled() const
bool leaveMulticastGroup(const QHostAddress &groupAddress, const QNetworkInterface &interface)
void connectToHost(const QString &hostName, quint16 port, OpenMode mode=ReadWrite)
Attempts to make a connection to hostName on the given port.
The QByteArray class provides an array of bytes.
T * take()
Returns the value of the pointer referenced by this object.
QString errorString() const
Returns a human-readable description of the last device error that occurred.
void _q_emitPendingReadNotification()
void emitConnectionNotification()
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object's name property to value.
void setPeerAddress(const QHostAddress &address)
static const int MaxWriteBufferSize
QSocks5UdpAssociateData * udpData
#define QT_TRANSLATE_NOOP(scope, x)
Marks the string literal sourceText for dynamic translation in the given context; i...
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void setState(QAbstractSocket::SocketState state)
QSocks5BindData * bindData
void setUser(const QString &userName)
Sets the user name for proxy authentication to be user.
bool contains(int socketDescriptor)
quint32 qFromBigEndian< quint32 >(const uchar *src)
quint32 toIPv4Address() const
Returns the IPv4 address as a number.
NetworkLayerProtocol
This enum describes the network layer protocol values used in Qt.
bool bind(const QHostAddress &address, quint16 port)
void ungetChar(char c)
Puts the character c back into the device, and decrements the current position unless the position is...
void abort()
Aborts the current connection and resets the socket.
The QString class provides a Unicode character string.
The QHash class is a template class that provides a hash-table-based dictionary.
The QObject class is the base class of all Qt objects.
#define Q_BASIC_ATOMIC_INITIALIZER(a)
bool isWriteNotificationEnabled() const
The QElapsedTimer class provides a fast way to calculate elapsed times.
qint64 bytesToWrite() const
bool waitForRead(int msecs=30000, bool *timedOut=0)
qint64 elapsed() const
Returns the number of milliseconds since this QElapsedTimer was last started.
The QPointer class is a template class that provides guarded pointers to QObject. ...
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
bool bind(const QHostAddress &address, quint16 port)
Binds this socket to the address address and the port port.
~QSocks5SocketEnginePrivate()
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read...
SocketState
This enum describes the different states in which a socket can be.
int socketDescriptor() const
void timerEvent(QTimerEvent *event)
This event handler can be reimplemented in a subclass to receive timer events for the object...
Q_CORE_EXPORT void qDebug(const char *,...)
The QNetworkProxy class provides a network layer proxy.
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
static QByteArray toAce(const QString &)
Returns the ASCII Compatible Encoding of the given domain name domain.
void add(int socketDescriptor, QSocks5BindData *bindData)
#define QT_BEGIN_NAMESPACE
This macro expands to.
static QIntfbScreen * connected
bool connectionNotificationPending
void setError(QAbstractSocket::SocketError error, const QString &errorString) const
void setPeerPort(quint16 port)
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
bool waitForWrite(int msecs=30000, bool *timedOut=0)
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QQueue< QSocks5RevivedDatagram > pendingDatagrams
qint64 writeDatagram(const char *data, qint64 len, const QHostAddress &addr, quint16 port)
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
virtual bool unSeal(const QByteArray sealedBuf, QByteArray *buf)
static bool qt_socks5_get_host_address_and_port(const QByteArray &buf, QHostAddress *pAddress, quint16 *pPort, int *pPos)
SocketError
This enum describes the socket errors that can occur.
static QByteArray fromRawData(const char *, int size)
Constructs a QByteArray that uses the first size bytes of the data array.
bool writeNotificationPending
Q_CORE_EXPORT void qWarning(const char *,...)
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
bool continueAuthenticate(QTcpSocket *socket, bool *completed)
static const char * data(const QByteArray &arr)
QSocks5Authenticator * authenticator
QSocks5SocketEngine(QObject *parent=0)
bool connectToHostByName(const QString &name, quint16 port)
The QTcpSocket class provides a TCP socket.
void setProxy(const QNetworkProxy &networkProxy)
const T * ptr(const T &t)
QAbstractSocket::SocketError socketError
bool readNotificationEnabled
void close()
Closes the I/O device for the socket, disconnects the socket's connection with the host...
The QAuthenticator class provides an authentication object.
void _q_emitPendingConnectionNotification()
void initialize(Socks5Mode socks5Mode)
quint16 qFromBigEndian< quint16 >(const uchar *src)
void _q_controlSocketDisconnected()
int length() const
Same as size().
void emitReadNotification()
const char * constData() const
Returns a pointer to the data stored in the byte array.
bool writeNotificationActivated
void checkForDatagrams() const
Q_CORE_EXPORT void qFatal(const char *,...)
The QCoreApplication class provides an event loop for console Qt applications.
void setWriteNotificationEnabled(bool enable)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
void setProxy(const QNetworkProxy &networkProxy)
Sets the explicit network proxy for this socket to networkProxy.
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
static int qt_timeout_value(int msecs, int elapsed)
static bool qt_socks5_set_host_address_and_port(const QHostAddress &address, quint16 port, QByteArray *pBuf)
bool readNotificationPending
QAbstractSocket::NetworkLayerProtocol protocol() const
Returns the network layer protocol of the host address.
QHostAddress localAddress
qint64 pendingDatagramSize() const
void setAddress(quint32 ip4Addr)
Set the IPv4 address specified by ip4Addr.
void _q_controlSocketReadNotification()
quint16 localPort() const
Returns the host port number (in native byte order) of the local socket if available; otherwise retur...
The QTimerEvent class contains parameters that describe a timer event.
QHostAddress localAddress
void parseAuthenticationMethodReply()
static QCoreApplication * instance()
Returns a pointer to the application's QCoreApplication (or QApplication) instance.
virtual QAbstractSocketEngine * createSocketEngine(QAbstractSocket::SocketType socketType, const QNetworkProxy &, QObject *parent)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
#define SOCKS5_BLOCKING_BIND_TIMEOUT
QAbstractSocket::SocketError error() const
virtual ~QSocks5Authenticator()
QObject * parent() const
Returns a pointer to the parent object.
void parseRequestMethodReply()
QString user() const
returns the user used for authentication.
QHash< int, QSocks5BindData * > store
QAbstractSocket::NetworkLayerProtocol protocol() const
quint16 port() const
Returns the port of the proxy host.
QSocks5BindData * retrieve(int socketDescriptor)
static QReadWriteLock lock
int fetchAndAddRelaxed(int valueToAdd)
static QString s5StateToString(QSocks5SocketEnginePrivate::Socks5State)
QByteArray readAll()
Reads all available data from the device, and returns it as a QByteArray.
QNetworkInterface multicastInterface() const
static QString dump(const QByteArray &)
#define Q_INIT_CHECK(returnValue)
int size() const
Returns the number of bytes in this byte array.
#define S5_PASSWORDAUTH_VERSION
qint64 read(char *data, qint64 maxlen)
QVariant property(const char *name) const
Returns the value of the object's name property.
QString password() const
Returns the password used for authentication.
bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol=QAbstractSocket::IPv4Protocol)
QHostAddress associateAddress
static QBasicAtomicInt descriptorCounter
qint64 readDatagram(char *data, qint64 maxlen, QHostAddress *addr=0, quint16 *port=0)
void _q_udpSocketReadNotification()
void setReadNotificationEnabled(bool enable)
void _q_emitPendingWriteNotification()
virtual bool beginAuthenticate(QTcpSocket *socket, bool *completed)
The QNetworkInterface class provides a listing of the host's IP addresses and network interfaces...
bool writeNotificationEnabled
void emitWriteNotification()
bool waitForConnected(int msecs, bool *timedOut)
QThread * thread() const
Returns the thread in which the object lives.
The QHostAddress class provides an IP address.
QAbstractSocket::SocketState state() const
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
QString password() const
returns the password used for authentication.
QSocks5ConnectData * connectData
#define S5_AUTHMETHOD_NONE
QString user() const
Returns the user name used for authentication.
char at(int i) const
Returns the character at index position i in the byte array.
SocketError error() const
Returns the type of error that last occurred.
void reserve(int size)
Attempts to allocate memory for at least size bytes.
QAbstractSocket::SocketType socketType() const
bool waitForReadOrWrite(bool *readyToRead, bool *readyToWrite, bool checkRead, bool checkWrite, int msecs=30000, bool *timedOut=0)
void setPassword(const QString &password)
Sets the password for proxy authentication to be password.
void parseAuthenticatingReply()
void _q_controlSocketError(QAbstractSocket::SocketError)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
static bool qt_socks5_set_host_name_and_port(const QString &hostname, quint16 port, QByteArray *pBuf)
qint64 write(const char *data, qint64 len)
void start()
Starts this timer.
void _q_controlSocketBytesWritten()
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
qint64 readDatagram(char *data, qint64 maxlen, QHostAddress *host=0, quint16 *port=0)
Receives a datagram no larger than maxSize bytes and stores it in data.
QByteArray & remove(int index, int len)
Removes len bytes from the array, starting at index position pos, and returns a reference to the arra...
void clear()
Clears the contents of the byte array and makes it empty.
virtual bool seal(const QByteArray buf, QByteArray *sealedBuf)
int option(SocketOption option) const
SocketState state() const
Returns the state of the socket.
void setErrorState(Socks5State state, const QString &extraMessage=QString())
QSocks5PasswordAuthenticator(const QString &userName, const QString &password)
void _q_controlSocketConnected()
bool beginAuthenticate(QTcpSocket *socket, bool *completed)
void setExceptionNotificationEnabled(bool enable)
QString hostName() const
Returns the host name of the proxy host.
bool isReadNotificationEnabled() const