torsslsocket.h

Go to the documentation of this file.
00001 /*
00002 **  This file is part of Vidalia, and is subject to the license terms in the
00003 **  LICENSE file, found in the top level directory of this distribution. If you
00004 **  did not receive the LICENSE file with this file, you may obtain it from the
00005 **  Vidalia source package distributed by the Vidalia Project at
00006 **  http://www.vidalia-project.net/. No part of Vidalia, including this file,
00007 **  may be copied, modified, propagated, or distributed except according to the
00008 **  terms described in the LICENSE file.
00009 */
00010 
00011 /*
00012 ** \file torsslsocket.h
00013 ** \version $Id: /local/vidalia/trunk/src/util/torsocket.h 1564 2006-12-26T06:06:04.965088Z edmanm  $
00014 ** \brief A QSslSocket that makes encrypted requests over Tor
00015 */
00016 
00017 #ifndef _TORSSLSOCKET_H
00018 #define _TORSSLSOCKET_H
00019 
00020 #include <QSslSocket>
00021 #include <QHostAddress>
00022 
00023 
00024 class TorSslSocket : public QSslSocket
00025 {
00026   Q_OBJECT
00027   
00028 public:
00029   /** Constructor. */
00030   TorSslSocket(const QHostAddress &socksAddr,
00031                quint16 socksPort, QObject *parent = 0);
00032 
00033   /** Connects to the specified hostname and port via Tor. */
00034   void connectToRemoteHost(const QString &remoteHost, quint16 remotePort,
00035                            bool encrypted);
00036 
00037 signals:
00038   /** Emitted when a connection has been established through Tor to the remote
00039    * host specified in a prior call to connectToHost(). */
00040   void connectedToRemoteHost();
00041   /** Emitted when a connection error has occurred. */
00042   void socketError(QString errmsg);
00043     
00044 private slots:
00045   /** Called when the socket is connected to the proxy and sends our
00046    * half of a Socks4a handshake. */
00047   void connectedToProxy();
00048   /** Called when an encrypted connection has been established to the remote
00049    * host. */
00050   void onEncrypted();
00051   /** Handles the server's response part of a Socks4a handshake. */
00052   void onHandshakeResponse();
00053   /** Called when a connection error has occurred. */
00054   void onError(QAbstractSocket::SocketError error);
00055   /** Called when one or more SSL errors occur on the socket. */
00056   void onSslErrors(const QList<QSslError> &errors);
00057   
00058 private:
00059   /** Sends the client part of a Socks4a handshake with a proxy server. */
00060   void sendSocksHandshake(const QString &remoteHost, quint16 remotePort);
00061   
00062   QHostAddress _socksAddr; /**< Address of Tor's SOCKS listener. */
00063   QString _remoteHost;     /**< Remote hostname. */
00064   quint16 _socksPort;      /**< Port of Tor's SOCKS listener. */
00065   quint16 _remotePort;     /**< Remote host port. */
00066   bool    _encrypted;      /**< Set to true if the connection to the remote
00067                                 host should be encrypted. */
00068 };
00069 
00070 #endif
00071 

Generated on Tue Jul 7 17:00:56 2009 for Vidalia by  doxygen 1.4.7