Vidalia 0.2.12

ServerSettings.h

Go to the documentation of this file.
00001 /*
00002 **  This file is part of Vidalia, and is subject to the license terms in the
00003 **  LICENSE file, found in the top level directory of this distribution. If you
00004 **  did not receive the LICENSE file with this file, you may obtain it from the
00005 **  Vidalia source package distributed by the Vidalia Project at
00006 **  http://www.vidalia-project.net/. No part of Vidalia, including this file,
00007 **  may be copied, modified, propagated, or distributed except according to the
00008 **  terms described in the LICENSE file.
00009 */
00010 
00011 /*
00012 ** \file ServerSettings.h
00013 ** \brief Settings for running a Tor server
00014 */
00015 
00016 #ifndef _SERVERSETTINGS_H
00017 #define _SERVERSETTINGS_H
00018 
00019 #include "AbstractTorSettings.h"
00020 #include "ExitPolicy.h"
00021 
00022 
00023 class ServerSettings : public AbstractTorSettings
00024 {
00025   Q_OBJECT
00026 
00027 public:
00028   /** Constructor */
00029   ServerSettings(TorControl *torControl);
00030 
00031   /** Applies changese to Tor. */
00032   bool apply(QString *errmsg = 0);
00033 
00034   /** Enables running Tor as a server. */
00035   void setServerEnabled(bool enable);
00036   /** Returns true if Tor is running as a server. */
00037   bool isServerEnabled();
00038   
00039   /** Sets to <b>enabled</b> whether Tor should be a bridge node when acting
00040    * as a server. */
00041   void setBridgeEnabled(bool enable);
00042   /** Returns true if Tor is configured to act as a bridge node. */
00043   bool isBridgeEnabled();
00044 
00045   /** Sets the server's ORPort value. */
00046   void setORPort(quint16 orPort);
00047   /** Gets the server's ORPort value. */
00048   quint16 getORPort();
00049 
00050   /** Sets the server's DirPort value. */
00051   void setDirPort(quint16 dirPort);
00052   /** Gets the server's DirPort value. */
00053   quint16 getDirPort();
00054  
00055   /** Sets the server's nickname. */
00056   void setNickname(QString nickname);
00057   /** Gets the server's nickname. */
00058   QString getNickname();
00059   
00060   /** Sets the server operator's contact information. */
00061   void setContactInfo(QString info);
00062   /** Gets the server operator's contact information. */
00063   QString getContactInfo();
00064 
00065   /** Enables or disables the server to act as a directory mirror. */
00066   void setDirectoryMirror(bool mirror);
00067   /** Returns true if the server will mirror the directory. */
00068   bool isDirectoryMirror();
00069   /** Sets the exit policy for this server. */
00070   void setExitPolicy(ExitPolicy &policy);
00071   /** Gets the exit policy for this server. */
00072   ExitPolicy getExitPolicy();
00073   
00074   /** Sets the long-term average bandwidth rate (in KB/s) of this server. */
00075   void setBandwidthAvgRate(quint32 rate);
00076   /** Gets the long-term average bandwidth rate (in KB/s) of this server. */
00077   quint32 getBandwidthAvgRate();
00078 
00079   /** Sets the maximum burst rate (in B/s) of this server. */
00080   void setBandwidthBurstRate(quint32 rate);
00081   /** Gets the maximum burst rate (in B/s) of this server. */
00082   quint32 getBandwidthBurstRate();
00083 
00084   /** Sets whether the user's server descriptor will be published or not.
00085    * Currently this only affects publishing of bridge descriptors. If the
00086    * user is running a normal relay, its descriptor will always be
00087    * published regardless of this setting. */
00088   void setPublishServerDescriptor(bool publish);
00089   /** Returns true if the user's server descriptor will be published to
00090    * the appropriate authorities. */
00091   bool publishServerDescriptor() const;
00092 
00093   /** Configure port forwarding. */
00094   void configurePortForwarding();
00095 
00096   void cleanupPortForwarding();
00097 
00098   /** Returns true if UPnP support is enabled. */
00099   bool isUpnpEnabled();
00100   /** Sets whether Vidalia should try to configure port forwarding using UPnP. */
00101   void setUpnpEnabled(bool enabled);
00102 
00103 protected:
00104   /** Virtual method called when we retrieve a server-related setting from Tor.
00105    * Currently this just translates BandwidthFoo to RelayBandwidthFoo when
00106    * appropriate. */
00107   virtual QVariant torValue(const QString &key) const;
00108 
00109 private:
00110   /** Returns Tor-recognizable configuration keys and current values. */
00111   QHash<QString,QString> confValues();
00112 };
00113 
00114 #endif
00115