Vidalia  0.2.21
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. */
83  quint32 getBandwidthAvgRate();
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. */
88  quint32 getBandwidthBurstRate();
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