Vidalia 0.2.10
|
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 TorSettings.h 00013 ** \version $Id: TorSettings.h 3735 2009-04-28 20:28:01Z edmanm $ 00014 ** \brief Settings used for starting and running Tor 00015 */ 00016 00017 #ifndef _TORSETTINGS_H 00018 #define _TORSETTINGS_H 00019 00020 #include "AbstractTorSettings.h" 00021 00022 #include <QHostAddress> 00023 00024 00025 /** Manages Tor-specific settings, such as location, command-line arguments, 00026 * and control interface information. */ 00027 class TorSettings : public AbstractTorSettings 00028 { 00029 Q_OBJECT 00030 00031 public: 00032 /** Available Tor authentication methods. */ 00033 enum AuthenticationMethod { 00034 NullAuth, /**< No authentication. */ 00035 CookieAuth, /**< Use a "magic" cookie for authentication. */ 00036 PasswordAuth, /**< Use a hashed password for authentication. */ 00037 UnknownAuth /**< Unknown authentication method. */ 00038 }; 00039 00040 /** Default constructor. */ 00041 TorSettings(TorControl *torControl = 0); 00042 /** Applies any changes to Tor's control port or authentication settings. */ 00043 bool apply(QString *errmsg = 0); 00044 00045 /** Gets the name and path of Tor's executable. */ 00046 QString getExecutable() const; 00047 /** Sets the name and path of Tor's executable. */ 00048 void setExecutable(const QString &torExecutable); 00049 00050 /** Gets the location of Tor's data directory. */ 00051 QString getDataDirectory() const; 00052 /** Sets the location to use for Tor's data directory. */ 00053 void setDataDirectory(const QString &dataDir); 00054 00055 /** Gets the torrc to use when starting Tor. */ 00056 QString getTorrc() const; 00057 /** Sets the torrc to use when starting Tor. */ 00058 void setTorrc(const QString &torrc); 00059 00060 /** Get Tor's control interface address. */ 00061 QHostAddress getControlAddress() const; 00062 /** Set Tor's control interface address. */ 00063 void setControlAddress(const QHostAddress &addr); 00064 00065 /** Get the control port. */ 00066 quint16 getControlPort() const; 00067 /** Set the control port. */ 00068 void setControlPort(quint16 port); 00069 00070 /** Returns the plaintext (i.e., not hashed) control password used when 00071 * authenticating to Tor. */ 00072 QString getControlPassword() const; 00073 /** Sets the control password used when starting Tor with 00074 * HashedControlPassword to <b>password</b>. */ 00075 void setControlPassword(const QString &password); 00076 00077 /** Returns true if a new, random control password is to be used each time 00078 * Tor is started. */ 00079 bool useRandomPassword() const; 00080 /** Sets whether or not to generate and use a random control password each 00081 * time Tor is started. */ 00082 void setUseRandomPassword(bool useRandomPassword); 00083 00084 /** Returns the current authentication method used when connecting to Tor.*/ 00085 AuthenticationMethod getAuthenticationMethod() const; 00086 /** Sets the authentication method used when starting Tor to <b>method</b>.*/ 00087 void setAuthenticationMethod(AuthenticationMethod method); 00088 00089 /** Returns the current list of ports that will cause Tor to issue a warning 00090 * when the user tries to connect to one of them. */ 00091 QList<quint16> getWarnPlaintextPorts() const; 00092 /** Sets the list of ports that will cause Tor to issue a warning when the 00093 * user tries to connect to one of them. */ 00094 void setWarnPlaintextPorts(const QList<quint16> &ports); 00095 00096 /** Returns the current list of ports that will cause Tor to reject the 00097 * connection when the user tries to connect to one of them. */ 00098 QList<quint16> getRejectPlaintextPorts() const; 00099 /** Sets the list of ports that will cause Tor to reject the connection 00100 * when the user tries to connect to one of them. */ 00101 void setRejectPlaintextPorts(const QList<quint16> &ports); 00102 00103 /** Generates a random control password consisting of PASSWORD_LEN 00104 * characters. */ 00105 static QString randomPassword(); 00106 /** Returns the hash of <b>password</b> as given by the command 00107 * "tor --hash-password foo". */ 00108 static QString hashPassword(const QString &password); 00109 00110 private: 00111 /** Returns the AuthenticationMethod enum value for the string 00112 * description of the authentication method given in <b>authMethod</b>. */ 00113 AuthenticationMethod toAuthenticationMethod(const QString &authMethod) const; 00114 /** Returns the string description of the authentication method specified by 00115 * <b>method</b>. The authentication method string is stored in Vidalia's 00116 * configuration file. */ 00117 QString toString(AuthenticationMethod type) const; 00118 }; 00119 00120 #endif 00121