Vidalia
0.2.15
|
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 HttpProxy = 2, /**< Use an HTTP proxy for non-tunneled dir fetches. */ 00037 HttpHttpsProxy = 3, /**< Use HTTP proxy for both dir and OR connections. */ 00038 ProxyTypeMax = 3 00039 }; 00040 00041 public: 00042 /** Default constructor. */ 00043 NetworkSettings(TorControl *torControl); 00044 00045 /** Applies the current network configuration settings to Tor. If 00046 * * <b>errmsg</b> is specified and an error occurs while applying the 00047 * settings, it will be set to a string describing the error. */ 00048 bool apply(QString *errmsg = 0); 00049 00050 /** Returns true if we need to set ReachableAddresses because we're behind a 00051 * restrictive firewall that limits the ports Tor can connect to. */ 00052 bool getFascistFirewall(); 00053 /** Sets to <b>fascistFirewall</b> whether Tor should only create outgoing 00054 * connections to the list of ports specified to setReachablePorts(). 00055 * \sa setReachablePorts() */ 00056 void setFascistFirewall(bool fascistFirewall); 00057 00058 /** Returns a list of ports to be specified in ReachableAddresses. */ 00059 QList<quint16> getReachablePorts(); 00060 /** Sets the list of ports that will be specified in ReachableAddresses to 00061 * <b>reachablePorts</b>. */ 00062 void setReachablePorts(const QList<quint16> &reachablePorts); 00063 00064 /** Returns the proxy type Tor is using, or NoProxy if it makes direct 00065 * connections. */ 00066 ProxyType getProxyType(); 00067 /** Set the type of proxy Tor should use to <b>type</b>. */ 00068 void setProxyType(ProxyType type); 00069 00070 /** Returns the address of the proxy server Tor makes connections through. */ 00071 QString getProxyAddress(); 00072 /** Sets the proxy address and port to <b>addr</b>. */ 00073 void setProxyAddress(const QString &addr); 00074 00075 /** Returns the username used to login to the proxy server. */ 00076 QString getProxyUsername(); 00077 /** Sets the proxy server username to <b>user</b>. */ 00078 void setProxyUsername(const QString &user); 00079 00080 /** Returns the password used to login to the proxy server. */ 00081 QString getProxyPassword(); 00082 /** Sets the proxy server password to <b>pass</b>. */ 00083 void setProxyPassword(const QString &pass); 00084 00085 /** Returns true if Tor should try to use bridge nodes to access the Tor 00086 * network. */ 00087 bool getUseBridges(); 00088 /** Sets to <b>useBridges</b> whether Tor should try to use bridge nodes 00089 * to access the Tor network. */ 00090 void setUseBridges(bool useBridges); 00091 00092 /** Returns a list of bridge nodes Tor should use. */ 00093 QStringList getBridgeList(); 00094 /** Sets to <b>bridgeList</b> the list of bridge nodes Tor should use. */ 00095 void setBridgeList(const QStringList &bridgeList); 00096 00097 /** Returns true if Tor is configured to try to tunnel its directory 00098 * connections through a one-hop circuit. */ 00099 bool getTunnelDirConns(); 00100 00101 private: 00102 /** Converts the ProxyType <b>type</b> to a string to store in the 00103 * configuration file. */ 00104 QString proxyTypeToString(ProxyType type); 00105 00106 /** Converts the proxy type string <b>type</b> to its ProxyType counterpart. */ 00107 ProxyType proxyTypeFromString(const QString &type); 00108 }; 00109 00110 #endif 00111