#include <torsettings.h>
Public Types | |
enum | AuthenticationMethod { NullAuth, CookieAuth, PasswordAuth, UnknownAuth } |
Public Member Functions | |
TorSettings (TorControl *torControl=0) | |
bool | apply (QString *errmsg=0) |
QString | getExecutable () const |
void | setExecutable (const QString &torExecutable) |
QString | getDataDirectory () const |
void | setDataDirectory (const QString &dataDir) |
QString | getTorrc () const |
void | setTorrc (const QString &torrc) |
QHostAddress | getControlAddress () const |
void | setControlAddress (const QHostAddress &addr) |
quint16 | getControlPort () const |
void | setControlPort (quint16 port) |
QString | getControlPassword () const |
void | setControlPassword (const QString &password) |
bool | useRandomPassword () const |
void | setUseRandomPassword (bool useRandomPassword) |
AuthenticationMethod | getAuthenticationMethod () const |
void | setAuthenticationMethod (AuthenticationMethod method) |
QString | getUser () const |
void | setUser (const QString &user) |
QString | getGroup () const |
void | setGroup (const QString &group) |
Static Public Member Functions | |
static QString | randomPassword () |
static QString | hashPassword (const QString &password) |
Private Member Functions | |
AuthenticationMethod | toAuthenticationMethod (const QString &authMethod) const |
QString | toString (AuthenticationMethod type) const |
Definition at line 27 of file torsettings.h.
Available Tor authentication methods.
NullAuth | No authentication. |
CookieAuth | Use a "magic" cookie for authentication. |
PasswordAuth | Use a hashed password for authentication. |
UnknownAuth | Unknown authentication method. |
Definition at line 33 of file torsettings.h.
TorSettings::TorSettings | ( | TorControl * | torControl = 0 |
) |
Default constructor.
Default constructor
Definition at line 59 of file torsettings.cpp.
References DEFAULT_AUTH_METHOD, VSettings::setDefault(), SETTING_AUTH_METHOD, SETTING_CONTROL_ADDR, SETTING_CONTROL_PASSWORD, SETTING_CONTROL_PORT, SETTING_DATA_DIRECTORY, SETTING_TOR_EXECUTABLE, SETTING_TOR_GROUP, SETTING_TOR_USER, SETTING_TORRC, SETTING_USE_RANDOM_PASSWORD, toString(), and win32_program_files_folder().
bool TorSettings::apply | ( | QString * | errmsg = 0 |
) | [virtual] |
Applies any changes to Tor's control port or authentication settings.
Implements AbstractTorSettings.
Definition at line 86 of file torsettings.cpp.
References CookieAuth, getControlPassword(), hashPassword(), AbstractTorSettings::localValue(), PasswordAuth, randomPassword(), TorControl::setConf(), SETTING_AUTH_METHOD, SETTING_CONTROL_PORT, toAuthenticationMethod(), TOR_ARG_COOKIE_AUTH, TOR_ARG_HASHED_PASSWORD, AbstractTorSettings::torControl(), toString(), and useRandomPassword().
Referenced by AdvancedPage::apply().
QString TorSettings::getExecutable | ( | ) | const |
Gets the name and path of Tor's executable.
Returns a fully-qualified path to Tor's executable, including the executable name.
Definition at line 137 of file torsettings.cpp.
References VSettings::defaultValue(), AbstractTorSettings::localValue(), and SETTING_TOR_EXECUTABLE.
Referenced by hashPassword(), GeneralPage::load(), and MainWindow::start().
void TorSettings::setExecutable | ( | const QString & | torExecutable | ) |
Sets the name and path of Tor's executable.
Sets the location and name of Tor's executable to the given string.
Definition at line 147 of file torsettings.cpp.
References SETTING_TOR_EXECUTABLE, and AbstractTorSettings::setValue().
Referenced by GeneralPage::save().
QString TorSettings::getDataDirectory | ( | ) | const |
Gets the location of Tor's data directory.
Definition at line 122 of file torsettings.cpp.
References SETTING_DATA_DIRECTORY, toString(), and AbstractTorSettings::value().
Referenced by MainWindow::authenticate(), hashPassword(), AdvancedPage::load(), MainWindow::loadControlCookie(), AdvancedPage::save(), and MainWindow::start().
void TorSettings::setDataDirectory | ( | const QString & | dataDirectory | ) |
Sets the location to use for Tor's data directory.
Sets the location to use as Tor's data directory.
Definition at line 129 of file torsettings.cpp.
References SETTING_DATA_DIRECTORY, and AbstractTorSettings::setValue().
Referenced by AdvancedPage::save().
QString TorSettings::getTorrc | ( | ) | const |
Gets the torrc to use when starting Tor.
Returns the torrc that will be used when starting Tor.
Definition at line 154 of file torsettings.cpp.
References TorControl::getInfo(), TorControl::isConnected(), AbstractTorSettings::localValue(), SETTING_TORRC, AbstractTorSettings::torControl(), and toString().
Referenced by AdvancedPage::load(), AdvancedPage::save(), and MainWindow::start().
void TorSettings::setTorrc | ( | const QString & | torrc | ) |
Sets the torrc to use when starting Tor.
Sets the torrc that will be used when starting Tor.
torrc | The torrc to use. |
Definition at line 167 of file torsettings.cpp.
References SETTING_TORRC, and AbstractTorSettings::setValue().
Referenced by AdvancedPage::save().
QHostAddress TorSettings::getControlAddress | ( | ) | const |
Get Tor's control interface address.
Get the address or hostname used to connect to Tor
Definition at line 206 of file torsettings.cpp.
References AbstractTorSettings::localValue(), and SETTING_CONTROL_ADDR.
Referenced by MainWindow::connectFailed(), AdvancedPage::load(), MainWindow::start(), and MainWindow::started().
void TorSettings::setControlAddress | ( | const QHostAddress & | addr | ) |
Set Tor's control interface address.
Set the address or hostname used to connect to Tor
Definition at line 214 of file torsettings.cpp.
References SETTING_CONTROL_ADDR, and AbstractTorSettings::setValue().
Referenced by AdvancedPage::save().
quint16 TorSettings::getControlPort | ( | ) | const |
Get the control port.
Get the control port used to connect to Tor
Definition at line 221 of file torsettings.cpp.
References SETTING_CONTROL_PORT, and AbstractTorSettings::value().
Referenced by MainWindow::connectFailed(), AdvancedPage::load(), MainWindow::start(), and MainWindow::started().
void TorSettings::setControlPort | ( | quint16 | port | ) |
Set the control port.
Set the control port used to connect to Tor
Definition at line 228 of file torsettings.cpp.
References SETTING_CONTROL_PORT, and AbstractTorSettings::setValue().
Referenced by AdvancedPage::save().
QString TorSettings::getControlPassword | ( | ) | const |
Returns the plaintext (i.e., not hashed) control password used when authenticating to Tor.
Definition at line 236 of file torsettings.cpp.
References AbstractTorSettings::localValue(), and SETTING_CONTROL_PASSWORD.
Referenced by apply(), AdvancedPage::load(), and MainWindow::start().
void TorSettings::setControlPassword | ( | const QString & | password | ) |
Sets the control password used when starting Tor with HashedControlPassword to password.
Definition at line 244 of file torsettings.cpp.
References SETTING_CONTROL_PASSWORD, and AbstractTorSettings::setValue().
Referenced by MainWindow::authenticationFailed(), and AdvancedPage::save().
bool TorSettings::useRandomPassword | ( | ) | const |
Returns true if a new, random control password is to be used each time Tor is started.
Returns true if a new, random control password is to be used each time Tor is started.
Definition at line 252 of file torsettings.cpp.
References AbstractTorSettings::localValue(), and SETTING_USE_RANDOM_PASSWORD.
Referenced by apply(), AdvancedPage::load(), and MainWindow::start().
void TorSettings::setUseRandomPassword | ( | bool | useRandomPassword | ) |
Sets whether or not to generate and use a random control password each time Tor is started.
Definition at line 260 of file torsettings.cpp.
References SETTING_USE_RANDOM_PASSWORD, and AbstractTorSettings::setValue().
Referenced by MainWindow::authenticationFailed(), and AdvancedPage::save().
TorSettings::AuthenticationMethod TorSettings::getAuthenticationMethod | ( | ) | const |
Returns the current authentication method used when connecting to Tor.
Returns the current authentication method used when connecting to Tor.
Definition at line 267 of file torsettings.cpp.
References CookieAuth, DEFAULT_AUTH_METHOD, TorControl::getConf(), TorControl::isConnected(), AbstractTorSettings::localValue(), PasswordAuth, SETTING_AUTH_METHOD, toAuthenticationMethod(), TOR_ARG_COOKIE_AUTH, TOR_ARG_HASHED_PASSWORD, AbstractTorSettings::torControl(), toString(), and UnknownAuth.
Referenced by MainWindow::authenticate(), AdvancedPage::load(), and MainWindow::start().
void TorSettings::setAuthenticationMethod | ( | AuthenticationMethod | method | ) |
Sets the authentication method used when starting Tor to method.
Sets the authentication method used when starting Tor to method.
Definition at line 290 of file torsettings.cpp.
References SETTING_AUTH_METHOD, AbstractTorSettings::setValue(), and toString().
Referenced by MainWindow::authenticationFailed(), and AdvancedPage::save().
QString TorSettings::getUser | ( | ) | const |
Get which user will be used to run Tor.
Returns the user used when running Tor. The user is specified as an argument to Tor, which will setuid to this user.
Definition at line 175 of file torsettings.cpp.
References SETTING_TOR_USER, and AbstractTorSettings::value().
Referenced by AdvancedPage::load(), and MainWindow::start().
void TorSettings::setUser | ( | const QString & | user | ) |
Set which user will be used to run Tor.
Sets the user used when running Tor. The user is specified as an argument to Tor, which will setuid to this user.
Definition at line 183 of file torsettings.cpp.
References SETTING_TOR_USER, and AbstractTorSettings::setValue().
Referenced by AdvancedPage::save().
QString TorSettings::getGroup | ( | ) | const |
Get which group will be used to run Tor.
Returns the group used when running Tor. The group is specified as an argument to Tor, which will setgid to this group.
Definition at line 191 of file torsettings.cpp.
References SETTING_TOR_GROUP, and AbstractTorSettings::value().
Referenced by AdvancedPage::load(), and MainWindow::start().
void TorSettings::setGroup | ( | const QString & | group | ) |
Set which group will be used to run Tor.
Sets the group used when running Tor. The group is specified as an argument to Tor, which will setgid to this group.
Definition at line 199 of file torsettings.cpp.
References SETTING_TOR_GROUP, and AbstractTorSettings::setValue().
Referenced by AdvancedPage::save().
QString TorSettings::randomPassword | ( | ) | [static] |
Generates a random control password consisting of PASSWORD_LEN characters.
Generates a random control password consisting of PASSWORD_LEN characters.
Definition at line 327 of file torsettings.cpp.
References crypto_rand_string(), and PASSWORD_LEN.
Referenced by apply(), and MainWindow::start().
QString TorSettings::hashPassword | ( | const QString & | password | ) | [static] |
Returns the hash of password as given by the command "tor --hash-password foo".
Returns the hash of password as given by the command "tor --hash-password foo".
Definition at line 335 of file torsettings.cpp.
References getDataDirectory(), and getExecutable().
Referenced by apply(), and MainWindow::start().
TorSettings::AuthenticationMethod TorSettings::toAuthenticationMethod | ( | const QString & | authMethod | ) | const [private] |
Returns the AuthenticationMethod enum value for the string description of the authentication method given in authMethod.
Definition at line 313 of file torsettings.cpp.
References CookieAuth, NullAuth, PasswordAuth, toString(), and UnknownAuth.
Referenced by apply(), and getAuthenticationMethod().
QString TorSettings::toString | ( | AuthenticationMethod | method | ) | const [private] |
Returns the string description of the authentication method specified by method. The authentication method string is stored in Vidalia's configuration file.
Returns the string description of the authentication method specified by method. The authentication method string is stored in Vidalia's configuration file.
Definition at line 299 of file torsettings.cpp.
References CookieAuth, NullAuth, and PasswordAuth.
Referenced by apply(), getAuthenticationMethod(), getDataDirectory(), getTorrc(), setAuthenticationMethod(), toAuthenticationMethod(), and TorSettings().