<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>Vidalia: ServerSettings.cpp Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.3 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="dir_b47abd1aad201a152869566145babb61.html">src</a> » <a class="el" href="dir_695ba8f8357372e02d38c40b3c6dbe81.html">vidalia</a> » <a class="el" href="dir_738aec08306f4b898e01f7a551299457.html">config</a> </div> </div> <div class="contents"> <h1>ServerSettings.cpp</h1><a href="_server_settings_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment">** This file is part of Vidalia, and is subject to the license terms in the</span> <a name="l00003"></a>00003 <span class="comment">** LICENSE file, found in the top level directory of this distribution. If you</span> <a name="l00004"></a>00004 <span class="comment">** did not receive the LICENSE file with this file, you may obtain it from the</span> <a name="l00005"></a>00005 <span class="comment">** Vidalia source package distributed by the Vidalia Project at</span> <a name="l00006"></a>00006 <span class="comment">** http://www.vidalia-project.net/. No part of Vidalia, including this file,</span> <a name="l00007"></a>00007 <span class="comment">** may be copied, modified, propagated, or distributed except according to the</span> <a name="l00008"></a>00008 <span class="comment">** terms described in the LICENSE file.</span> <a name="l00009"></a>00009 <span class="comment">*/</span> <a name="l00010"></a>00010 <a name="l00011"></a>00011 <span class="comment">/*</span> <a name="l00012"></a>00012 <span class="comment">** \file ServerSettings.cpp</span> <a name="l00013"></a>00013 <span class="comment">** \version $Id: ServerSettings.cpp 4143 2009-10-12 00:59:22Z edmanm $</span> <a name="l00014"></a>00014 <span class="comment">** \brief Settings for running a Tor server</span> <a name="l00015"></a>00015 <span class="comment">*/</span> <a name="l00016"></a>00016 <a name="l00017"></a>00017 <span class="preprocessor">#include "<a class="code" href="config_8h.html">config.h</a>"</span> <a name="l00018"></a>00018 <span class="preprocessor">#include "<a class="code" href="_server_settings_8h.html">ServerSettings.h</a>"</span> <a name="l00019"></a>00019 <span class="preprocessor">#include "<a class="code" href="_tor_settings_8h.html">TorSettings.h</a>"</span> <a name="l00020"></a>00020 <span class="preprocessor">#ifdef USE_MINIUPNPC</span> <a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="_u_p_n_p_control_8h.html">UPNPControl.h</a>"</span> <a name="l00022"></a>00022 <span class="preprocessor">#endif</span> <a name="l00023"></a>00023 <span class="preprocessor"></span> <a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="net_8h.html">net.h</a>"</span> <a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="stringutil_8h.html">stringutil.h</a>"</span> <a name="l00026"></a>00026 <a name="l00027"></a>00027 <span class="preprocessor">#include <QHostInfo></span> <a name="l00028"></a>00028 <span class="comment"></span> <a name="l00029"></a>00029 <span class="comment">/** Define the set of characters that are valid in a nickname. */</span> <a name="l00030"></a><a class="code" href="_server_settings_8cpp.html#afeafddd1f05e9b838d2468377e525be8">00030</a> <span class="preprocessor">#define VALID_NICKNAME_CHARS \</span> <a name="l00031"></a>00031 <span class="preprocessor"> "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"</span> <a name="l00032"></a>00032 <span class="preprocessor"></span><span class="comment">/** Define the maximum length of a server's nickname. */</span> <a name="l00033"></a><a class="code" href="_server_settings_8cpp.html#a0929ff1a585dc55520c5b872f79c3e43">00033</a> <span class="preprocessor">#define MAX_NICKNAME_LEN 19</span> <a name="l00034"></a>00034 <span class="preprocessor"></span> <a name="l00035"></a>00035 <span class="comment">/* Server configuration settings */</span> <a name="l00036"></a><a class="code" href="_server_settings_8cpp.html#a5fba69e5fc55de63ca6f97c159b05ce4">00036</a> <span class="preprocessor">#define SETTING_ENABLED "Enabled"</span> <a name="l00037"></a><a class="code" href="_server_settings_8cpp.html#a31bee2dae94f6c2933421d25625b24d9">00037</a> <span class="preprocessor"></span><span class="preprocessor">#define SETTING_DIRMIRROR "DirectoryMirror"</span> <a name="l00038"></a><a class="code" href="_server_settings_8cpp.html#aec16b866bc88d47755c9ac7fe196f29d">00038</a> <span class="preprocessor"></span><span class="preprocessor">#define SETTING_NICKNAME "Nickname"</span> <a name="l00039"></a><a class="code" href="_server_settings_8cpp.html#a98cc7ed39cadd5da9c5ec4f8585b302b">00039</a> <span class="preprocessor"></span><span class="preprocessor">#define SETTING_ORPORT "ORPort"</span> <a name="l00040"></a><a class="code" href="_server_settings_8cpp.html#ab2c872ca73ec73efd890398d18fe7d4e">00040</a> <span class="preprocessor"></span><span class="preprocessor">#define SETTING_DIRPORT "DirPort"</span> <a name="l00041"></a><a class="code" href="_server_settings_8cpp.html#a424a0c131fab58f9052f594e5b688771">00041</a> <span class="preprocessor"></span><span class="preprocessor">#define SETTING_CONTACT "ContactInfo"</span> <a name="l00042"></a><a class="code" href="_server_settings_8cpp.html#a64de7b6529282213b9b6944191494b5f">00042</a> <span class="preprocessor"></span><span class="preprocessor">#define SETTING_EXITPOLICY "ExitPolicy"</span> <a name="l00043"></a><a class="code" href="_server_settings_8cpp.html#a7fc1febee4b7077b9cb0e074e886eeea">00043</a> <span class="preprocessor"></span><span class="preprocessor">#define SETTING_BANDWIDTH_RATE "BandwidthRate"</span> <a name="l00044"></a><a class="code" href="_server_settings_8cpp.html#a6f1a1925359b933919cf5ff533ad7bb8">00044</a> <span class="preprocessor"></span><span class="preprocessor">#define SETTING_BANDWIDTH_BURST "BandwidthBurst"</span> <a name="l00045"></a><a class="code" href="_server_settings_8cpp.html#a28e1abcac51a8e5a8361c0b8994cc3b0">00045</a> <span class="preprocessor"></span><span class="preprocessor">#define SETTING_BRIDGE_RELAY "BridgeRelay"</span> <a name="l00046"></a><a class="code" href="_server_settings_8cpp.html#aa0d9c39c77bd12a25422f0df4efabaf5">00046</a> <span class="preprocessor"></span><span class="preprocessor">#define SETTING_ENABLE_UPNP "EnableUPnP"</span> <a name="l00047"></a><a class="code" href="_server_settings_8cpp.html#aeda76480b4d1583b291d500471877d3f">00047</a> <span class="preprocessor"></span><span class="preprocessor">#define SETTING_RELAY_BANDWIDTH_RATE "RelayBandwidthRate"</span> <a name="l00048"></a><a class="code" href="_server_settings_8cpp.html#a72daca616b231e93a8a43d3002fc3289">00048</a> <span class="preprocessor"></span><span class="preprocessor">#define SETTING_RELAY_BANDWIDTH_BURST "RelayBandwidthBurst"</span> <a name="l00049"></a><a class="code" href="_server_settings_8cpp.html#aa98dd71e345116ec53e2bd6ab9b0d32c">00049</a> <span class="preprocessor"></span><span class="preprocessor">#define SETTING_PUBLISH_SERVER_DESCRIPTOR "PublishServerDescriptor"</span> <a name="l00050"></a>00050 <span class="preprocessor"></span> <a name="l00051"></a>00051 <span class="comment"></span> <a name="l00052"></a>00052 <span class="comment">/** Constructor.</span> <a name="l00053"></a>00053 <span class="comment"> * \param torControl a TorControl object used to read and apply the server</span> <a name="l00054"></a>00054 <span class="comment"> * configuration settings.</span> <a name="l00055"></a>00055 <span class="comment"> */</span> <a name="l00056"></a><a class="code" href="class_server_settings.html#afd3b5060bd7dba76a8ff73f47a5c2081">00056</a> <a class="code" href="class_server_settings.html#afd3b5060bd7dba76a8ff73f47a5c2081">ServerSettings::ServerSettings</a>(<a class="code" href="class_tor_control.html">TorControl</a> *torControl) <a name="l00057"></a>00057 : <a class="code" href="class_abstract_tor_settings.html">AbstractTorSettings</a>(<span class="stringliteral">"Server"</span>, torControl) <a name="l00058"></a>00058 { <a name="l00059"></a>00059 <a class="code" href="class_v_settings.html#aebcf7105467fb91077fbb4470fcf9624">setDefault</a>(<a class="code" href="_server_settings_8cpp.html#a5fba69e5fc55de63ca6f97c159b05ce4">SETTING_ENABLED</a>, <span class="keyword">false</span>); <a name="l00060"></a>00060 <a class="code" href="class_v_settings.html#aebcf7105467fb91077fbb4470fcf9624">setDefault</a>(<a class="code" href="_server_settings_8cpp.html#a31bee2dae94f6c2933421d25625b24d9">SETTING_DIRMIRROR</a>, <span class="keyword">true</span>); <a name="l00061"></a>00061 <span class="preprocessor">#if defined(Q_OS_WIN32)</span> <a name="l00062"></a>00062 <span class="preprocessor"></span> <a class="code" href="class_v_settings.html#aebcf7105467fb91077fbb4470fcf9624">setDefault</a>(<a class="code" href="_server_settings_8cpp.html#a98cc7ed39cadd5da9c5ec4f8585b302b">SETTING_ORPORT</a>, 443); <a name="l00063"></a>00063 <span class="preprocessor">#else</span> <a name="l00064"></a>00064 <span class="preprocessor"></span> <a class="code" href="class_v_settings.html#aebcf7105467fb91077fbb4470fcf9624">setDefault</a>(<a class="code" href="_server_settings_8cpp.html#a98cc7ed39cadd5da9c5ec4f8585b302b">SETTING_ORPORT</a>, 9001); <a name="l00065"></a>00065 <span class="preprocessor">#endif</span> <a name="l00066"></a>00066 <span class="preprocessor"></span> <a class="code" href="class_v_settings.html#aebcf7105467fb91077fbb4470fcf9624">setDefault</a>(<a class="code" href="_server_settings_8cpp.html#ab2c872ca73ec73efd890398d18fe7d4e">SETTING_DIRPORT</a>, 9030); <a name="l00067"></a>00067 <a class="code" href="class_v_settings.html#aebcf7105467fb91077fbb4470fcf9624">setDefault</a>(<a class="code" href="_server_settings_8cpp.html#aec16b866bc88d47755c9ac7fe196f29d">SETTING_NICKNAME</a>, <span class="stringliteral">"Unnamed"</span>); <a name="l00068"></a>00068 <a class="code" href="class_v_settings.html#aebcf7105467fb91077fbb4470fcf9624">setDefault</a>(<a class="code" href="_server_settings_8cpp.html#a424a0c131fab58f9052f594e5b688771">SETTING_CONTACT</a>, <span class="stringliteral">"<you@example.com>"</span>); <a name="l00069"></a>00069 <a class="code" href="class_v_settings.html#aebcf7105467fb91077fbb4470fcf9624">setDefault</a>(<a class="code" href="_server_settings_8cpp.html#a7fc1febee4b7077b9cb0e074e886eeea">SETTING_BANDWIDTH_RATE</a>, 5242880); <a name="l00070"></a>00070 <a class="code" href="class_v_settings.html#aebcf7105467fb91077fbb4470fcf9624">setDefault</a>(<a class="code" href="_server_settings_8cpp.html#aeda76480b4d1583b291d500471877d3f">SETTING_RELAY_BANDWIDTH_RATE</a>, 5242880); <a name="l00071"></a>00071 <a class="code" href="class_v_settings.html#aebcf7105467fb91077fbb4470fcf9624">setDefault</a>(<a class="code" href="_server_settings_8cpp.html#a6f1a1925359b933919cf5ff533ad7bb8">SETTING_BANDWIDTH_BURST</a>, 10485760); <a name="l00072"></a>00072 <a class="code" href="class_v_settings.html#aebcf7105467fb91077fbb4470fcf9624">setDefault</a>(<a class="code" href="_server_settings_8cpp.html#a72daca616b231e93a8a43d3002fc3289">SETTING_RELAY_BANDWIDTH_BURST</a>, 10485760); <a name="l00073"></a>00073 <a class="code" href="class_v_settings.html#aebcf7105467fb91077fbb4470fcf9624">setDefault</a>(<a class="code" href="_server_settings_8cpp.html#a64de7b6529282213b9b6944191494b5f">SETTING_EXITPOLICY</a>, <a name="l00074"></a>00074 <a class="code" href="class_exit_policy.html">ExitPolicy</a>(<a class="code" href="class_exit_policy.html#aa76586108b81e24f0bd8dfb51bd77ab8a4a36006dbba2412e631cb58c1f9ef1be">ExitPolicy::Default</a>).toString()); <a name="l00075"></a>00075 <a class="code" href="class_v_settings.html#aebcf7105467fb91077fbb4470fcf9624">setDefault</a>(<a class="code" href="_server_settings_8cpp.html#aa0d9c39c77bd12a25422f0df4efabaf5">SETTING_ENABLE_UPNP</a>, <span class="keyword">false</span>); <a name="l00076"></a>00076 <a class="code" href="class_v_settings.html#aebcf7105467fb91077fbb4470fcf9624">setDefault</a>(<a class="code" href="_server_settings_8cpp.html#a28e1abcac51a8e5a8361c0b8994cc3b0">SETTING_BRIDGE_RELAY</a>, <span class="keyword">false</span>); <a name="l00077"></a>00077 <a class="code" href="class_v_settings.html#aebcf7105467fb91077fbb4470fcf9624">setDefault</a>(<a class="code" href="_server_settings_8cpp.html#aa98dd71e345116ec53e2bd6ab9b0d32c">SETTING_PUBLISH_SERVER_DESCRIPTOR</a>, <span class="stringliteral">"1"</span>); <a name="l00078"></a>00078 } <a name="l00079"></a>00079 <span class="comment"></span> <a name="l00080"></a>00080 <span class="comment">/** Returns a QHash of Tor-recognizable configuratin keys to their current</span> <a name="l00081"></a>00081 <span class="comment"> * values. */</span> <a name="l00082"></a>00082 QHash<QString, QString> <a name="l00083"></a><a class="code" href="class_server_settings.html#a6ca0466032d355a9e90a013b669fda51">00083</a> <a class="code" href="class_server_settings.html#a6ca0466032d355a9e90a013b669fda51">ServerSettings::confValues</a>() <a name="l00084"></a>00084 { <a name="l00085"></a>00085 QHash<QString, QString> conf; <a name="l00086"></a>00086 quint32 torVersion = <a class="code" href="class_abstract_tor_settings.html#a1fd0bb636bfa8131f6261b1bc11aeee4">torControl</a>()-><a class="code" href="class_tor_control.html#acd37862e652425dec4329acef6df4f3e">getTorVersion</a>(); <a name="l00087"></a>00087 <a name="l00088"></a>00088 <span class="comment">/* Server Nickname */</span> <a name="l00089"></a>00089 conf.insert(<a class="code" href="_server_settings_8cpp.html#aec16b866bc88d47755c9ac7fe196f29d">SETTING_NICKNAME</a>, <a name="l00090"></a>00090 (<a class="code" href="class_server_settings.html#ad8d3c25facf05765a5379421a5f80da5">isServerEnabled</a>() ? <a class="code" href="class_abstract_tor_settings.html#a169f730fd477acb8f61cb5cf1026204f">localValue</a>(<a class="code" href="_server_settings_8cpp.html#aec16b866bc88d47755c9ac7fe196f29d">SETTING_NICKNAME</a>).toString() <a name="l00091"></a>00091 : <span class="stringliteral">""</span>)); <a name="l00092"></a>00092 <span class="comment">/* Server ORPort */</span> <a name="l00093"></a>00093 conf.insert(<a class="code" href="_server_settings_8cpp.html#a98cc7ed39cadd5da9c5ec4f8585b302b">SETTING_ORPORT</a>, <a name="l00094"></a>00094 (<a class="code" href="class_server_settings.html#ad8d3c25facf05765a5379421a5f80da5">isServerEnabled</a>() ? <a class="code" href="class_abstract_tor_settings.html#a169f730fd477acb8f61cb5cf1026204f">localValue</a>(<a class="code" href="_server_settings_8cpp.html#a98cc7ed39cadd5da9c5ec4f8585b302b">SETTING_ORPORT</a>).toString() <a name="l00095"></a>00095 : <span class="stringliteral">"0"</span>)); <a name="l00096"></a>00096 <span class="comment">/* Server DirPort */</span> <a name="l00097"></a>00097 conf.insert(<a class="code" href="_server_settings_8cpp.html#ab2c872ca73ec73efd890398d18fe7d4e">SETTING_DIRPORT</a>, <a name="l00098"></a>00098 (<a class="code" href="class_server_settings.html#a7779c3509d358077406b4e75cf9c7f7d">isDirectoryMirror</a>() ? <a class="code" href="class_abstract_tor_settings.html#a169f730fd477acb8f61cb5cf1026204f">localValue</a>(<a class="code" href="_server_settings_8cpp.html#ab2c872ca73ec73efd890398d18fe7d4e">SETTING_DIRPORT</a>).toString() <a name="l00099"></a>00099 : <span class="stringliteral">"0"</span>)); <a name="l00100"></a>00100 <span class="comment">/* Server Exit Policy */</span> <a name="l00101"></a>00101 conf.insert(<a class="code" href="_server_settings_8cpp.html#a64de7b6529282213b9b6944191494b5f">SETTING_EXITPOLICY</a>, <a name="l00102"></a>00102 (<a class="code" href="class_server_settings.html#a911acfd3a5ce7227e10e64f251ba44e0">isBridgeEnabled</a>() ? <span class="stringliteral">"reject *:*"</span> <a name="l00103"></a>00103 : <a class="code" href="class_abstract_tor_settings.html#a169f730fd477acb8f61cb5cf1026204f">localValue</a>(<a class="code" href="_server_settings_8cpp.html#a64de7b6529282213b9b6944191494b5f">SETTING_EXITPOLICY</a>).toString())); <a name="l00104"></a>00104 <a name="l00105"></a>00105 <span class="comment">/* Server bandwidth settings */</span> <a name="l00106"></a>00106 conf.insert((torVersion >= 0x020001 ? <a class="code" href="_server_settings_8cpp.html#aeda76480b4d1583b291d500471877d3f">SETTING_RELAY_BANDWIDTH_RATE</a> <a name="l00107"></a>00107 : <a class="code" href="_server_settings_8cpp.html#a7fc1febee4b7077b9cb0e074e886eeea">SETTING_BANDWIDTH_RATE</a>), <a name="l00108"></a>00108 QString::number(<a class="code" href="class_abstract_tor_settings.html#a169f730fd477acb8f61cb5cf1026204f">localValue</a>(SETTING_BANDWIDTH_RATE).toUInt()) + <span class="stringliteral">" bytes"</span>); <a name="l00109"></a>00109 conf.insert((torVersion >= 0x020001 ? <a class="code" href="_server_settings_8cpp.html#a72daca616b231e93a8a43d3002fc3289">SETTING_RELAY_BANDWIDTH_BURST</a> <a name="l00110"></a>00110 : <a class="code" href="_server_settings_8cpp.html#a6f1a1925359b933919cf5ff533ad7bb8">SETTING_BANDWIDTH_BURST</a>), <a name="l00111"></a>00111 QString::number(<a class="code" href="class_abstract_tor_settings.html#a169f730fd477acb8f61cb5cf1026204f">localValue</a>(SETTING_BANDWIDTH_BURST).toUInt()) + <span class="stringliteral">" bytes"</span>); <a name="l00112"></a>00112 <a name="l00113"></a>00113 <span class="comment">/* Server Contact Information */</span> <a name="l00114"></a>00114 QString contact = <a name="l00115"></a>00115 <a class="code" href="class_abstract_tor_settings.html#a169f730fd477acb8f61cb5cf1026204f">localValue</a>(<a class="code" href="_server_settings_8cpp.html#a424a0c131fab58f9052f594e5b688771">SETTING_CONTACT</a>).toString().trimmed(); <a name="l00116"></a>00116 QString defaultContact = <a class="code" href="class_v_settings.html#a76db82d5e923b9710c9318b50bd6ad67">defaultValue</a>(<a class="code" href="_server_settings_8cpp.html#a424a0c131fab58f9052f594e5b688771">SETTING_CONTACT</a>).toString(); <a name="l00117"></a>00117 <span class="keywordflow">if</span> ((contact == defaultContact) || <a name="l00118"></a>00118 (contact == <a class="code" href="stringutil_8cpp.html#ad6c76e6ae682c586a541b8391b02df5d">scrub_email_addr</a>(defaultContact))) { <a name="l00119"></a>00119 <span class="comment">/* Only set the contact info if they put something non-default there */</span> <a name="l00120"></a>00120 contact = <span class="stringliteral">""</span>; <a name="l00121"></a>00121 } <a name="l00122"></a>00122 conf.insert(<a class="code" href="_server_settings_8cpp.html#a424a0c131fab58f9052f594e5b688771">SETTING_CONTACT</a>, <a class="code" href="stringutil_8cpp.html#ad6c76e6ae682c586a541b8391b02df5d">scrub_email_addr</a>(contact)); <a name="l00123"></a>00123 <a name="l00124"></a>00124 <span class="comment">/* Set if we're a bridge relay */</span> <a name="l00125"></a>00125 <span class="keywordflow">if</span> (<a class="code" href="class_server_settings.html#a911acfd3a5ce7227e10e64f251ba44e0">isBridgeEnabled</a>()) { <a name="l00126"></a>00126 conf.insert(<a class="code" href="_server_settings_8cpp.html#a28e1abcac51a8e5a8361c0b8994cc3b0">SETTING_BRIDGE_RELAY</a>, <span class="stringliteral">"1"</span>); <a name="l00127"></a>00127 conf.insert(<a class="code" href="_server_settings_8cpp.html#aa98dd71e345116ec53e2bd6ab9b0d32c">SETTING_PUBLISH_SERVER_DESCRIPTOR</a>, <a name="l00128"></a>00128 <a class="code" href="class_server_settings.html#afc0daa865e87d83ef9050967ee3f9404">publishServerDescriptor</a>() ? <span class="stringliteral">"1"</span> : <span class="stringliteral">"0"</span>); <a name="l00129"></a>00129 } <span class="keywordflow">else</span> { <a name="l00130"></a>00130 conf.insert(<a class="code" href="_server_settings_8cpp.html#a28e1abcac51a8e5a8361c0b8994cc3b0">SETTING_BRIDGE_RELAY</a>, <span class="stringliteral">"0"</span>); <a name="l00131"></a>00131 conf.insert(<a class="code" href="_server_settings_8cpp.html#aa98dd71e345116ec53e2bd6ab9b0d32c">SETTING_PUBLISH_SERVER_DESCRIPTOR</a>, <span class="stringliteral">"1"</span>); <a name="l00132"></a>00132 } <a name="l00133"></a>00133 <span class="keywordflow">return</span> conf; <a name="l00134"></a>00134 } <a name="l00135"></a>00135 <span class="comment"></span> <a name="l00136"></a>00136 <span class="comment">/** Applies the current server configuration settings to Tor. If <b>errmsg</b></span> <a name="l00137"></a>00137 <span class="comment"> * is specified and an error occurs while applying the settings, it will be </span> <a name="l00138"></a>00138 <span class="comment"> * set to a string describing the error. */</span> <a name="l00139"></a>00139 <span class="keywordtype">bool</span> <a name="l00140"></a><a class="code" href="class_server_settings.html#a030fec2c0433a3106391bb1593382110">00140</a> <a class="code" href="class_server_settings.html#a030fec2c0433a3106391bb1593382110">ServerSettings::apply</a>(QString *errmsg) <a name="l00141"></a>00141 { <a name="l00142"></a>00142 <span class="keywordtype">bool</span> rc; <a name="l00143"></a>00143 <a name="l00144"></a>00144 <a class="code" href="class_server_settings.html#a23f08c9a01e392157a092edefa9fcae0">configurePortForwarding</a>(); <a name="l00145"></a>00145 <a name="l00146"></a>00146 <span class="keywordflow">if</span> (<a class="code" href="class_server_settings.html#ad8d3c25facf05765a5379421a5f80da5">isServerEnabled</a>()) { <a name="l00147"></a>00147 rc = <a class="code" href="class_abstract_tor_settings.html#a1fd0bb636bfa8131f6261b1bc11aeee4">torControl</a>()-><a class="code" href="class_tor_control.html#acd33beb0663b2a464a101c4efb425708">setConf</a>(<a class="code" href="class_server_settings.html#a6ca0466032d355a9e90a013b669fda51">confValues</a>(), errmsg); <a name="l00148"></a>00148 } <span class="keywordflow">else</span> { <a name="l00149"></a>00149 QStringList resetKeys; <a name="l00150"></a>00150 quint32 torVersion = <a class="code" href="class_abstract_tor_settings.html#a1fd0bb636bfa8131f6261b1bc11aeee4">torControl</a>()-><a class="code" href="class_tor_control.html#acd37862e652425dec4329acef6df4f3e">getTorVersion</a>(); <a name="l00151"></a>00151 resetKeys << <a class="code" href="_server_settings_8cpp.html#a98cc7ed39cadd5da9c5ec4f8585b302b">SETTING_ORPORT</a> <a name="l00152"></a>00152 << <a class="code" href="_server_settings_8cpp.html#aec16b866bc88d47755c9ac7fe196f29d">SETTING_NICKNAME</a> <a name="l00153"></a>00153 << <a class="code" href="_server_settings_8cpp.html#ab2c872ca73ec73efd890398d18fe7d4e">SETTING_DIRPORT</a> <a name="l00154"></a>00154 << <a class="code" href="_server_settings_8cpp.html#a424a0c131fab58f9052f594e5b688771">SETTING_CONTACT</a> <a name="l00155"></a>00155 << <a class="code" href="_server_settings_8cpp.html#a64de7b6529282213b9b6944191494b5f">SETTING_EXITPOLICY</a> <a name="l00156"></a>00156 << <a class="code" href="_server_settings_8cpp.html#a28e1abcac51a8e5a8361c0b8994cc3b0">SETTING_BRIDGE_RELAY</a> <a name="l00157"></a>00157 << <a class="code" href="_server_settings_8cpp.html#aa98dd71e345116ec53e2bd6ab9b0d32c">SETTING_PUBLISH_SERVER_DESCRIPTOR</a>; <a name="l00158"></a>00158 <span class="keywordflow">if</span> (torVersion >= 0x020001) { <a name="l00159"></a>00159 resetKeys << <a class="code" href="_server_settings_8cpp.html#aeda76480b4d1583b291d500471877d3f">SETTING_RELAY_BANDWIDTH_RATE</a> <a name="l00160"></a>00160 << <a class="code" href="_server_settings_8cpp.html#a72daca616b231e93a8a43d3002fc3289">SETTING_RELAY_BANDWIDTH_BURST</a>; <a name="l00161"></a>00161 } <span class="keywordflow">else</span> { <a name="l00162"></a>00162 resetKeys << <a class="code" href="_server_settings_8cpp.html#a7fc1febee4b7077b9cb0e074e886eeea">SETTING_BANDWIDTH_RATE</a> <a name="l00163"></a>00163 << <a class="code" href="_server_settings_8cpp.html#a6f1a1925359b933919cf5ff533ad7bb8">SETTING_BANDWIDTH_BURST</a>; <a name="l00164"></a>00164 } <a name="l00165"></a>00165 rc = <a class="code" href="class_abstract_tor_settings.html#a1fd0bb636bfa8131f6261b1bc11aeee4">torControl</a>()-><a class="code" href="class_tor_control.html#aba22570eab1b0ca3735d1a32dbcd3de9">resetConf</a>(resetKeys, errmsg); <a name="l00166"></a>00166 } <a name="l00167"></a>00167 <span class="keywordflow">return</span> rc; <a name="l00168"></a>00168 } <a name="l00169"></a>00169 <a name="l00170"></a>00170 <span class="comment">/* TODO: We should call this periodically, in case the router gets rebooted or forgets its UPnP settings */</span> <a name="l00171"></a>00171 <span class="comment">/* TODO: Remove port forwarding when Tor is shutdown or the ORPort changes */</span> <a name="l00172"></a>00172 <span class="comment">/* TODO: init_upnp() will block for up to 2 seconds. We should fire off a thread */</span> <a name="l00173"></a>00173 <span class="comment"></span> <a name="l00174"></a>00174 <span class="comment">/** Configure UPnP device to forward DirPort and ORPort. If enable is</span> <a name="l00175"></a>00175 <span class="comment"> * true, will forward ORPort and DirPort; otherwise will remove exising</span> <a name="l00176"></a>00176 <span class="comment"> * port mappings */</span> <a name="l00177"></a>00177 <span class="keywordtype">void</span> <a name="l00178"></a><a class="code" href="class_server_settings.html#a23f08c9a01e392157a092edefa9fcae0">00178</a> <a class="code" href="class_server_settings.html#a23f08c9a01e392157a092edefa9fcae0">ServerSettings::configurePortForwarding</a>() <a name="l00179"></a>00179 { <a name="l00180"></a>00180 <span class="preprocessor">#ifdef USE_MINIUPNPC</span> <a name="l00181"></a>00181 <span class="preprocessor"></span> quint16 ORPort, DirPort; <a name="l00182"></a>00182 <a name="l00183"></a>00183 <span class="comment">// This is how the tickbox should control UPNP</span> <a name="l00184"></a>00184 <span class="keywordflow">if</span> (!<a class="code" href="class_server_settings.html#a421e1da362a29f7d2a5bda3ba065faf2">isUpnpEnabled</a>()) <a name="l00185"></a>00185 <span class="keywordflow">return</span>; <a name="l00186"></a>00186 <a name="l00187"></a>00187 ORPort = <a class="code" href="class_server_settings.html#a6b919ff92a5c43e2163e595c6550ad5a">getORPort</a>(); <a name="l00188"></a>00188 <span class="keywordflow">if</span> (!<a class="code" href="class_server_settings.html#ad8d3c25facf05765a5379421a5f80da5">isServerEnabled</a>()) <a name="l00189"></a>00189 ORPort = 0; <a name="l00190"></a>00190 <a name="l00191"></a>00191 DirPort = <a class="code" href="class_server_settings.html#a2a3b7a0c5ab09cf6c7436b78addd37a7">getDirPort</a>(); <a name="l00192"></a>00192 <span class="keywordflow">if</span> (!<a class="code" href="class_server_settings.html#ad8d3c25facf05765a5379421a5f80da5">isServerEnabled</a>() || !<a class="code" href="class_server_settings.html#a7779c3509d358077406b4e75cf9c7f7d">isDirectoryMirror</a>()) <a name="l00193"></a>00193 DirPort = 0; <a name="l00194"></a>00194 <a name="l00195"></a>00195 <a class="code" href="class_u_p_n_p_control.html">UPNPControl</a> *control = <a class="code" href="class_u_p_n_p_control.html#a5046fdfc0449019c8d1e21ac0918dbb1">UPNPControl::instance</a>(); <a name="l00196"></a>00196 control-><a class="code" href="class_u_p_n_p_control.html#a32326c4e812a710434a747e89bdce54f">setDesiredState</a>(DirPort, ORPort); <a name="l00197"></a>00197 <span class="preprocessor">#endif</span> <a name="l00198"></a>00198 <span class="preprocessor"></span>} <a name="l00199"></a>00199 <a name="l00200"></a>00200 <span class="keywordtype">void</span> <a name="l00201"></a><a class="code" href="class_server_settings.html#a7ad953b22dcd629061e11b2a86d1c98f">00201</a> <a class="code" href="class_server_settings.html#a7ad953b22dcd629061e11b2a86d1c98f">ServerSettings::cleanupPortForwarding</a>() <a name="l00202"></a>00202 { <a name="l00203"></a>00203 <span class="preprocessor">#ifdef USE_MINIUPNPC</span> <a name="l00204"></a>00204 <span class="preprocessor"></span> <a class="code" href="class_u_p_n_p_control.html#a08d919527cbffb92e9025d97f726ffbf">UPNPControl::cleanup</a>(); <a name="l00205"></a>00205 <span class="preprocessor">#endif</span> <a name="l00206"></a>00206 <span class="preprocessor"></span>} <a name="l00207"></a>00207 <span class="comment"></span> <a name="l00208"></a>00208 <span class="comment">/** Virtual method called when we retrieve a server-related setting from Tor.</span> <a name="l00209"></a>00209 <span class="comment"> * Currently this just translates BandwidthFoo to RelayBandwidthFoo when</span> <a name="l00210"></a>00210 <span class="comment"> * appropriate. */</span> <a name="l00211"></a>00211 QVariant <a name="l00212"></a><a class="code" href="class_server_settings.html#a264c9f00c4cd4b1eb2d4b624b1e7633b">00212</a> <a class="code" href="class_server_settings.html#a264c9f00c4cd4b1eb2d4b624b1e7633b">ServerSettings::torValue</a>(<span class="keyword">const</span> QString &key)<span class="keyword"> const</span> <a name="l00213"></a>00213 <span class="keyword"></span>{ <a name="l00214"></a>00214 <span class="keywordflow">if</span> (<a class="code" href="class_abstract_tor_settings.html#a1fd0bb636bfa8131f6261b1bc11aeee4">torControl</a>()->getTorVersion() >= 0x020001) { <a name="l00215"></a>00215 <span class="keywordflow">if</span> (key == <a class="code" href="_server_settings_8cpp.html#a7fc1febee4b7077b9cb0e074e886eeea">SETTING_BANDWIDTH_RATE</a>) <a name="l00216"></a>00216 <span class="keywordflow">return</span> <a class="code" href="class_server_settings.html#a264c9f00c4cd4b1eb2d4b624b1e7633b">AbstractTorSettings::torValue</a>(<a class="code" href="_server_settings_8cpp.html#aeda76480b4d1583b291d500471877d3f">SETTING_RELAY_BANDWIDTH_RATE</a>); <a name="l00217"></a>00217 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (key == <a class="code" href="_server_settings_8cpp.html#a6f1a1925359b933919cf5ff533ad7bb8">SETTING_BANDWIDTH_BURST</a>) <a name="l00218"></a>00218 <span class="keywordflow">return</span> <a class="code" href="class_server_settings.html#a264c9f00c4cd4b1eb2d4b624b1e7633b">AbstractTorSettings::torValue</a>(<a class="code" href="_server_settings_8cpp.html#a72daca616b231e93a8a43d3002fc3289">SETTING_RELAY_BANDWIDTH_BURST</a>); <a name="l00219"></a>00219 } <a name="l00220"></a>00220 <span class="keywordflow">return</span> <a class="code" href="class_server_settings.html#a264c9f00c4cd4b1eb2d4b624b1e7633b">AbstractTorSettings::torValue</a>(key); <a name="l00221"></a>00221 } <a name="l00222"></a>00222 <span class="comment"></span> <a name="l00223"></a>00223 <span class="comment">/** Enables or disables running Tor as a server. </span> <a name="l00224"></a>00224 <span class="comment"> * \param enable Whether to enable or disable the Tor server. </span> <a name="l00225"></a>00225 <span class="comment"> */</span> <a name="l00226"></a>00226 <span class="keywordtype">void</span> <a name="l00227"></a><a class="code" href="class_server_settings.html#aa833bc4697c608baf75e69b85ab8c6b6">00227</a> <a class="code" href="class_server_settings.html#aa833bc4697c608baf75e69b85ab8c6b6">ServerSettings::setServerEnabled</a>(<span class="keywordtype">bool</span> enable) <a name="l00228"></a>00228 { <a name="l00229"></a>00229 <a class="code" href="class_abstract_tor_settings.html#a29b7abc52f7dfcb1453aafa28f902789">setValue</a>(<a class="code" href="_server_settings_8cpp.html#a5fba69e5fc55de63ca6f97c159b05ce4">SETTING_ENABLED</a>, enable); <a name="l00230"></a>00230 } <a name="l00231"></a>00231 <span class="comment"></span> <a name="l00232"></a>00232 <span class="comment">/** Returns true if Tor is currently configured to run as a Tor server. If Tor</span> <a name="l00233"></a>00233 <span class="comment"> * is running, we will check whether it has an ORPort defined. Otherwise, we</span> <a name="l00234"></a>00234 <span class="comment"> * will use our saved settings. */</span> <a name="l00235"></a>00235 <span class="keywordtype">bool</span> <a name="l00236"></a><a class="code" href="class_server_settings.html#ad8d3c25facf05765a5379421a5f80da5">00236</a> <a class="code" href="class_server_settings.html#ad8d3c25facf05765a5379421a5f80da5">ServerSettings::isServerEnabled</a>() <a name="l00237"></a>00237 { <a name="l00238"></a>00238 QString orPort; <a name="l00239"></a>00239 <span class="keywordflow">if</span> (<a class="code" href="class_abstract_tor_settings.html#a1fd0bb636bfa8131f6261b1bc11aeee4">torControl</a>()->isConnected() && !<a class="code" href="class_abstract_tor_settings.html#ad99b94f5f0e35609bd3ed288a68f8700">changedSinceLastApply</a>()) { <a name="l00240"></a>00240 <span class="keywordflow">if</span> (<a class="code" href="class_abstract_tor_settings.html#a1fd0bb636bfa8131f6261b1bc11aeee4">torControl</a>()->getConf(<a class="code" href="_server_settings_8cpp.html#a98cc7ed39cadd5da9c5ec4f8585b302b">SETTING_ORPORT</a>, orPort)) <a name="l00241"></a>00241 <span class="keywordflow">return</span> (orPort.toUInt() > 0); <a name="l00242"></a>00242 } <a name="l00243"></a>00243 <span class="keywordflow">return</span> <a class="code" href="class_abstract_tor_settings.html#a169f730fd477acb8f61cb5cf1026204f">localValue</a>(<a class="code" href="_server_settings_8cpp.html#a5fba69e5fc55de63ca6f97c159b05ce4">SETTING_ENABLED</a>).toBool(); <a name="l00244"></a>00244 } <a name="l00245"></a>00245 <span class="comment"></span> <a name="l00246"></a>00246 <span class="comment">/** Sets to <b>enabled</b> whether Tor should be a bridge node when acting as</span> <a name="l00247"></a>00247 <span class="comment"> * a server. */</span> <a name="l00248"></a>00248 <span class="keywordtype">void</span> <a name="l00249"></a><a class="code" href="class_server_settings.html#a0e330c838b330b7d25eeb4c8e7ece126">00249</a> <a class="code" href="class_server_settings.html#a0e330c838b330b7d25eeb4c8e7ece126">ServerSettings::setBridgeEnabled</a>(<span class="keywordtype">bool</span> enabled) <a name="l00250"></a>00250 { <a name="l00251"></a>00251 <a class="code" href="class_abstract_tor_settings.html#a29b7abc52f7dfcb1453aafa28f902789">setValue</a>(<a class="code" href="_server_settings_8cpp.html#a28e1abcac51a8e5a8361c0b8994cc3b0">SETTING_BRIDGE_RELAY</a>, enabled); <a name="l00252"></a>00252 } <a name="l00253"></a>00253 <span class="comment"></span> <a name="l00254"></a>00254 <span class="comment">/** Returns true if Tor is configured to act as a bridge node. */</span> <a name="l00255"></a>00255 <span class="keywordtype">bool</span> <a name="l00256"></a><a class="code" href="class_server_settings.html#a911acfd3a5ce7227e10e64f251ba44e0">00256</a> <a class="code" href="class_server_settings.html#a911acfd3a5ce7227e10e64f251ba44e0">ServerSettings::isBridgeEnabled</a>() <a name="l00257"></a>00257 { <a name="l00258"></a>00258 <span class="keywordflow">return</span> <a class="code" href="class_abstract_tor_settings.html#a6c2c0255bf7d89a14f1ad9ebdd6bf2ef">value</a>(<a class="code" href="_server_settings_8cpp.html#a28e1abcac51a8e5a8361c0b8994cc3b0">SETTING_BRIDGE_RELAY</a>).toBool() && <a class="code" href="class_server_settings.html#ad8d3c25facf05765a5379421a5f80da5">isServerEnabled</a>(); <a name="l00259"></a>00259 } <a name="l00260"></a>00260 <span class="comment"></span> <a name="l00261"></a>00261 <span class="comment">/** Sets the server's ORPort. */</span> <a name="l00262"></a>00262 <span class="keywordtype">void</span> <a name="l00263"></a><a class="code" href="class_server_settings.html#a15d7e9f64b3a2799a993819d74f0bcdc">00263</a> <a class="code" href="class_server_settings.html#a15d7e9f64b3a2799a993819d74f0bcdc">ServerSettings::setORPort</a>(quint16 orPort) <a name="l00264"></a>00264 { <a name="l00265"></a>00265 <a class="code" href="class_abstract_tor_settings.html#a29b7abc52f7dfcb1453aafa28f902789">setValue</a>(<a class="code" href="_server_settings_8cpp.html#a98cc7ed39cadd5da9c5ec4f8585b302b">SETTING_ORPORT</a>, orPort); <a name="l00266"></a>00266 } <a name="l00267"></a>00267 <span class="comment"></span> <a name="l00268"></a>00268 <span class="comment">/** Gets the server's current ORPort setting. */</span> <a name="l00269"></a>00269 quint16 <a name="l00270"></a><a class="code" href="class_server_settings.html#a6b919ff92a5c43e2163e595c6550ad5a">00270</a> <a class="code" href="class_server_settings.html#a6b919ff92a5c43e2163e595c6550ad5a">ServerSettings::getORPort</a>() <a name="l00271"></a>00271 { <a name="l00272"></a>00272 <span class="keywordflow">return</span> (quint16)<a class="code" href="class_abstract_tor_settings.html#a6c2c0255bf7d89a14f1ad9ebdd6bf2ef">value</a>(<a class="code" href="_server_settings_8cpp.html#a98cc7ed39cadd5da9c5ec4f8585b302b">SETTING_ORPORT</a>).toUInt(); <a name="l00273"></a>00273 } <a name="l00274"></a>00274 <span class="comment"></span> <a name="l00275"></a>00275 <span class="comment">/** Sets the server's current DirPort. */</span> <a name="l00276"></a>00276 <span class="keywordtype">void</span> <a name="l00277"></a><a class="code" href="class_server_settings.html#ac64f885fda7a97a12c2ff1166f7c7c37">00277</a> <a class="code" href="class_server_settings.html#ac64f885fda7a97a12c2ff1166f7c7c37">ServerSettings::setDirPort</a>(quint16 dirPort) <a name="l00278"></a>00278 { <a name="l00279"></a>00279 <a class="code" href="class_abstract_tor_settings.html#a29b7abc52f7dfcb1453aafa28f902789">setValue</a>(<a class="code" href="_server_settings_8cpp.html#ab2c872ca73ec73efd890398d18fe7d4e">SETTING_DIRPORT</a>, dirPort); <a name="l00280"></a>00280 } <a name="l00281"></a>00281 <span class="comment"></span> <a name="l00282"></a>00282 <span class="comment">/** Gets the server's current DirPort. */</span> <a name="l00283"></a>00283 quint16 <a name="l00284"></a><a class="code" href="class_server_settings.html#a2a3b7a0c5ab09cf6c7436b78addd37a7">00284</a> <a class="code" href="class_server_settings.html#a2a3b7a0c5ab09cf6c7436b78addd37a7">ServerSettings::getDirPort</a>() <a name="l00285"></a>00285 { <a name="l00286"></a>00286 <span class="keywordflow">return</span> (quint16)<a class="code" href="class_abstract_tor_settings.html#a6c2c0255bf7d89a14f1ad9ebdd6bf2ef">value</a>(<a class="code" href="_server_settings_8cpp.html#ab2c872ca73ec73efd890398d18fe7d4e">SETTING_DIRPORT</a>).toUInt(); <a name="l00287"></a>00287 } <a name="l00288"></a>00288 <span class="comment"></span> <a name="l00289"></a>00289 <span class="comment">/** Sets the server's nickname. */</span> <a name="l00290"></a>00290 <span class="keywordtype">void</span> <a name="l00291"></a><a class="code" href="class_server_settings.html#a6d364baace16bb134cc74e8d675f7cc9">00291</a> <a class="code" href="class_server_settings.html#a6d364baace16bb134cc74e8d675f7cc9">ServerSettings::setNickname</a>(QString nickname) <a name="l00292"></a>00292 { <a name="l00293"></a>00293 <a class="code" href="class_abstract_tor_settings.html#a29b7abc52f7dfcb1453aafa28f902789">setValue</a>(<a class="code" href="_server_settings_8cpp.html#aec16b866bc88d47755c9ac7fe196f29d">SETTING_NICKNAME</a>, nickname); <a name="l00294"></a>00294 } <a name="l00295"></a>00295 <span class="comment"></span> <a name="l00296"></a>00296 <span class="comment">/** Gets the server's nickname. */</span> <a name="l00297"></a>00297 QString <a name="l00298"></a><a class="code" href="class_server_settings.html#a6d3899ef930a3de796f4e13d4ab7c534">00298</a> <a class="code" href="class_server_settings.html#a6d3899ef930a3de796f4e13d4ab7c534">ServerSettings::getNickname</a>() <a name="l00299"></a>00299 { <a name="l00300"></a>00300 QString nickname = <a class="code" href="class_abstract_tor_settings.html#a6c2c0255bf7d89a14f1ad9ebdd6bf2ef">value</a>(<a class="code" href="_server_settings_8cpp.html#aec16b866bc88d47755c9ac7fe196f29d">SETTING_NICKNAME</a>).toString(); <a name="l00301"></a>00301 <span class="comment">/* Ensure the nickname contains only valid characters and is not too long. */</span> <a name="l00302"></a>00302 <span class="keywordflow">return</span> <a class="code" href="stringutil_8cpp.html#a3160a90d93ee7f5b4c2abebdfe4e8afc">ensure_valid_chars</a>(nickname, <a name="l00303"></a>00303 <a class="code" href="_nickname_validator_8cpp.html#afeafddd1f05e9b838d2468377e525be8">VALID_NICKNAME_CHARS</a>).left(<a class="code" href="_server_settings_8cpp.html#a0929ff1a585dc55520c5b872f79c3e43">MAX_NICKNAME_LEN</a>); <a name="l00304"></a>00304 } <a name="l00305"></a>00305 <span class="comment"></span> <a name="l00306"></a>00306 <span class="comment">/** Sets the server's contact information. */</span> <a name="l00307"></a>00307 <span class="keywordtype">void</span> <a name="l00308"></a><a class="code" href="class_server_settings.html#abb5dffb3adca20bd99e79b0d2b521982">00308</a> <a class="code" href="class_server_settings.html#abb5dffb3adca20bd99e79b0d2b521982">ServerSettings::setContactInfo</a>(QString contact) <a name="l00309"></a>00309 { <a name="l00310"></a>00310 <a class="code" href="class_abstract_tor_settings.html#a29b7abc52f7dfcb1453aafa28f902789">setValue</a>(<a class="code" href="_server_settings_8cpp.html#a424a0c131fab58f9052f594e5b688771">SETTING_CONTACT</a>, contact); <a name="l00311"></a>00311 } <a name="l00312"></a>00312 <span class="comment"></span> <a name="l00313"></a>00313 <span class="comment">/** Gets the server's contact information. */</span> <a name="l00314"></a>00314 QString <a name="l00315"></a><a class="code" href="class_server_settings.html#a001a1e0d97c05db09e1de9779b464789">00315</a> <a class="code" href="class_server_settings.html#a001a1e0d97c05db09e1de9779b464789">ServerSettings::getContactInfo</a>() <a name="l00316"></a>00316 { <a name="l00317"></a>00317 <span class="keywordflow">return</span> <a class="code" href="class_abstract_tor_settings.html#a6c2c0255bf7d89a14f1ad9ebdd6bf2ef">value</a>(<a class="code" href="_server_settings_8cpp.html#a424a0c131fab58f9052f594e5b688771">SETTING_CONTACT</a>).toString(); <a name="l00318"></a>00318 } <a name="l00319"></a>00319 <span class="comment"></span> <a name="l00320"></a>00320 <span class="comment">/** Returns whether this server will act as a directory mirror or not. */</span> <a name="l00321"></a>00321 <span class="keywordtype">bool</span> <a name="l00322"></a><a class="code" href="class_server_settings.html#a7779c3509d358077406b4e75cf9c7f7d">00322</a> <a class="code" href="class_server_settings.html#a7779c3509d358077406b4e75cf9c7f7d">ServerSettings::isDirectoryMirror</a>() <a name="l00323"></a>00323 { <a name="l00324"></a>00324 <span class="keywordflow">return</span> <a class="code" href="class_abstract_tor_settings.html#a169f730fd477acb8f61cb5cf1026204f">localValue</a>(<a class="code" href="_server_settings_8cpp.html#a31bee2dae94f6c2933421d25625b24d9">SETTING_DIRMIRROR</a>).toBool(); <a name="l00325"></a>00325 } <a name="l00326"></a>00326 <span class="comment"></span> <a name="l00327"></a>00327 <span class="comment">/** Sets whether this server will act as a directory mirror. */</span> <a name="l00328"></a>00328 <span class="keywordtype">void</span> <a name="l00329"></a><a class="code" href="class_server_settings.html#a9599baf63fdd49e18155b95987e6755b">00329</a> <a class="code" href="class_server_settings.html#a9599baf63fdd49e18155b95987e6755b">ServerSettings::setDirectoryMirror</a>(<span class="keywordtype">bool</span> mirror) <a name="l00330"></a>00330 { <a name="l00331"></a>00331 <a class="code" href="class_abstract_tor_settings.html#a29b7abc52f7dfcb1453aafa28f902789">setValue</a>(<a class="code" href="_server_settings_8cpp.html#a31bee2dae94f6c2933421d25625b24d9">SETTING_DIRMIRROR</a>, mirror); <a name="l00332"></a>00332 } <a name="l00333"></a>00333 <span class="comment"></span> <a name="l00334"></a>00334 <span class="comment">/** Returns the exit policy for this server. */</span> <a name="l00335"></a>00335 <a class="code" href="class_exit_policy.html">ExitPolicy</a> <a name="l00336"></a><a class="code" href="class_server_settings.html#a9d9ec555d9e9fd7c3f608d99a2471186">00336</a> <a class="code" href="class_server_settings.html#a9d9ec555d9e9fd7c3f608d99a2471186">ServerSettings::getExitPolicy</a>() <a name="l00337"></a>00337 { <a name="l00338"></a>00338 <span class="keywordflow">return</span> <a class="code" href="class_exit_policy.html">ExitPolicy</a>(<a class="code" href="class_abstract_tor_settings.html#a6c2c0255bf7d89a14f1ad9ebdd6bf2ef">value</a>(<a class="code" href="_server_settings_8cpp.html#a64de7b6529282213b9b6944191494b5f">SETTING_EXITPOLICY</a>).toString()); <a name="l00339"></a>00339 } <a name="l00340"></a>00340 <span class="comment"></span> <a name="l00341"></a>00341 <span class="comment">/** Sets the exit policy for this server. */</span> <a name="l00342"></a>00342 <span class="keywordtype">void</span> <a name="l00343"></a><a class="code" href="class_server_settings.html#aad511688b32d4262e64b96ae66c3ae68">00343</a> <a class="code" href="class_server_settings.html#aad511688b32d4262e64b96ae66c3ae68">ServerSettings::setExitPolicy</a>(<a class="code" href="class_exit_policy.html">ExitPolicy</a> &exitPolicy) <a name="l00344"></a>00344 { <a name="l00345"></a>00345 <a class="code" href="class_abstract_tor_settings.html#a29b7abc52f7dfcb1453aafa28f902789">setValue</a>(<a class="code" href="_server_settings_8cpp.html#a64de7b6529282213b9b6944191494b5f">SETTING_EXITPOLICY</a>, exitPolicy.<a class="code" href="class_exit_policy.html#a8178aa3e7eac2aedc6c680a85f1b57f6">toString</a>()); <a name="l00346"></a>00346 } <a name="l00347"></a>00347 <span class="comment"></span> <a name="l00348"></a>00348 <span class="comment">/** Returns the long-term average bandwidth rate (in KB/s) for this server. */</span> <a name="l00349"></a>00349 quint32 <a name="l00350"></a><a class="code" href="class_server_settings.html#a68f74454d64896664db22f5671c900c2">00350</a> <a class="code" href="class_server_settings.html#a68f74454d64896664db22f5671c900c2">ServerSettings::getBandwidthAvgRate</a>() <a name="l00351"></a>00351 { <a name="l00352"></a>00352 <span class="keywordflow">return</span> <a class="code" href="class_abstract_tor_settings.html#a6c2c0255bf7d89a14f1ad9ebdd6bf2ef">value</a>(<a class="code" href="_server_settings_8cpp.html#a7fc1febee4b7077b9cb0e074e886eeea">SETTING_BANDWIDTH_RATE</a>).toUInt(); <a name="l00353"></a>00353 } <a name="l00354"></a>00354 <span class="comment"></span> <a name="l00355"></a>00355 <span class="comment">/** Sets the long-term average bandwidth rate (in KB/s) for this server. */</span> <a name="l00356"></a>00356 <span class="keywordtype">void</span> <a name="l00357"></a><a class="code" href="class_server_settings.html#ae007a13970276a36f8c2ff34a465cf73">00357</a> <a class="code" href="class_server_settings.html#ae007a13970276a36f8c2ff34a465cf73">ServerSettings::setBandwidthAvgRate</a>(quint32 rate) <a name="l00358"></a>00358 { <a name="l00359"></a>00359 <a class="code" href="class_abstract_tor_settings.html#a29b7abc52f7dfcb1453aafa28f902789">setValue</a>(<a class="code" href="_server_settings_8cpp.html#a7fc1febee4b7077b9cb0e074e886eeea">SETTING_BANDWIDTH_RATE</a>, rate); <a name="l00360"></a>00360 } <a name="l00361"></a>00361 <span class="comment"></span> <a name="l00362"></a>00362 <span class="comment">/** Returns the maximum bandwidth burst rate (in KB/s) for this server. */</span> <a name="l00363"></a>00363 quint32 <a name="l00364"></a><a class="code" href="class_server_settings.html#a4db2fe48b6bcfc400965bf896f96eb7c">00364</a> <a class="code" href="class_server_settings.html#a4db2fe48b6bcfc400965bf896f96eb7c">ServerSettings::getBandwidthBurstRate</a>() <a name="l00365"></a>00365 { <a name="l00366"></a>00366 <span class="keywordflow">return</span> <a class="code" href="class_abstract_tor_settings.html#a6c2c0255bf7d89a14f1ad9ebdd6bf2ef">value</a>(<a class="code" href="_server_settings_8cpp.html#a6f1a1925359b933919cf5ff533ad7bb8">SETTING_BANDWIDTH_BURST</a>).toUInt(); <a name="l00367"></a>00367 } <a name="l00368"></a>00368 <span class="comment"></span> <a name="l00369"></a>00369 <span class="comment">/** Sets the maximum bandwidth burst rate (in KB/s) for this server. */</span> <a name="l00370"></a>00370 <span class="keywordtype">void</span> <a name="l00371"></a><a class="code" href="class_server_settings.html#aa1a48f299c7eaa765c5743bded4d0df9">00371</a> <a class="code" href="class_server_settings.html#aa1a48f299c7eaa765c5743bded4d0df9">ServerSettings::setBandwidthBurstRate</a>(quint32 rate) <a name="l00372"></a>00372 { <a name="l00373"></a>00373 <a class="code" href="class_abstract_tor_settings.html#a29b7abc52f7dfcb1453aafa28f902789">setValue</a>(<a class="code" href="_server_settings_8cpp.html#a6f1a1925359b933919cf5ff533ad7bb8">SETTING_BANDWIDTH_BURST</a>, rate); <a name="l00374"></a>00374 } <a name="l00375"></a>00375 <span class="comment"></span> <a name="l00376"></a>00376 <span class="comment">/** Sets whether the user's server descriptor will be published or not.</span> <a name="l00377"></a>00377 <span class="comment"> * Currently this only affects publishing of bridge descriptors. If the</span> <a name="l00378"></a>00378 <span class="comment"> * user is running a normal relay, its descriptor will always be</span> <a name="l00379"></a>00379 <span class="comment"> * published regardless of this setting. */</span> <a name="l00380"></a>00380 <span class="keywordtype">void</span> <a name="l00381"></a><a class="code" href="class_server_settings.html#a47644bb280ab9940becc2edb5fb345b5">00381</a> <a class="code" href="class_server_settings.html#a47644bb280ab9940becc2edb5fb345b5">ServerSettings::setPublishServerDescriptor</a>(<span class="keywordtype">bool</span> publish) <a name="l00382"></a>00382 { <a name="l00383"></a>00383 <span class="keywordflow">if</span> (publish) <a name="l00384"></a>00384 <a class="code" href="class_abstract_tor_settings.html#a29b7abc52f7dfcb1453aafa28f902789">setValue</a>(<a class="code" href="_server_settings_8cpp.html#aa98dd71e345116ec53e2bd6ab9b0d32c">SETTING_PUBLISH_SERVER_DESCRIPTOR</a>, <span class="stringliteral">"1"</span>); <a name="l00385"></a>00385 <span class="keywordflow">else</span> <a name="l00386"></a>00386 <a class="code" href="class_abstract_tor_settings.html#a29b7abc52f7dfcb1453aafa28f902789">setValue</a>(<a class="code" href="_server_settings_8cpp.html#aa98dd71e345116ec53e2bd6ab9b0d32c">SETTING_PUBLISH_SERVER_DESCRIPTOR</a>, <span class="stringliteral">"0"</span>); <a name="l00387"></a>00387 } <a name="l00388"></a>00388 <span class="comment"></span> <a name="l00389"></a>00389 <span class="comment">/** Returns true if the user's server descriptor will be published to the</span> <a name="l00390"></a>00390 <span class="comment"> * appropriate authorities. */</span> <a name="l00391"></a>00391 <span class="keywordtype">bool</span> <a name="l00392"></a><a class="code" href="class_server_settings.html#afc0daa865e87d83ef9050967ee3f9404">00392</a> <a class="code" href="class_server_settings.html#afc0daa865e87d83ef9050967ee3f9404">ServerSettings::publishServerDescriptor</a>()<span class="keyword"> const</span> <a name="l00393"></a>00393 <span class="keyword"></span>{ <a name="l00394"></a>00394 <span class="keywordflow">return</span> (<a class="code" href="class_abstract_tor_settings.html#a6c2c0255bf7d89a14f1ad9ebdd6bf2ef">value</a>(<a class="code" href="_server_settings_8cpp.html#aa98dd71e345116ec53e2bd6ab9b0d32c">SETTING_PUBLISH_SERVER_DESCRIPTOR</a>).toString() != <span class="stringliteral">"0"</span>); <a name="l00395"></a>00395 } <a name="l00396"></a>00396 <span class="comment"></span> <a name="l00397"></a>00397 <span class="comment">/** Returns true if UPnP support is available and enabled. */</span> <a name="l00398"></a>00398 <span class="keywordtype">bool</span> <a name="l00399"></a><a class="code" href="class_server_settings.html#a421e1da362a29f7d2a5bda3ba065faf2">00399</a> <a class="code" href="class_server_settings.html#a421e1da362a29f7d2a5bda3ba065faf2">ServerSettings::isUpnpEnabled</a>() <a name="l00400"></a>00400 { <a name="l00401"></a>00401 <span class="preprocessor">#if defined(USE_MINIUPNPC)</span> <a name="l00402"></a>00402 <span class="preprocessor"></span> <span class="keywordflow">return</span> <a class="code" href="class_abstract_tor_settings.html#a169f730fd477acb8f61cb5cf1026204f">localValue</a>(<a class="code" href="_server_settings_8cpp.html#aa0d9c39c77bd12a25422f0df4efabaf5">SETTING_ENABLE_UPNP</a>).toBool(); <a name="l00403"></a>00403 <span class="preprocessor">#else</span> <a name="l00404"></a>00404 <span class="preprocessor"></span> <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00405"></a>00405 <span class="preprocessor">#endif</span> <a name="l00406"></a>00406 <span class="preprocessor"></span>} <a name="l00407"></a>00407 <span class="comment"></span> <a name="l00408"></a>00408 <span class="comment">/** Sets whether Vidalia should try to configure port forwarding using UPnP.</span> <a name="l00409"></a>00409 <span class="comment"> * If Vidalia was compiled without UPnP support, this method has no effect. */</span> <a name="l00410"></a>00410 <span class="keywordtype">void</span> <a name="l00411"></a><a class="code" href="class_server_settings.html#a5d731b4a7a4e08035a631118054b05e6">00411</a> <a class="code" href="class_server_settings.html#a5d731b4a7a4e08035a631118054b05e6">ServerSettings::setUpnpEnabled</a>(<span class="keywordtype">bool</span> enabled) <a name="l00412"></a>00412 { <a name="l00413"></a>00413 <span class="preprocessor">#if defined(USE_MINIUPNPC)</span> <a name="l00414"></a>00414 <span class="preprocessor"></span> <a class="code" href="class_abstract_tor_settings.html#a29b7abc52f7dfcb1453aafa28f902789">setValue</a>(<a class="code" href="_server_settings_8cpp.html#aa0d9c39c77bd12a25422f0df4efabaf5">SETTING_ENABLE_UPNP</a>, enabled); <a name="l00415"></a>00415 <span class="preprocessor">#endif</span> <a name="l00416"></a>00416 <span class="preprocessor"></span>} <a name="l00417"></a>00417 </pre></div></div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Mon Aug 30 22:58:54 2010 for Vidalia by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address> </body> </html>