[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r14223: Make UPnP code compile. Currently it initializes UPnP device (torbrowser/trunk/src/current-patches)



Author: sjm217
Date: 2008-03-27 15:47:46 -0400 (Thu, 27 Mar 2008)
New Revision: 14223

Modified:
   torbrowser/trunk/src/current-patches/vidalia-miniupnp.patch
Log:
Make UPnP code compile.
Currently it initializes UPnP device but no more.
Also define STATICLIB to avoid linking errors with Mingw32.

Modified: torbrowser/trunk/src/current-patches/vidalia-miniupnp.patch
===================================================================
--- torbrowser/trunk/src/current-patches/vidalia-miniupnp.patch	2008-03-27 17:25:49 UTC (rev 14222)
+++ torbrowser/trunk/src/current-patches/vidalia-miniupnp.patch	2008-03-27 19:47:46 UTC (rev 14223)
@@ -1,19 +1,19 @@
 Index: INSTALL
 ===================================================================
---- INSTALL	(revision 2423)
+--- INSTALL	(revision 2465)
 +++ INSTALL	(working copy)
-@@ -205,3 +205,7 @@
+@@ -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" .
-\ No newline at end of file
++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 2423)
+--- src/vidalia/CMakeLists.txt	(revision 2465)
 +++ src/vidalia/CMakeLists.txt	(working copy)
 @@ -16,6 +16,7 @@
    ${CMAKE_CURRENT_SOURCE_DIR}
@@ -22,8 +22,8 @@
 +  ${MINIUPNPC_INCLUDE_DIR}
  )
  configure_file(
-   ${CMAKE_CURRENT_SOURCE_DIR}/vidalia.h.in
-@@ -238,9 +239,16 @@
+   ${CMAKE_CURRENT_SOURCE_DIR}/res/vidalia_win.rc.in
+@@ -234,9 +235,16 @@
  endif(APPLE)
  add_dependencies(${vidalia_BIN} translations)
  
@@ -40,9 +40,14 @@
    torcontrol
    util
  )
+@@ -268,3 +276,4 @@
+ endif(NOT WIN32 AND NOT APPLE)
+ 
+ 
++
 Index: src/vidalia/config/serversettings.cpp
 ===================================================================
---- src/vidalia/config/serversettings.cpp	(revision 2423)
+--- src/vidalia/config/serversettings.cpp	(revision 2465)
 +++ src/vidalia/config/serversettings.cpp	(working copy)
 @@ -130,6 +130,9 @@
    bool rc;
@@ -54,7 +59,7 @@
      rc = torControl()->setConf(confValues(), errmsg);
    } else { 
      QStringList resetKeys;
-@@ -152,6 +155,91 @@
+@@ -152,6 +155,72 @@
    return rc;
  }
  
@@ -64,39 +69,19 @@
 +ServerSettings::init_upnp()
 +{
 +  struct UPNPDev * devlist;
-+  struct UPNPDev * dev;
-+  char * descXML;
-+  int descXMLsize = 0;
++  char lanaddr[256];
++  int retval;
++
 +  printf("TB : init_upnp()\n");
++
 +  memset(&urls, 0, sizeof(struct UPNPUrls));
 +  memset(&data, 0, sizeof(struct IGDdatas));
-+  devlist = upnpDiscover(2000);
-+  if (devlist)
-+    {
-+      dev = devlist;
-+      while (dev)
-+	{
-+	  if (strstr (dev->st, "InternetGatewayDevice"))
-+	    break;
-+	  dev = dev->pNext;
-+	}
-+      if (!dev)
-+	dev = devlist; /* defaulting to first device */
 +
-+      printf("UPnP device :\n"
-+	     " desc: %s\n st: %s\n",
-+	     dev->descURL, dev->st);
++  devlist = upnpDiscover(2000, NULL, NULL);
++  retval = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, 256);
++  printf("UPNP: %d", retval);
 +
-+      descXML = miniwget(dev->descURL, &descXMLsize);
-+      if (descXML)
-+	{
-+	  parserootdesc (descXML, descXMLsize, &data);
-+	  free (descXML); descXML = 0;
-+	  GetUPNPUrls (&urls, &data, dev->descURL);
-+	}
-+      freeUPNPDevlist(devlist);
-+    }
-+
++  freeUPNPDevlist(devlist);
 +}
 +
 +/** Based on http://miniupnp.free.fr/files/download.php?file=xchat-upnp20061022.patch */
@@ -136,37 +121,44 @@
 +
 +/* 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()
 +{
-+  ;
++  init_upnp();
 +}
 +
  /** Virtual method called when we retrieve a server-related setting from Tor.
   * Currently this just translates BandwidthFoo to RelayBandwidthFoo when
   * appropriate. */
+@@ -321,3 +390,4 @@
+   setValue(SETTING_BANDWIDTH_BURST, rate);
+ }
+ 
++
 Index: src/vidalia/config/serversettings.h
 ===================================================================
---- src/vidalia/config/serversettings.h	(revision 2423)
+--- src/vidalia/config/serversettings.h	(revision 2465)
 +++ src/vidalia/config/serversettings.h	(working copy)
-@@ -20,6 +20,9 @@
+@@ -20,6 +20,10 @@
  #include "abstracttorsettings.h"
  #include "exitpolicy.h"
  
++#define STATICLIB
 +#include <miniupnpc/miniwget.h>
 +#include <miniupnpc/miniupnpc.h>
 +#include <miniupnpc/upnpcommands.h>
  
  class ServerSettings : public AbstractTorSettings
  {
-@@ -89,8 +92,18 @@
+@@ -89,9 +93,20 @@
    virtual QVariant torValue(const QString &key) const;
  
  private:
 +  /** Used by miniupnpc library */
-+  static struct UPNPUrls urls;
-+  static struct IGDdatas data;
++  struct UPNPUrls urls;
++  struct IGDdatas data;
 +  void init_upnp();
 +  void upnp_add_redir (const char * addr, int port);
 +  void upnp_rem_redir(int port);
@@ -179,3 +171,5 @@
  };
  
  #endif
+ 
++