[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r2566: Add vidalia.conf options for enabling or disabling UPnP and (in vidalia: . branches/upnp/src/vidalia/config)
Author: edmanm
Date: 2008-05-09 00:58:41 -0400 (Fri, 09 May 2008)
New Revision: 2566
Modified:
vidalia/
vidalia/branches/upnp/src/vidalia/config/serverpage.cpp
vidalia/branches/upnp/src/vidalia/config/serversettings.cpp
vidalia/branches/upnp/src/vidalia/config/serversettings.h
Log:
r291@thebe: edmanm | 2008-05-09 00:57:20 -0400
Add vidalia.conf options for enabling or disabling UPnP and connect it to the
checkbox on the relay settings page.
Property changes on: vidalia
___________________________________________________________________
svk:merge ticket from /local/vidalia [r291] on 45a62a8a-8088-484c-baad-c7b3e776dd32
Modified: vidalia/branches/upnp/src/vidalia/config/serverpage.cpp
===================================================================
--- vidalia/branches/upnp/src/vidalia/config/serverpage.cpp 2008-05-09 04:31:18 UTC (rev 2565)
+++ vidalia/branches/upnp/src/vidalia/config/serverpage.cpp 2008-05-09 04:58:41 UTC (rev 2566)
@@ -271,7 +271,11 @@
_settings->setContactInfo(ui.lineServerContact->text());
saveBandwidthLimits();
saveExitPolicies();
-
+
+#if defined(USE_MINIUPNPC)
+ _settings->setUpnpEnabled(ui.chkEnableUpnp->isChecked());
+#endif
+
return true;
}
@@ -295,6 +299,10 @@
loadBandwidthLimits();
loadExitPolicies();
loadBridgeIdentity();
+
+#if defined(USE_MINIUPNPC)
+ ui.chkEnableUpnp->setChecked(_settings->isUpnpEnabled());
+#endif
}
/** Shows exit policy related help information */
Modified: vidalia/branches/upnp/src/vidalia/config/serversettings.cpp
===================================================================
--- vidalia/branches/upnp/src/vidalia/config/serversettings.cpp 2008-05-09 04:31:18 UTC (rev 2565)
+++ vidalia/branches/upnp/src/vidalia/config/serversettings.cpp 2008-05-09 04:58:41 UTC (rev 2566)
@@ -43,6 +43,7 @@
#define SETTING_BANDWIDTH_RATE "BandwidthRate"
#define SETTING_BANDWIDTH_BURST "BandwidthBurst"
#define SETTING_BRIDGE_RELAY "BridgeRelay"
+#define SETTING_ENABLE_UPNP "EnableUPnP"
#define SETTING_RELAY_BANDWIDTH_RATE "RelayBandwidthRate"
#define SETTING_RELAY_BANDWIDTH_BURST "RelayBandwidthBurst"
#define SETTING_PUBLISH_DESCRIPTOR "PublishServerDescriptor"
@@ -72,6 +73,7 @@
setDefault(SETTING_PUBLISH_DESCRIPTOR, "1");
setDefault(SETTING_EXITPOLICY,
ExitPolicy(ExitPolicy::Default).toString());
+ setDefault(SETTING_ENABLE_UPNP, false);
}
/** Returns a QHash of Tor-recognizable configuratin keys to their current
@@ -136,6 +138,10 @@
configurePortForwarding();
if (isServerEnabled()) {
+ /* Configure UPnP device to forward DirPort and OrPort */
+ /* TODO: does isServerEnabled() return true when a server is just set up? */
+ if (isUpnpEnabled())
+ configurePortForwarding(true, true);
rc = torControl()->setConf(confValues(), errmsg);
} else {
QStringList resetKeys;
@@ -368,3 +374,24 @@
setValue(SETTING_BANDWIDTH_BURST, rate);
}
+/** Returns true if UPnP support is available and enabled. */
+bool
+ServerSettings::isUpnpEnabled()
+{
+#if defined(USE_MINIUPNPC)
+ return localValue(SETTING_ENABLE_UPNP).toBool();
+#else
+ return false;
+#endif
+}
+
+/** Sets whether Vidalia should try to configure port forwarding using UPnP.
+ * If Vidalia was compiled without UPnP support, this method has no effect. */
+void
+ServerSettings::setUpnpEnabled(bool enabled)
+{
+#if defined(USE_MINIUPNPC)
+ setValue(SETTING_ENABLE_UPNP, enabled);
+#endif
+}
+
Modified: vidalia/branches/upnp/src/vidalia/config/serversettings.h
===================================================================
--- vidalia/branches/upnp/src/vidalia/config/serversettings.h 2008-05-09 04:31:18 UTC (rev 2565)
+++ vidalia/branches/upnp/src/vidalia/config/serversettings.h 2008-05-09 04:58:41 UTC (rev 2566)
@@ -82,10 +82,17 @@
/** Gets the maximum burst rate (in B/s) of this server. */
quint32 getBandwidthBurstRate();
- /** Configure port forwarding */
- void configurePortForwarding();
+ /** If <b>enable</b> is true, configure UPnP device to forward ORPort, otherwise
+ * remove mapping. */
+ void configurePortForwarding(bool enable, bool async);
void cleanupPortForwarding();
+
+ /** Returns true if UPnP support is enabled. */
+ bool isUpnpEnabled();
+ /** Sets whether Vidalia should try to configure port forwarding using UPnP. */
+ void setUpnpEnabled(bool enabled);
+
protected:
/** Virtual method called when we retrieve a server-related setting from Tor.
* Currently this just translates BandwidthFoo to RelayBandwidthFoo when