PDA

View Full Version : UPnP workaround for Belkin F5D8233-4-v1(01)


zab_
May 7th, 2009, 02:36 PM
My Belkin N router has a bug in the UPnP actions. It appends a whitespace at the end of the port mapping action and it becomes "AddPortMapping " instead of "AddPortMapping".

Below is a workaround for this.


Index: components/gnutella-core/src/main/java/com/limegroup/gnutella/UPnPManager.java
================================================== =================
RCS file: /cvs/limewire/components/gnutella-core/src/main/java/com/limegroup/gnutella/UPnPManager.java,v
retrieving revision 1.40
diff -u -r1.40 UPnPManager.java
--- components/gnutella-core/src/main/java/com/limegroup/gnutella/UPnPManager.java 19 Mar 2009 18:28:23 -0000 1.40
+++ components/gnutella-core/src/main/java/com/limegroup/gnutella/UPnPManager.java 7 May 2009 14:27:05 -0000
@@ -329,10 +329,23 @@

Action add = _service.getAction("AddPortMapping");

- if(add == null) {
- LOG.debug("Couldn't find AddPortMapping action!");
- return false;
- }
+ if(add == null) {
+ LOG.debug("Couldn't find AddPortMapping action! Will iterate...");
+ for (Object action : _service.getActionList()) {
+ Action a = (Action)action;
+ if (a == null || a.getName() == null)
+ continue;
+ if ("AddPortMapping".equals(a.getName().trim())) {
+ add = a;
+ break;
+ }
+ }
+
+ if (add == null) {
+ LOG.debug("Really couldn't find action. Giving up.");
+ return false;
+ }
+ }


add.setArgumentValue("NewRemoteHost",m._externalAddress);

Sam
May 7th, 2009, 02:52 PM
Thanks for the patch. :-)