#include <torsslsocket.h>
Signals | |
void | connectedToRemoteHost () |
void | socketError (QString errmsg) |
Public Member Functions | |
TorSslSocket (const QHostAddress &socksAddr, quint16 socksPort, QObject *parent=0) | |
void | connectToRemoteHost (const QString &remoteHost, quint16 remotePort, bool encrypted) |
Private Slots | |
void | connectedToProxy () |
void | onEncrypted () |
void | onHandshakeResponse () |
void | onError (QAbstractSocket::SocketError error) |
void | onSslErrors (const QList< QSslError > &errors) |
Private Member Functions | |
void | sendSocksHandshake (const QString &remoteHost, quint16 remotePort) |
Private Attributes | |
QHostAddress | _socksAddr |
QString | _remoteHost |
quint16 | _socksPort |
quint16 | _remotePort |
bool | _encrypted |
Definition at line 24 of file torsslsocket.h.
TorSslSocket::TorSslSocket | ( | const QHostAddress & | socksAddr, | |
quint16 | socksPort, | |||
QObject * | parent = 0 | |||
) |
Constructor.
Definition at line 32 of file torsslsocket.cpp.
References connectedToProxy(), tc::error(), onEncrypted(), onError(), onHandshakeResponse(), and onSslErrors().
void TorSslSocket::connectedToProxy | ( | ) | [private, slot] |
Called when the socket is connected to the proxy and sends our half of a Socks4a handshake.
Called when a connection has been established to the proxy host and starts a Socks4a handshake.
Definition at line 83 of file torsslsocket.cpp.
References _remoteHost, _remotePort, and sendSocksHandshake().
Referenced by TorSslSocket().
void TorSslSocket::connectedToRemoteHost | ( | ) | [signal] |
Emitted when a connection has been established through Tor to the remote host specified in a prior call to connectToHost().
Referenced by onEncrypted(), and onHandshakeResponse().
void TorSslSocket::connectToRemoteHost | ( | const QString & | remoteHost, | |
quint16 | remotePort, | |||
bool | encrypted | |||
) |
Connects to the specified hostname and port via Tor.
Definition at line 52 of file torsslsocket.cpp.
References _encrypted, _remoteHost, _remotePort, _socksAddr, and _socksPort.
void TorSslSocket::onEncrypted | ( | ) | [private, slot] |
Called when an encrypted connection has been established to the remote host.
Definition at line 91 of file torsslsocket.cpp.
References connectedToRemoteHost().
Referenced by TorSslSocket().
void TorSslSocket::onError | ( | QAbstractSocket::SocketError | error | ) | [private, slot] |
Called when a connection error has occurred.
Definition at line 63 of file torsslsocket.cpp.
References socketError().
Referenced by TorSslSocket().
void TorSslSocket::onHandshakeResponse | ( | ) | [private, slot] |
Handles the server's response part of a Socks4a handshake.
Handles the second half of the handshake, received from the SOCKS proxy server. The response should be formatted as follows:
0x00 (response version) STATUS (0x5A means success; other values mean failure) PORT (not set) ADDRESS (not set)
Definition at line 130 of file torsslsocket.cpp.
References _encrypted, _remoteHost, connectedToRemoteHost(), SOCKS_CONNECT_STATUS_OK, SOCKS_RESPONSE_LEN, and SOCKS_RESPONSE_VERSION.
Referenced by TorSslSocket().
void TorSslSocket::onSslErrors | ( | const QList< QSslError > & | errors | ) | [private, slot] |
Called when one or more SSL errors occur on the socket.
Definition at line 71 of file torsslsocket.cpp.
References tc::error(), and socketError().
Referenced by TorSslSocket().
void TorSslSocket::sendSocksHandshake | ( | const QString & | remoteHost, | |
quint16 | remotePort | |||
) | [private] |
Sends the client part of a Socks4a handshake with a proxy server.
Sends the first part of a Socks4a handshake, using the remote hostname and port specified in the previous call to connectToHost(). The message should be formatted as follows:
0x04 (socks version) 0x01 (connect) PORT (two bytes, most significant byte first) 0x00 0x00 0x00 0x01 (fake IP address: tells proxy to use SOCKS4a) 0x00 (empty username field) HOSTNAME (target hostname) 0x00 (marks the end of the hostname field)
Definition at line 109 of file torsslsocket.cpp.
References SOCKS_CONNECT, SOCKS_FAKE_IP, and SOCKS_VERSION.
Referenced by connectedToProxy().
void TorSslSocket::socketError | ( | QString | errmsg | ) | [signal] |
Emitted when a connection error has occurred.
Referenced by onError(), and onSslErrors().
bool TorSslSocket::_encrypted [private] |
Set to true if the connection to the remote host should be encrypted.
Definition at line 66 of file torsslsocket.h.
Referenced by connectToRemoteHost(), and onHandshakeResponse().
QString TorSslSocket::_remoteHost [private] |
Remote hostname.
Definition at line 63 of file torsslsocket.h.
Referenced by connectedToProxy(), connectToRemoteHost(), and onHandshakeResponse().
quint16 TorSslSocket::_remotePort [private] |
Remote host port.
Definition at line 65 of file torsslsocket.h.
Referenced by connectedToProxy(), and connectToRemoteHost().
QHostAddress TorSslSocket::_socksAddr [private] |
Address of Tor's SOCKS listener.
Definition at line 62 of file torsslsocket.h.
Referenced by connectToRemoteHost().
quint16 TorSslSocket::_socksPort [private] |
Port of Tor's SOCKS listener.
Definition at line 64 of file torsslsocket.h.
Referenced by connectToRemoteHost().