TorSocket Class Reference

#include <torsocket.h>

List of all members.

Signals

void connectedToRemoteHost ()
void socketError (QString errmsg)

Public Member Functions

 TorSocket (const QHostAddress &socksAddr, quint16 socksPort, QObject *parent=0)
void connectToRemoteHost (const QString &remoteHost, quint16 remotePort)

Private Slots

void connectedToProxy ()
void onHandshakeResponse ()
void onError (QAbstractSocket::SocketError error)

Private Member Functions

void sendSocksHandshake (const QString &remoteHost, quint16 remotePort)

Private Attributes

QHostAddress _socksAddr
QString _remoteHost
quint16 _socksPort
quint16 _remotePort


Detailed Description

Definition at line 24 of file torsocket.h.


Constructor & Destructor Documentation

TorSocket::TorSocket ( const QHostAddress &  socksAddr,
quint16  socksPort,
QObject *  parent = 0 
)

Constructor.

Definition at line 30 of file torsocket.cpp.

References connectedToProxy(), tc::error(), onError(), and onHandshakeResponse().


Member Function Documentation

void TorSocket::connectToRemoteHost ( const QString &  remoteHost,
quint16  remotePort 
)

Connects to the specified hostname and port via Tor.

Definition at line 46 of file torsocket.cpp.

References _remoteHost, _remotePort, _socksAddr, and _socksPort.

Referenced by GeoIpResolver::resolve().

void TorSocket::connectedToRemoteHost (  )  [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]

Emitted when a connection error has occurred.

Referenced by onError().

void TorSocket::connectedToProxy (  )  [private, slot]

Called when the socket is connected to the proxy and sends our half of a Socks4a handshake.

Definition at line 64 of file torsocket.cpp.

References _remoteHost, _remotePort, and sendSocksHandshake().

Referenced by TorSocket().

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 103 of file torsocket.cpp.

References connectedToRemoteHost(), SOCKS_CONNECT_STATUS_OK, SOCKS_RESPONSE_LEN, and SOCKS_RESPONSE_VERSION.

Referenced by TorSocket().

void TorSocket::onError ( QAbstractSocket::SocketError  error  )  [private, slot]

Called when a connection error has occurred.

Definition at line 55 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 82 of file torsocket.cpp.

References SOCKS_CONNECT, SOCKS_FAKE_IP, and SOCKS_VERSION.

Referenced by connectedToProxy().


Member Data Documentation

QHostAddress TorSocket::_socksAddr [private]

Address of Tor's SOCKS listener.

Definition at line 56 of file torsocket.h.

Referenced by connectToRemoteHost().

QString TorSocket::_remoteHost [private]

Remote hostname.

Definition at line 57 of file torsocket.h.

Referenced by connectedToProxy(), and connectToRemoteHost().

quint16 TorSocket::_socksPort [private]

Port of Tor's SOCKS listener.

Definition at line 58 of file torsocket.h.

Referenced by connectToRemoteHost().

quint16 TorSocket::_remotePort [private]

Remote host port.

Definition at line 59 of file torsocket.h.

Referenced by connectedToProxy(), and connectToRemoteHost().


The documentation for this class was generated from the following files:

Generated on Wed Nov 26 21:04:00 2008 for Vidalia by  doxygen 1.5.6