Vidalia 0.3.1
TorSocket.h
Go to the documentation of this file.
1/*
2** This file is part of Vidalia, and is subject to the license terms in the
3** LICENSE file, found in the top level directory of this distribution. If you
4** did not receive the LICENSE file with this file, you may obtain it from the
5** Vidalia source package distributed by the Vidalia Project at
6** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7** including this file, may be copied, modified, propagated, or distributed
8** except according to the terms described in the LICENSE file.
9*/
10
11/*
12** \file TorSocket.h
13** \brief A QTcpSocket that makes requests over Tor
14*/
15
16#ifndef _TORSOCKET_H
17#define _TORSOCKET_H
18
19#include <QTcpSocket>
20#include <QHostAddress>
21
22
23class TorSocket : public QTcpSocket
24{
25 Q_OBJECT
26
27public:
28 /** Constructor. */
29 TorSocket(const QHostAddress &socksAddr,
30 quint16 socksPort, QObject *parent = 0);
31
32 /** Connects to the specified hostname and port via Tor. */
33 void connectToRemoteHost(const QString &remoteHost, quint16 remotePort);
34
35signals:
36 /** Emitted when a connection has been established through Tor to the remote
37 * host specified in a prior call to connectToHost(). */
39 /** Emitted when a connection error has occurred. */
40 void socketError(QString errmsg);
41
42private slots:
43 /** Called when the socket is connected to the proxy and sends our
44 * half of a Socks4a handshake. */
45 void connectedToProxy();
46 /** Handles the server's response part of a Socks4a handshake. */
48 /** Called when a connection error has occurred. */
49 void onError(QAbstractSocket::SocketError error);
50
51private:
52 /** Sends the client part of a Socks4a handshake with a proxy server. */
53 void sendSocksHandshake(const QString &remoteHost, quint16 remotePort);
54
55 QHostAddress _socksAddr; /**< Address of Tor's SOCKS listener. */
56 QString _remoteHost; /**< Remote hostname. */
57 quint16 _socksPort; /**< Port of Tor's SOCKS listener. */
58 quint16 _remotePort; /**< Remote host port. */
59};
60
61#endif
62
void onHandshakeResponse()
Definition: TorSocket.cpp:102
void sendSocksHandshake(const QString &remoteHost, quint16 remotePort)
Definition: TorSocket.cpp:81
void connectedToRemoteHost()
TorSocket(const QHostAddress &socksAddr, quint16 socksPort, QObject *parent=0)
Definition: TorSocket.cpp:29
void connectedToProxy()
Definition: TorSocket.cpp:63
void socketError(QString errmsg)
quint16 _remotePort
Definition: TorSocket.h:58
QHostAddress _socksAddr
Definition: TorSocket.h:55
quint16 _socksPort
Definition: TorSocket.h:57
void onError(QAbstractSocket::SocketError error)
Definition: TorSocket.cpp:54
void connectToRemoteHost(const QString &remoteHost, quint16 remotePort)
Definition: TorSocket.cpp:45
QString _remoteHost
Definition: TorSocket.h:56
DebugMessage error(const QString &fmt)
Definition: tcglobal.cpp:40