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