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 ** \version $Id: serversettings.h 2638 2008-06-01 23:42:53Z edmanm $ 00014 ** \brief Settings for running a Tor server 00015 */ 00016 00017 #ifndef _SERVERSETTINGS_H 00018 #define _SERVERSETTINGS_H 00019 00020 #include "abstracttorsettings.h" 00021 #include "exitpolicy.h" 00022 00023 00024 class ServerSettings : public AbstractTorSettings 00025 { 00026 Q_OBJECT 00027 00028 public: 00029 /** Constructor */ 00030 ServerSettings(TorControl *torControl); 00031 00032 /** Applies changese to Tor. */ 00033 bool apply(QString *errmsg = 0); 00034 00035 /** Enables running Tor as a server. */ 00036 void setServerEnabled(bool enable); 00037 /** Returns true if Tor is running as a server. */ 00038 bool isServerEnabled(); 00039 00040 /** Sets to <b>enabled</b> whether Tor should be a bridge node when acting 00041 * as a server. */ 00042 void setBridgeEnabled(bool enable); 00043 /** Returns true if Tor is configured to act as a bridge node. */ 00044 bool isBridgeEnabled(); 00045 00046 /** Sets the server's ORPort value. */ 00047 void setORPort(quint16 orPort); 00048 /** Gets the server's ORPort value. */ 00049 quint16 getORPort(); 00050 00051 /** Sets the server's DirPort value. */ 00052 void setDirPort(quint16 dirPort); 00053 /** Gets the server's DirPort value. */ 00054 quint16 getDirPort(); 00055 00056 /** Sets the server's nickname. */ 00057 void setNickname(QString nickname); 00058 /** Gets the server's nickname. */ 00059 QString getNickname(); 00060 00061 /** Sets the server operator's contact information. */ 00062 void setContactInfo(QString info); 00063 /** Gets the server operator's contact information. */ 00064 QString getContactInfo(); 00065 00066 /** Enables or disables the server to act as a directory mirror. */ 00067 void setDirectoryMirror(bool mirror); 00068 /** Returns true if the server will mirror the directory. */ 00069 bool isDirectoryMirror(); 00070 /** Sets the exit policy for this server. */ 00071 void setExitPolicy(ExitPolicy &policy); 00072 /** Gets the exit policy for this server. */ 00073 ExitPolicy getExitPolicy(); 00074 00075 /** Sets the long-term average bandwidth rate (in KB/s) of this server. */ 00076 void setBandwidthAvgRate(quint32 rate); 00077 /** Gets the long-term average bandwidth rate (in KB/s) of this server. */ 00078 quint32 getBandwidthAvgRate(); 00079 00080 /** Sets the maximum burst rate (in B/s) of this server. */ 00081 void setBandwidthBurstRate(quint32 rate); 00082 /** Gets the maximum burst rate (in B/s) of this server. */ 00083 quint32 getBandwidthBurstRate(); 00084 00085 /** Configure port forwarding. */ 00086 void configurePortForwarding(); 00087 00088 void cleanupPortForwarding(); 00089 00090 /** Returns true if UPnP support is enabled. */ 00091 bool isUpnpEnabled(); 00092 /** Sets whether Vidalia should try to configure port forwarding using UPnP. */ 00093 void setUpnpEnabled(bool enabled); 00094 00095 protected: 00096 /** Virtual method called when we retrieve a server-related setting from Tor. 00097 * Currently this just translates BandwidthFoo to RelayBandwidthFoo when 00098 * appropriate. */ 00099 virtual QVariant torValue(const QString &key) const; 00100 00101 private: 00102 /** Returns Tor-recognizable configuration keys and current values. */ 00103 QHash<QString,QString> confValues(); 00104 }; 00105 00106 #endif 00107