00001 /**************************************************************** 00002 * Vidalia is distributed under the following license: 00003 * 00004 * Copyright (C) 2006, Matt Edman, Justin Hipple 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 ****************************************************************/ 00021 00022 /** 00023 * \file serversettings.h 00024 * \version $Id: serversettings.h 1789 2007-06-17 13:04:42Z edmanm $ 00025 * \brief Settings for running a Tor server 00026 */ 00027 00028 #ifndef _SERVERSETTINGS_H 00029 #define _SERVERSETTINGS_H 00030 00031 #include <control/torcontrol.h> 00032 00033 #include "vidaliasettings.h" 00034 #include "exitpolicy.h" 00035 00036 00037 class ServerSettings : private VidaliaSettings 00038 { 00039 00040 public: 00041 /** Constructor */ 00042 ServerSettings(TorControl *torControl); 00043 00044 /** Reverts all settings changes since the last apply. */ 00045 void revert(); 00046 /** Returns true if the settings have changed since the last apply. */ 00047 bool changedSinceLastApply(); 00048 /** Applies changese to Tor. */ 00049 bool apply(QString *errmsg = 0); 00050 00051 /** Enables running Tor as a server. */ 00052 void setServerEnabled(bool enable); 00053 /** Returns true if Tor is running as a server. */ 00054 bool isServerEnabled(); 00055 00056 /** Sets the server's ORPort value. */ 00057 void setORPort(quint16 orPort); 00058 /** Gets the server's ORPort value. */ 00059 quint16 getORPort(); 00060 00061 /** Sets the server's DirPort value. */ 00062 void setDirPort(quint16 dirPort); 00063 /** Gets the server's DirPort value. */ 00064 quint16 getDirPort(); 00065 00066 /** Sets the server's nickname. */ 00067 void setNickname(QString nickname); 00068 /** Gets the server's nickname. */ 00069 QString getNickname(); 00070 00071 /** Sets the server operator's contact information. */ 00072 void setContactInfo(QString info); 00073 /** Gets the server operator's contact information. */ 00074 QString getContactInfo(); 00075 00076 /** Enables or disables the server to act as a directory mirror. */ 00077 void setDirectoryMirror(bool mirror); 00078 /** Returns true if the server will mirror the directory. */ 00079 bool isDirectoryMirror(); 00080 /** Sets the exit policy for this server. */ 00081 void setExitPolicy(ExitPolicy &policy); 00082 /** Gets the exit policy for this server. */ 00083 ExitPolicy getExitPolicy(); 00084 00085 /** Sets the long-term average bandwidth rate (in KB/s) of this server. */ 00086 void setBandwidthAvgRate(quint32 rate); 00087 /** Gets the long-term average bandwidth rate (in KB/s) of this server. */ 00088 quint32 getBandwidthAvgRate(); 00089 00090 /** Sets the maximum burst rate (in B/s) of this server. */ 00091 void setBandwidthBurstRate(quint32 rate); 00092 /** Gets the maximum burst rate (in B/s) of this server. */ 00093 quint32 getBandwidthBurstRate(); 00094 00095 private: 00096 /** Sets a value indicating that the server settings have changed since 00097 * apply() was last called. */ 00098 void setChanged(bool changed); 00099 00100 /** Returns Tor-recognizable configuration keys and current values. */ 00101 QHash<QString,QString> confValues(); 00102 00103 /** Returns all currently stored server settings. */ 00104 QMap<QString, QVariant> allSettings(); 00105 00106 /** Returns true if the specified QVariant contains an empty value. */ 00107 bool isEmptyValue(QVariant value); 00108 /** Retrieves a configuration value. If one isn't found, use a default. */ 00109 QVariant value(QString key); 00110 /** Stores a configuration key-value. */ 00111 void setValue(QString key, QVariant value); 00112 00113 /** A TorControl object used to talk to Tor. */ 00114 TorControl* _torControl; 00115 /** Values of all stored settings at the last apply() point. */ 00116 QMap<QString, QVariant> _backupSettings; 00117 }; 00118 00119 #endif 00120