QSocks5SocketEngine: Always try to connect in connectToHost unless already connecting.

Otherwise, connectInternal becomes a no-op after an initial connection attempt
has been made (making the socket effectively useless if that connection attempt
fails).

A workaround is to close() the socket, which worked by virtue of
QAbstractSocket's close() disconnecting (which ultimately calls
resetSocketLayer, and destroys the socket engine instance) - meaning that the
next connection attempt would have a fresh socks instance to try out the
connection with.

Reported-by: Gabe Edwards <gabe.edwards@me.com>
Change-Id: Iab1e84af6d4248fd75a6dfe5e79a3c73129aae0b
Reviewed-by: Richard J. Moore <rich@kde.org>
This commit is contained in:
Robin Burchell 2015-12-24 00:15:44 +01:00
parent a6b2a4642f
commit cbc4750f52

View File

@ -1111,14 +1111,16 @@ bool QSocks5SocketEngine::connectInternal()
} }
} }
if (d->socks5State == QSocks5SocketEnginePrivate::Uninitialized if (d->socketState != QAbstractSocket::ConnectingState) {
&& d->socketState != QAbstractSocket::ConnectingState) { if (d->socks5State == QSocks5SocketEnginePrivate::Uninitialized) {
setState(QAbstractSocket::ConnectingState); setState(QAbstractSocket::ConnectingState);
//limit buffer in internal socket, data is buffered in the external socket under application control //limit buffer in internal socket, data is buffered in the external socket under application control
d->data->controlSocket->setReadBufferSize(65536); d->data->controlSocket->setReadBufferSize(65536);
}
d->data->controlSocket->connectToHost(d->proxyInfo.hostName(), d->proxyInfo.port()); d->data->controlSocket->connectToHost(d->proxyInfo.hostName(), d->proxyInfo.port());
return false;
} }
return false; return false;
} }