Vidalia 0.3.1
Signals | Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
TorSocket Class Reference

#include <TorSocket.h>

Inheritance diagram for TorSocket:

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 23 of file TorSocket.h.

Constructor & Destructor Documentation

◆ TorSocket()

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

Constructor.

Definition at line 29 of file TorSocket.cpp.

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

Member Function Documentation

◆ connectedToProxy

void TorSocket::connectedToProxy ( )
privateslot

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

Definition at line 63 of file TorSocket.cpp.

References _remoteHost, _remotePort, and sendSocksHandshake().

Referenced by TorSocket().

◆ connectedToRemoteHost

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().

◆ connectToRemoteHost()

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

Connects to the specified hostname and port via Tor.

Definition at line 45 of file TorSocket.cpp.

References _remoteHost, _remotePort, _socksAddr, and _socksPort.

◆ onError

void TorSocket::onError ( QAbstractSocket::SocketError  error)
privateslot

Called when a connection error has occurred.

Definition at line 54 of file TorSocket.cpp.

References tc::error(), and socketError().

Referenced by TorSocket().

◆ onHandshakeResponse

void TorSocket::onHandshakeResponse ( )
privateslot

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 102 of file TorSocket.cpp.

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

Referenced by onHandshakeResponse(), and TorSocket().

◆ sendSocksHandshake()

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 81 of file TorSocket.cpp.

References quint32, SOCKS_CONNECT, SOCKS_FAKE_IP, and SOCKS_VERSION.

Referenced by connectedToProxy().

◆ socketError

void TorSocket::socketError ( QString  errmsg)
signal

Emitted when a connection error has occurred.

Referenced by onError().

Member Data Documentation

◆ _remoteHost

QString TorSocket::_remoteHost
private

Remote hostname.

Definition at line 56 of file TorSocket.h.

Referenced by connectedToProxy(), and connectToRemoteHost().

◆ _remotePort

quint16 TorSocket::_remotePort
private

Remote host port.

Definition at line 58 of file TorSocket.h.

Referenced by connectedToProxy(), and connectToRemoteHost().

◆ _socksAddr

QHostAddress TorSocket::_socksAddr
private

Address of Tor's SOCKS listener.

Definition at line 55 of file TorSocket.h.

Referenced by connectToRemoteHost().

◆ _socksPort

quint16 TorSocket::_socksPort
private

Port of Tor's SOCKS listener.

Definition at line 57 of file TorSocket.h.

Referenced by connectToRemoteHost().


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