Vidalia  0.3.1
ServerSettings.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 ServerSettings.h
13 ** \brief Settings for running a Tor server
14 */
15 
16 #ifndef _SERVERSETTINGS_H
17 #define _SERVERSETTINGS_H
18 
19 #include "AbstractTorSettings.h"
20 #include "ExitPolicy.h"
21 
22 
24 {
25  Q_OBJECT
26 
27 public:
28  /** Constructor */
30 
31  /** Applies changese to Tor. */
32  bool apply(QString *errmsg = 0);
33 
34  /** Enables running Tor as a server. */
35  void setServerEnabled(bool enable);
36  /** Returns true if Tor is running as a server. */
37  bool isServerEnabled();
38 
39  /** Sets to <b>enabled</b> whether Tor should be a bridge node when acting
40  * as a server. */
41  void setBridgeEnabled(bool enable);
42  /** Returns true if Tor is configured to act as a bridge node. */
43  bool isBridgeEnabled();
44 
45  /** Sets to <b>enabled</b> whether Tor should be a non-exit node when acting
46  * as a server. */
47  void setNonExitEnabled(bool enable);
48  /** Returns true if Tor is configured to act as a non-exit node. */
49  bool isNonExitEnabled();
50 
51  /** Sets the server's ORPort value. */
52  void setORPort(quint16 orPort);
53  /** Gets the server's ORPort value. */
54  quint16 getORPort();
55 
56  /** Sets the server's DirPort value. */
57  void setDirPort(quint16 dirPort);
58  /** Gets the server's DirPort value. */
59  quint16 getDirPort();
60 
61  /** Sets the server's nickname. */
62  void setNickname(QString nickname);
63  /** Gets the server's nickname. */
64  QString getNickname();
65 
66  /** Sets the server operator's contact information. */
67  void setContactInfo(QString info);
68  /** Gets the server operator's contact information. */
69  QString getContactInfo();
70 
71  /** Enables or disables the server to act as a directory mirror. */
72  void setDirectoryMirror(bool mirror);
73  /** Returns true if the server will mirror the directory. */
74  bool isDirectoryMirror();
75  /** Sets the exit policy for this server. */
76  void setExitPolicy(ExitPolicy &policy);
77  /** Gets the exit policy for this server. */
79 
80  /** Sets the long-term average bandwidth rate (in KB/s) of this server. */
81  void setBandwidthAvgRate(quint32 rate);
82  /** Gets the long-term average bandwidth rate (in KB/s) of this server. */
84 
85  /** Sets the maximum burst rate (in B/s) of this server. */
86  void setBandwidthBurstRate(quint32 rate);
87  /** Gets the maximum burst rate (in B/s) of this server. */
89 
90  /** Sets whether the user's server descriptor will be published or not.
91  * Currently this only affects publishing of bridge descriptors. If the
92  * user is running a normal relay, its descriptor will always be
93  * published regardless of this setting. */
94  void setPublishServerDescriptor(bool publish);
95  /** Returns true if the user's server descriptor will be published to
96  * the appropriate authorities. */
97  bool publishServerDescriptor() const;
98 
99  /** Configure port forwarding. */
101 
102  void cleanupPortForwarding();
103 
104  /** Returns true if UPnP support is enabled. */
105  bool isUpnpEnabled();
106  /** Sets whether Vidalia should try to configure port forwarding using UPnP. */
107  void setUpnpEnabled(bool enabled);
108 
109 protected:
110  /** Virtual method called when we retrieve a server-related setting from Tor.
111  * Currently this just translates BandwidthFoo to RelayBandwidthFoo when
112  * appropriate. */
113  virtual QVariant torValue(const QString &key) const;
114 
115 private:
116  /** Returns Tor-recognizable configuration keys and current values. */
117  QHash<QString,QString> confValues();
118 };
119 
120 #endif
121 
ServerSettings::getContactInfo
QString getContactInfo()
Definition: ServerSettings.cpp:331
ServerSettings::setPublishServerDescriptor
void setPublishServerDescriptor(bool publish)
Definition: ServerSettings.cpp:397
ServerSettings::ServerSettings
ServerSettings(TorControl *torControl)
Definition: ServerSettings.cpp:57
ServerSettings::setNonExitEnabled
void setNonExitEnabled(bool enable)
Definition: ServerSettings.cpp:265
ServerSettings::getBandwidthBurstRate
quint32 getBandwidthBurstRate()
Definition: ServerSettings.cpp:380
ServerSettings::cleanupPortForwarding
void cleanupPortForwarding()
Definition: ServerSettings.cpp:202
ServerSettings::getBandwidthAvgRate
quint32 getBandwidthAvgRate()
Definition: ServerSettings.cpp:366
ServerSettings::setExitPolicy
void setExitPolicy(ExitPolicy &policy)
Definition: ServerSettings.cpp:359
ServerSettings::setORPort
void setORPort(quint16 orPort)
Definition: ServerSettings.cpp:279
ServerSettings::getExitPolicy
ExitPolicy getExitPolicy()
Definition: ServerSettings.cpp:352
TorControl
Definition: TorControl.h:49
ServerSettings::isUpnpEnabled
bool isUpnpEnabled()
Definition: ServerSettings.cpp:415
ServerSettings::isBridgeEnabled
bool isBridgeEnabled()
Definition: ServerSettings.cpp:257
ServerSettings::isNonExitEnabled
bool isNonExitEnabled()
Definition: ServerSettings.cpp:272
ServerSettings::isDirectoryMirror
bool isDirectoryMirror()
Definition: ServerSettings.cpp:338
QVariant
stop errmsg QVariant
Definition: TorControlPrototype.cpp:180
ServerSettings::setDirPort
void setDirPort(quint16 dirPort)
Definition: ServerSettings.cpp:293
ServerSettings::setServerEnabled
void setServerEnabled(bool enable)
Definition: ServerSettings.cpp:228
ServerSettings::torValue
virtual QVariant torValue(const QString &key) const
Definition: ServerSettings.cpp:213
ServerSettings::isServerEnabled
bool isServerEnabled()
Definition: ServerSettings.cpp:237
AbstractTorSettings::torControl
TorControl * torControl() const
Definition: AbstractTorSettings.h:68
ServerSettings::setBridgeEnabled
void setBridgeEnabled(bool enable)
Definition: ServerSettings.cpp:250
ServerSettings::setDirectoryMirror
void setDirectoryMirror(bool mirror)
Definition: ServerSettings.cpp:345
ServerSettings
Definition: ServerSettings.h:23
ServerSettings::setContactInfo
void setContactInfo(QString info)
Definition: ServerSettings.cpp:324
ServerSettings::getNickname
QString getNickname()
Definition: ServerSettings.cpp:314
ExitPolicy
Definition: ExitPolicy.h:26
ServerSettings::setBandwidthBurstRate
void setBandwidthBurstRate(quint32 rate)
Definition: ServerSettings.cpp:387
AbstractTorSettings.h
ServerSettings::setUpnpEnabled
void setUpnpEnabled(bool enabled)
Definition: ServerSettings.cpp:427
ServerSettings::publishServerDescriptor
bool publishServerDescriptor() const
Definition: ServerSettings.cpp:408
ServerSettings::configurePortForwarding
void configurePortForwarding()
Definition: ServerSettings.cpp:179
ServerSettings::getORPort
quint16 getORPort()
Definition: ServerSettings.cpp:286
ServerSettings::getDirPort
quint16 getDirPort()
Definition: ServerSettings.cpp:300
ServerSettings::confValues
QHash< QString, QString > confValues()
Definition: ServerSettings.cpp:84
ServerSettings::setNickname
void setNickname(QString nickname)
Definition: ServerSettings.cpp:307
AbstractTorSettings
Definition: AbstractTorSettings.h:22
quint32
quint32
Definition: TorControlPrototype.cpp:222
ExitPolicy.h
ServerSettings::setBandwidthAvgRate
void setBandwidthAvgRate(quint32 rate)
Definition: ServerSettings.cpp:373
ServerSettings::apply
bool apply(QString *errmsg=0)
Definition: ServerSettings.cpp:141