Vidalia  0.2.17
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.torproject.org/projects/vidalia.html. No part of Vidalia, 
00007 **  including this file, may be copied, modified, propagated, or distributed 
00008 **  except according to the 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 to <b>enabled</b> whether Tor should be a non-exit node when acting
00046    * as a server. */
00047   void setNonExitEnabled(bool enable);
00048   /** Returns true if Tor is configured to act as a non-exit node. */
00049   bool isNonExitEnabled();
00050 
00051   /** Sets the server's ORPort value. */
00052   void setORPort(quint16 orPort);
00053   /** Gets the server's ORPort value. */
00054   quint16 getORPort();
00055 
00056   /** Sets the server's DirPort value. */
00057   void setDirPort(quint16 dirPort);
00058   /** Gets the server's DirPort value. */
00059   quint16 getDirPort();
00060  
00061   /** Sets the server's nickname. */
00062   void setNickname(QString nickname);
00063   /** Gets the server's nickname. */
00064   QString getNickname();
00065   
00066   /** Sets the server operator's contact information. */
00067   void setContactInfo(QString info);
00068   /** Gets the server operator's contact information. */
00069   QString getContactInfo();
00070 
00071   /** Enables or disables the server to act as a directory mirror. */
00072   void setDirectoryMirror(bool mirror);
00073   /** Returns true if the server will mirror the directory. */
00074   bool isDirectoryMirror();
00075   /** Sets the exit policy for this server. */
00076   void setExitPolicy(ExitPolicy &policy);
00077   /** Gets the exit policy for this server. */
00078   ExitPolicy getExitPolicy();
00079   
00080   /** Sets the long-term average bandwidth rate (in KB/s) of this server. */
00081   void setBandwidthAvgRate(quint32 rate);
00082   /** Gets the long-term average bandwidth rate (in KB/s) of this server. */
00083   quint32 getBandwidthAvgRate();
00084 
00085   /** Sets the maximum burst rate (in B/s) of this server. */
00086   void setBandwidthBurstRate(quint32 rate);
00087   /** Gets the maximum burst rate (in B/s) of this server. */
00088   quint32 getBandwidthBurstRate();
00089 
00090   /** Sets whether the user's server descriptor will be published or not.
00091    * Currently this only affects publishing of bridge descriptors. If the
00092    * user is running a normal relay, its descriptor will always be
00093    * published regardless of this setting. */
00094   void setPublishServerDescriptor(bool publish);
00095   /** Returns true if the user's server descriptor will be published to
00096    * the appropriate authorities. */
00097   bool publishServerDescriptor() const;
00098 
00099   /** Configure port forwarding. */
00100   void configurePortForwarding();
00101 
00102   void cleanupPortForwarding();
00103 
00104   /** Returns true if UPnP support is enabled. */
00105   bool isUpnpEnabled();
00106   /** Sets whether Vidalia should try to configure port forwarding using UPnP. */
00107   void setUpnpEnabled(bool enabled);
00108 
00109 protected:
00110   /** Virtual method called when we retrieve a server-related setting from Tor.
00111    * Currently this just translates BandwidthFoo to RelayBandwidthFoo when
00112    * appropriate. */
00113   virtual QVariant torValue(const QString &key) const;
00114 
00115 private:
00116   /** Returns Tor-recognizable configuration keys and current values. */
00117   QHash<QString,QString> confValues();
00118 };
00119 
00120 #endif
00121