Vidalia  0.2.17
NetworkSettings.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.torproject.org/projects/vidalia.html. No part of Vidalia, 
00007 **  including this file, may be copied, modified, propagated, or distributed 
00008 **  except according to the terms described in the LICENSE file.
00009 */
00010 
00011 /*
00012 ** \file NetworkSettings.h
00013 ** \brief Settings for configuring an HTTP/HTTPS proxy or bridges
00014 */
00015 
00016 #ifndef _NETWORKSETTINGS_H
00017 #define _NETWORKSETTINGS_H
00018 
00019 #include "AbstractTorSettings.h"
00020 
00021 #include <QList>
00022 #include <QStringList>
00023 
00024 
00025 class NetworkSettings : public AbstractTorSettings
00026 {
00027   Q_OBJECT
00028 
00029 public:
00030   enum ProxyType
00031   {
00032     ProxyTypeMin = -1,
00033     NoProxy = -1, /**< Have Tor connect directly to the Internet. */
00034     Socks4Proxy = 0, /**< Use a SOCKS 4 proxy for OR connections. */
00035     Socks5Proxy = 1, /**< Use a SOCKS 5 proxy for OR connections. */
00036     HttpHttpsProxy = 2, /**< Use HTTP proxy for both dir and OR connections. */
00037     ProxyTypeMax = 2
00038   };
00039 
00040 public:
00041   /** Default constructor. */
00042   NetworkSettings(TorControl *torControl);
00043 
00044   /** Applies the current network configuration settings to Tor. If
00045    *  * <b>errmsg</b> is specified and an error occurs while applying the
00046    *  settings, it will be set to a string describing the error. */
00047   bool apply(QString *errmsg = 0);
00048 
00049   /** Returns true if we need to set ReachableAddresses because we're behind a
00050    * restrictive firewall that limits the ports Tor can connect to. */
00051   bool getFascistFirewall();
00052   /** Sets to <b>fascistFirewall</b> whether Tor should only create outgoing
00053    * connections to the list of ports specified to setReachablePorts().
00054    * \sa setReachablePorts() */
00055   void setFascistFirewall(bool fascistFirewall);
00056 
00057   /** Returns a list of ports to be specified in ReachableAddresses. */
00058   QList<quint16> getReachablePorts();
00059   /** Sets the list of ports that will be specified in ReachableAddresses to
00060    * <b>reachablePorts</b>. */
00061   void setReachablePorts(const QList<quint16> &reachablePorts);
00062 
00063   /** Returns the proxy type Tor is using, or NoProxy if it makes direct
00064    * connections. */ 
00065   ProxyType getProxyType();
00066   /** Set the type of proxy Tor should use to <b>type</b>. */
00067   void setProxyType(ProxyType type);
00068 
00069   /** Returns the address of the proxy server Tor makes connections through. */
00070   QString getProxyAddress();
00071   /** Sets the proxy address and port to <b>addr</b>. */
00072   void setProxyAddress(const QString &addr);
00073 
00074   /** Returns the username used to login to the proxy server. */
00075   QString getProxyUsername();
00076   /** Sets the proxy server username to <b>user</b>. */ 
00077   void setProxyUsername(const QString &user);
00078 
00079   /** Returns the password used to login to the proxy server. */
00080   QString getProxyPassword();
00081   /** Sets the proxy server password to <b>pass</b>. */ 
00082   void setProxyPassword(const QString &pass);
00083  
00084   /** Returns true if Tor should try to use bridge nodes to access the Tor
00085    * network. */
00086   bool getUseBridges();
00087   /** Sets to <b>useBridges</b> whether Tor should try to use bridge nodes
00088    * to access the Tor network. */
00089   void setUseBridges(bool useBridges);
00090 
00091   /** Returns a list of bridge nodes Tor should use. */
00092   QStringList getBridgeList();
00093   /** Sets to <b>bridgeList</b> the list of bridge nodes Tor should use. */
00094   void setBridgeList(const QStringList &bridgeList);
00095 
00096   /** Returns true if Tor is configured to try to tunnel its directory
00097    * connections through a one-hop circuit. */
00098   bool getTunnelDirConns();
00099 
00100 private:
00101   /** Converts the ProxyType <b>type</b> to a string to store in the
00102    * configuration file. */
00103   QString proxyTypeToString(ProxyType type);
00104 
00105   /** Converts the proxy type string <b>type</b> to its ProxyType counterpart. */
00106   ProxyType proxyTypeFromString(const QString &type);
00107 };
00108 
00109 #endif
00110