#include <torsocket.h>
Signals | |
void | connectedToTor () |
void | connectedToHost () |
void | socketError (QString errmsg) |
Public Member Functions | |
TorSocket (QHostAddress socksAddr, quint16 socksPort, QObject *parent=0) | |
void | connectToHost (const QString &remoteHost, quint16 remotePort) |
Private Slots | |
void | onHandshakeResponse () |
void | onError (QAbstractSocket::SocketError error) |
Private Member Functions | |
void | sendSocksHandshake (const QString &remoteHost, quint16 remotePort) |
Private Attributes | |
QHostAddress | _socksAddr |
quint16 | _socksPort |
Definition at line 35 of file torsocket.h.
TorSocket::TorSocket | ( | QHostAddress | socksAddr, | |
quint16 | socksPort, | |||
QObject * | parent = 0 | |||
) |
void TorSocket::connectToHost | ( | const QString & | remoteHost, | |
quint16 | remotePort | |||
) |
Connects to the specified hostname and port via Tor.
Definition at line 53 of file torsocket.cpp.
References _socksAddr, _socksPort, connectedToTor(), LOCAL_CONNECT_TIMEOUT, onHandshakeResponse(), and sendSocksHandshake().
Referenced by GeoIpResolver::resolve().
void TorSocket::connectedToTor | ( | ) | [signal] |
Emitted when a connection has been established to Tor.
Referenced by connectToHost().
void TorSocket::connectedToHost | ( | ) | [signal] |
Emitted when a connection has been established through Tor to the remote host specified in a prior call to connectToHost().
Referenced by onHandshakeResponse().
void TorSocket::socketError | ( | QString | errmsg | ) | [signal] |
Emmitted when a connection error has occurred.
Referenced by onError().
void TorSocket::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 112 of file torsocket.cpp.
References connectedToHost(), SOCKS_CONNECT_STATUS_OK, SOCKS_RESPONSE_LEN, and SOCKS_RESPONSE_VERSION.
Referenced by connectToHost().
void TorSocket::onError | ( | QAbstractSocket::SocketError | error | ) | [private, slot] |
Called when a connection error has occurred.
Definition at line 72 of file torsocket.cpp.
References socketError().
Referenced by TorSocket().
void TorSocket::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 91 of file torsocket.cpp.
References SOCKS_CONNECT, SOCKS_FAKE_IP, and SOCKS_VERSION.
Referenced by connectToHost().
QHostAddress TorSocket::_socksAddr [private] |
Address of Tor's SOCKS listener.
Definition at line 65 of file torsocket.h.
Referenced by connectToHost().
quint16 TorSocket::_socksPort [private] |
Port of Tor's SOCKS listener.
Definition at line 66 of file torsocket.h.
Referenced by connectToHost().