Vidalia
0.2.21
Main Page
Namespaces
Classes
Files
File List
File Members
src
vidalia
config
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. */
26
class
TorSettings
:
public
AbstractTorSettings
27
{
28
Q_OBJECT
29
30
public
:
31
/** Available Tor authentication methods. */
32
enum
AuthenticationMethod
{
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. */
40
TorSettings
(
TorControl
*
torControl
= 0);
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 */
73
ControlMethod::Method
getControlMethod
()
const
;
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
auto
);
81
82
/** Set the control method */
83
void
setControlMethod
(
ControlMethod::Method
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. */
100
void
setUseRandomPassword
(
bool
useRandomPassword
);
101
102
/** Returns the current authentication method used when connecting to Tor.*/
103
AuthenticationMethod
getAuthenticationMethod
()
const
;
104
/** Sets the authentication method used when starting Tor to <b>method</b>.*/
105
void
setAuthenticationMethod
(
AuthenticationMethod
method);
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
137
private
:
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
Generated on Thu Dec 6 2012 04:33:17 for Vidalia by
1.8.2