00001 /**************************************************************** 00002 * Vidalia is distributed under the following license: 00003 * 00004 * Copyright (C) 2006, Matt Edman, Justin Hipple 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 ****************************************************************/ 00021 00022 /** 00023 * \file torsettings.h 00024 * \version $Id: torsettings.h 1864 2007-08-23 23:31:35Z edmanm $ 00025 * \brief Settings used for starting and running Tor 00026 */ 00027 00028 #ifndef _TORSETTINGS_H 00029 #define _TORSETTINGS_H 00030 00031 #include <QHostAddress> 00032 00033 #include "vidaliasettings.h" 00034 00035 /** Manages Tor-specific settings, such as location, command-line arguments, 00036 * and control interface information. */ 00037 class TorSettings : private VidaliaSettings 00038 { 00039 public: 00040 /** Available Tor authentication methods. */ 00041 enum AuthenticationMethod { 00042 NullAuth, /**< No authentication. */ 00043 CookieAuth, /**< Use a "magic" cookie for authentication. */ 00044 PasswordAuth, /**< Use a hashed password for authentication. */ 00045 UnknownAuth /**< Unknown authentication method. */ 00046 }; 00047 00048 /** Default constructor. */ 00049 TorSettings(); 00050 00051 /** Gets the name and path of Tor's executable. */ 00052 QString getExecutable(); 00053 /** Sets the name and path of Tor's executable. */ 00054 void setExecutable(QString torExecutable); 00055 00056 /** Gets the location of Tor's data directory. */ 00057 QString getDataDirectory(); 00058 /** Sets the location to use for Tor's data directory. */ 00059 void setDataDirectory(QString dataDir); 00060 00061 /** Builds and formats a list of command-line arguments. */ 00062 QStringList getArguments(); 00063 00064 /** Gets the torrc to use when starting Tor. */ 00065 QString getTorrc(); 00066 /** Sets the torrc to use when starting Tor. */ 00067 void setTorrc(QString torrc); 00068 00069 /** Get Tor's control interface address. */ 00070 QHostAddress getControlAddress(); 00071 /** Set Tor's control interface address. */ 00072 void setControlAddress(QHostAddress addr); 00073 00074 /** Get the control port. */ 00075 quint16 getControlPort(); 00076 /** Set the control port. */ 00077 void setControlPort(quint16 port); 00078 00079 /** Returns the plaintext (i.e., not hashed) control password used when 00080 * authenticating to Tor. */ 00081 QString getControlPassword(); 00082 /** Sets the control password used when starting Tor with 00083 * HashedControlPassword to <b>password</b>. */ 00084 void setControlPassword(QString password); 00085 00086 /** Returns true if a new, random control password is to be used each time 00087 * Tor is started. */ 00088 bool useRandomPassword(); 00089 /** Sets whether or not to generate and use a random control password each 00090 * time Tor is started. */ 00091 void setUseRandomPassword(bool useRandomPassword); 00092 00093 /** Returns the current authentication method used when connecting to Tor.*/ 00094 AuthenticationMethod getAuthenticationMethod(); 00095 /** Sets the authentication method used when starting Tor to <b>method</b>.*/ 00096 void setAuthenticationMethod(AuthenticationMethod method); 00097 00098 /** Get which user will be used to run Tor. */ 00099 QString getUser(); 00100 /** Set which user will be used to run Tor. */ 00101 void setUser(QString user); 00102 00103 /** Get which group will be used to run Tor. */ 00104 QString getGroup(); 00105 /** Set which group will be used to run Tor. */ 00106 void setGroup(QString group); 00107 00108 private: 00109 /** Returns the string description of the authentication method specified by 00110 * <b>method</b>. The authentication method string is stored in Vidalia's 00111 * configuration file. */ 00112 QString toString(AuthenticationMethod type); 00113 /** Generates a random control password consisting of PASSWORD_LEN 00114 * characters. */ 00115 QString generateRandomPassword(); 00116 /** Returns the hash of <b>password</b> as given by the command 00117 * "tor --hash-password foo". */ 00118 QString hashPassword(QString password); 00119 }; 00120 00121 #endif 00122