 +  void init_upnp();
 +  void upnp_add_redir (const char * addr, int port);
 +  void upnp_rem_redir(int port);
-+
-   /** Returns Tor-recognizable configuration keys and current values. */
-   QHash<QString,QString> confValues();
-+
-+  /** Configure UPnP device to forward DirPort and ORPort */
-+  void configurePortForwarding();
- };
- 
- #endif
- 
-+
++};
++
++#endif 

Index: INSTALL
===================================================================
--- INSTALL	(revision 2465)
+++ INSTALL	(working copy)
@@ -206,3 +206,8 @@
 'cmake --help' or 'man cmake' (on non-Windows platforms) for more information
 about supported generators and configuration options.
 
+Including UPnP support
+----------------------
+
+cmake -G "MSYS Makefiles" -DMINIUPNPC_LIBRARY_DIR="/usr/local/lib" -DMINIUPNPC_INCLUDE_DIR="/usr/local/include" .
+
Index: src/vidalia/CMakeLists.txt
===================================================================
--- src/vidalia/CMakeLists.txt	(revision 2465)
+++ src/vidalia/CMakeLists.txt	(working copy)
@@ -16,6 +16,7 @@
   ${CMAKE_CURRENT_SOURCE_DIR}
   ${CMAKE_CURRENT_SOURCE_DIR}/config

     rc = torControl()->setConf(confValues(), errmsg);
   } else { 
     QStringList resetKeys;
@@ -152,6 +156,17 @@
   return rc;
 }
 
+/* TODO: We should call this periodically, in case the router gets rebooted or forgets its UPnP settings */
+/* TODO: Remove port forwarding when Tor is shutdown or the ORPort changes */
+/* TODO: init_upnp() will block for up to 2 seconds. We should fire off a thread */
+/** Configure UPnP device to forward DirPort and ORPort */
+void
+ServerSettings::configurePortForwarding()
+{
+  UPNPControl *pUNPControl = UPNPControl::Instance();
+  pUNPControl->forwardPort(getORPort());
+}
+
 /** Virtual method called when we retrieve a server-related setting from Tor.
  * Currently this just translates BandwidthFoo to RelayBandwidthFoo when
  * appropriate. */
Index: config/serversettings.h
===================================================================
--- config/serversettings.h	(revision 2473)
+++ config/serversettings.h	(working copy)
@@ -91,6 +91,9 @@
 private:
   /** Returns Tor-recognizable configuration keys and current values. */
   QHash<QString,QString> confValues();
+
+  /** Configure UPnP device to forward DirPort and ORPort */
+  void configurePortForwarding();
 };
 
 #endif
Index: config/upnpcontrol.cpp
===================================================================
--- config/upnpcontrol.cpp	(revision 0)
+++ config/upnpcontrol.cpp	(revision 0)
@@ -0,0 +1,93 @@
+/*
+**  This file is part of Vidalia, and is subject to the license terms in the
+**  LICENSE file, found in the top level directory of this distribution. If 
+**  you did not receive the LICENSE file with this file, you may obtain it
+**  from the Vidalia source package distributed by the Vidalia Project at
+**  http://www.vidalia-project.net/. No part of Vidalia, including this file,
+**  may be copied, modified, propagated, or distributed except according to
+**  the terms described in the LICENSE file.
+*/
+
+/* 
+** \file upnpcontrol.cpp
+** \version $Id: torcontrol.h 2362 2008-02-29 04:30:11Z edmanm $
+** \brief Singleton object for interacting with UPNP device
+*/
+
+#include "upnpcontrol.h"
+
+UPNPControl* UPNPControl::pInstance = 0;
+UPNPControl* UPNPControl::Instance()
+{
+  if (0 == pInstance)
+    pInstance = new UPNPControl;
+  return pInstance;
+}
+
+UPNPControl::UPNPControl()
+{
+  init_upnp();
+}
+
+void
+UPNPControl::forwardPort(int port)
+{
+  upnp_add_redir(lanaddr, port);
+}
+
+/** Based on http://miniupnp.free.fr/files/download.php?file=xchat-upnp20061022.patch */
+void
+UPNPControl::init_upnp()
+{
+  struct UPNPDev * devlist;
+  int retval;
