Vidalia 0.3.1
TorSettings.h
Go to the documentation of this file.
1/*
2** This file is part of Vidalia, and is subject to the license terms in the
3** LICENSE file, found in the top level directory of this distribution. If you
4** did not receive the LICENSE file with this file, you may obtain it from the
5** Vidalia source package distributed by the Vidalia Project at
6** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7** including this file, may be copied, modified, propagated, or distributed
8** except according to the terms described in the LICENSE file.
9*/
10
11/*
12** \file TorSettings.h
13** \brief Settings used for starting and running Tor
14*/
15
16#ifndef _TORSETTINGS_H
17#define _TORSETTINGS_H
18
19#include "AbstractTorSettings.h"
20
21#include <QHostAddress>
22
23
24/** Manages Tor-specific settings, such as location, command-line arguments,
25 * and control interface information. */
27{
28 Q_OBJECT
29
30public:
31 /** Available Tor authentication methods. */
33 NullAuth, /**< No authentication. */
34 CookieAuth, /**< Use a "magic" cookie for authentication. */
35 PasswordAuth, /**< Use a hashed password for authentication. */
36 UnknownAuth /**< Unknown authentication method. */
37 };
38
39 /** Default constructor. */
41 /** Applies any changes to Tor's control port or authentication settings. */
42 bool apply(QString *errmsg = 0);
43
44 /** Gets the name and path of Tor's executable. */
45 QString getExecutable() const;
46 /** Sets the name and path of Tor's executable. */
47 void setExecutable(const QString &torExecutable);
48
49 /** Gets the location of Tor's data directory. */
50 QString getDataDirectory() const;
51 /** Sets the location to use for Tor's data directory. */
52 void setDataDirectory(const QString &dataDir);
53
54 /** Gets the torrc to use when starting Tor. */
55 QString getTorrc() const;
56 /** Sets the torrc to use when starting Tor. */
57 void setTorrc(const QString &torrc);
58
59 /** Get Tor's control interface address. */
60 QHostAddress getControlAddress() const;
61 /** Set Tor's control interface address. */
62 void setControlAddress(const QHostAddress &addr);
63
64 /** Get the control port. */
65 quint16 getControlPort() const;
66 /** Set the control port. */
67 void setControlPort(quint16 port);
68
69 /** Get the path for ControlSocket */
70 QString getSocketPath() const;
71
72 /** Get the current control method */
74
75 /** Returns true if Vidalia will get the ControlPort automatically from
76 * Tor */
77 bool autoControlPort() const;
78
79 /** Sets whether Vidalia should get the ControlPort from Tor */
80 void setAutoControlPort(const bool autoControl);
81
82 /** Set the control method */
84
85 /** Set the path for ControlSocket */
86 void setSocketPath(const QString &path);
87
88 /** Returns the plaintext (i.e., not hashed) control password used when
89 * authenticating to Tor. */
90 QString getControlPassword() const;
91 /** Sets the control password used when starting Tor with
92 * HashedControlPassword to <b>password</b>. */
93 void setControlPassword(const QString &password);
94
95 /** Returns true if a new, random control password is to be used each time
96 * Tor is started. */
97 bool useRandomPassword() const;
98 /** Sets whether or not to generate and use a random control password each
99 * time Tor is started. */
101
102 /** Returns the current authentication method used when connecting to Tor.*/
104 /** Sets the authentication method used when starting Tor to <b>method</b>.*/
106
107 /** Returns the current list of ports that will cause Tor to issue a warning
108 * when the user tries to connect to one of them. */
109 QList<quint16> getWarnPlaintextPorts() const;
110 /** Sets the list of ports that will cause Tor to issue a warning when the
111 * user tries to connect to one of them. */
112 void setWarnPlaintextPorts(const QList<quint16> &ports);
113
114 /** Returns the current list of ports that will cause Tor to reject the
115 * connection when the user tries to connect to one of them. */
116 QList<quint16> getRejectPlaintextPorts() const;
117 /** Sets the list of ports that will cause Tor to reject the connection
118 * when the user tries to connect to one of them. */
119 void setRejectPlaintextPorts(const QList<quint16> &ports);
120
121 /** Generates a random control password consisting of PASSWORD_LEN
122 * characters. */
123 static QString randomPassword();
124 /** Returns the hash of <b>password</b> as given by the command
125 * "tor --hash-password foo". */
126 static QString hashPassword(const QString &password);
127
128 /** Returns true if Vidalia needs to bootstrap the torrc file */
129 bool bootstrap() const;
130 /** Enables or disables bootstrap */
131 void setBootstrap(bool enabled);
132 /** Returns the path of the bootstrap torrc file */
133 QString bootstrapFrom() const;
134 /** Sets the location of the bootstrap torrc file */
135 void setBootstrapFrom(const QString &from);
136
137private:
138 /** Returns the AuthenticationMethod enum value for the string
139 * description of the authentication method given in <b>authMethod</b>. */
140 AuthenticationMethod toAuthenticationMethod(const QString &authMethod) const;
141 /** Returns the string description of the authentication method specified by
142 * <b>method</b>. The authentication method string is stored in Vidalia's
143 * configuration file. */
144 QString toString(AuthenticationMethod type) const;
145};
146
147#endif
148
TorControl * torControl() const
void setControlPassword(const QString &password)
void setBootstrap(bool enabled)
bool apply(QString *errmsg=0)
QString getExecutable() const
QList< quint16 > getWarnPlaintextPorts() const
bool useRandomPassword() const
void setUseRandomPassword(bool useRandomPassword)
static QString randomPassword()
QString getControlPassword() const
void setControlAddress(const QHostAddress &addr)
QString toString(AuthenticationMethod type) const
quint16 getControlPort() const
TorSettings(TorControl *torControl=0)
Definition: TorSettings.cpp:69
AuthenticationMethod toAuthenticationMethod(const QString &authMethod) const
bool bootstrap() const
QHostAddress getControlAddress() const
QList< quint16 > getRejectPlaintextPorts() const
void setTorrc(const QString &torrc)
void setAuthenticationMethod(AuthenticationMethod method)
QString getDataDirectory() const
void setControlMethod(ControlMethod::Method method)
void setSocketPath(const QString &path)
QString getTorrc() const
void setDataDirectory(const QString &dataDir)
void setBootstrapFrom(const QString &from)
QString bootstrapFrom() const
void setControlPort(quint16 port)
QString getSocketPath() const
void setRejectPlaintextPorts(const QList< quint16 > &ports)
void setWarnPlaintextPorts(const QList< quint16 > &ports)
ControlMethod::Method getControlMethod() const
void setExecutable(const QString &torExecutable)
bool autoControlPort() const
void setAutoControlPort(const bool autoControl)
AuthenticationMethod getAuthenticationMethod() const
static QString hashPassword(const QString &password)