[or-cvs] r14161: More UPnP code (still doesn't compile) (in torbrowser/trunk: build-scripts src/current-patches)

sjm217 at seul.org sjm217 at seul.org
Sun Mar 23 21:02:37 UTC 2008


Author: sjm217
Date: 2008-03-23 17:02:36 -0400 (Sun, 23 Mar 2008)
New Revision: 14161

Removed:
   torbrowser/trunk/src/current-patches/torbrowser-miniupnp.patch
Modified:
   torbrowser/trunk/build-scripts/INSTALL
   torbrowser/trunk/src/current-patches/vidalia-miniupnp.patch
Log:
More UPnP code (still doesn't compile)

Modified: torbrowser/trunk/build-scripts/INSTALL
===================================================================
--- torbrowser/trunk/build-scripts/INSTALL	2008-03-23 19:53:37 UTC (rev 14160)
+++ torbrowser/trunk/build-scripts/INSTALL	2008-03-23 21:02:36 UTC (rev 14161)
@@ -129,7 +129,23 @@
 For libevent, use 1.3e, as suggested by the document above.
 libevent 1.4.0 is newer but untested.
 
+Building miniupnp
+=================
 
+mingw32-make.exe -f Makefile.mingw
+INSTALL=install
+INSTALLPREFIX=/usr/local
+INSTALLDIRINC=$INSTALLPREFIX/include/miniupnpc
+INSTALLDIRLIB=$INSTALLPREFIX/lib
+HEADERS="miniupnpc.h miniwget.h upnpcommands.h igd_desc_parse.h upnpreplyparse.h upnperrors.h declspec.h bsdqueue.h"
+LIBRARY=libminiupnpc.a
+APIVERSION=2
+SONAME=$SHAREDLIBRARY.$APIVERSION
+$INSTALL -d $INSTALLDIRINC
+$INSTALL --mode=644 $HEADERS $INSTALLDIRINC
+$INSTALL -d $INSTALLDIRLIB
+$INSTALL --mode=644 $LIBRARY $INSTALLDIRLIB
+
 Building Vidalia
 ================
 
@@ -224,3 +240,4 @@
 
 $ make -C obj-i686-pc-mingw32/browser/installer
 
+

Deleted: torbrowser/trunk/src/current-patches/torbrowser-miniupnp.patch
===================================================================
--- torbrowser/trunk/src/current-patches/torbrowser-miniupnp.patch	2008-03-23 19:53:37 UTC (rev 14160)
+++ torbrowser/trunk/src/current-patches/torbrowser-miniupnp.patch	2008-03-23 21:02:36 UTC (rev 14161)
@@ -1,28 +0,0 @@
-Index: build-scripts/INSTALL
-===================================================================
---- build-scripts/INSTALL	(revision 14128)
-+++ build-scripts/INSTALL	(working copy)
-@@ -129,7 +129,23 @@
- For libevent, use 1.3e, as suggested by the document above.
- libevent 1.4.0 is newer but untested.
- 
-+Building miniupnp
-+=================
- 
-+mingw32-make.exe -f Makefile.mingw
-+INSTALL=install
-+INSTALLPREFIX=/usr/local
-+INSTALLDIRINC=$INSTALLPREFIX/include/miniupnpc
-+INSTALLDIRLIB=$INSTALLPREFIX/lib
-+HEADERS="miniupnpc.h miniwget.h upnpcommands.h igd_desc_parse.h upnpreplyparse.h upnperrors.h"
-+LIBRARY=libminiupnpc.a
-+APIVERSION=2
-+SONAME=$SHAREDLIBRARY.$APIVERSION
-+$INSTALL -d $INSTALLDIRINC
-+$INSTALL --mode=644 $HEADERS $INSTALLDIRINC
-+$INSTALL -d $INSTALLDIRLIB
-+$INSTALL --mode=644 $LIBRARY $INSTALLDIRLIB
-+
- Building Vidalia
- ================
- 

Modified: torbrowser/trunk/src/current-patches/vidalia-miniupnp.patch
===================================================================
--- torbrowser/trunk/src/current-patches/vidalia-miniupnp.patch	2008-03-23 19:53:37 UTC (rev 14160)
+++ torbrowser/trunk/src/current-patches/vidalia-miniupnp.patch	2008-03-23 21:02:36 UTC (rev 14161)
@@ -1,3 +1,16 @@
+Index: INSTALL
+===================================================================
+--- INSTALL	(revision 2423)
++++ INSTALL	(working copy)
+@@ -205,3 +205,7 @@
+ '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
 Index: src/vidalia/CMakeLists.txt
 ===================================================================
 --- src/vidalia/CMakeLists.txt	(revision 2423)
@@ -2,3 +15,11 @@
 +++ src/vidalia/CMakeLists.txt	(working copy)
-@@ -238,9 +238,16 @@
+@@ -16,6 +16,7 @@
+   ${CMAKE_CURRENT_SOURCE_DIR}
+   ${CMAKE_CURRENT_SOURCE_DIR}/config
+   ${CMAKE_CURRENT_SOURCE_DIR}/help/browser
++  ${MINIUPNPC_INCLUDE_DIR}
+ )
+ configure_file(
+   ${CMAKE_CURRENT_SOURCE_DIR}/vidalia.h.in
+@@ -238,9 +239,16 @@
  endif(APPLE)
@@ -33,11 +54,88 @@
      rc = torControl()->setConf(confValues(), errmsg);
    } else { 
      QStringList resetKeys;
-@@ -152,6 +155,14 @@
+@@ -152,6 +155,91 @@
    return rc;
  }
  
++
++/** Based on http://miniupnp.free.fr/files/download.php?file=xchat-upnp20061022.patch */
++void
++ServerSettings::init_upnp()
++{
++  struct UPNPDev * devlist;
++  struct UPNPDev * dev;
++  char * descXML;
++  int descXMLsize = 0;
++  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);
++
++      descXML = miniwget(dev->descURL, &descXMLsize);
++      if (descXML)
++	{
++	  parserootdesc (descXML, descXMLsize, &data);
++	  free (descXML); descXML = 0;
++	  GetUPNPUrls (&urls, &data, dev->descURL);
++	}
++      freeUPNPDevlist(devlist);
++    }
++
++}
++
++/** Based on http://miniupnp.free.fr/files/download.php?file=xchat-upnp20061022.patch */
++void
++ServerSettings::upnp_add_redir(const char * addr, int port)
++{
++	char port_str[16];
++	int r;
++	printf("TB : upnp_add_redir (%s, %d)\n", addr, port);
++	if(urls.controlURL[0] == '\0')
++	{
++		printf("TB : the init was not done !\n");
++		return;
++	}
++	sprintf(port_str, "%d", port);
++	r = UPNP_AddPortMapping(urls.controlURL, data.servicetype,
++	                        port_str, port_str, addr, 0, "TCP");
++	if(r==0)
++		printf("AddPortMapping(%s, %s, %s) failed\n", port_str, port_str, addr);
++}
++
++/** Based on http://miniupnp.free.fr/files/download.php?file=xchat-upnp20061022.patch */
++void
++ServerSettings::upnp_rem_redir(int port)
++{
++	char port_str[16];
++	int t;
++	printf("TB : upnp_rem_redir (%d)\n", port);
++	if(urls.controlURL[0] == '\0')
++	{
++		printf("TB : the init was not done !\n");
++		return;
++	}
++	sprintf(port_str, "%d", port);
++	UPNP_DeletePortMapping(urls.controlURL, data.servicetype, port_str, "TCP");
++}
++
 +/* 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 */
 +/** Configure UPnP device to forward DirPort and ORPort */
 +void
 +ServerSettings::configurePortForwarding()
@@ -48,3 +146,36 @@
  /** Virtual method called when we retrieve a server-related setting from Tor.
   * Currently this just translates BandwidthFoo to RelayBandwidthFoo when
   * appropriate. */
+Index: src/vidalia/config/serversettings.h
+===================================================================
+--- src/vidalia/config/serversettings.h	(revision 2423)
++++ src/vidalia/config/serversettings.h	(working copy)
+@@ -20,6 +20,9 @@
+ #include "abstracttorsettings.h"
+ #include "exitpolicy.h"
+ 
++#include <miniupnpc/miniwget.h>
++#include <miniupnpc/miniupnpc.h>
++#include <miniupnpc/upnpcommands.h>
+ 
+ class ServerSettings : public AbstractTorSettings
+ {
+@@ -89,8 +92,18 @@
+   virtual QVariant torValue(const QString &key) const;
+ 
+ private:
++  /** Used by miniupnpc library */
++  static struct UPNPUrls urls;
++  static struct IGDdatas data;
++  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



More information about the tor-commits mailing list