Author: nextgens
Date: 2007-05-23 22:27:12 +0000 (Wed, 23 May 2007)
New Revision: 13346
Modified:
trunk/plugins/UPnP/UPnP.java
Log:
UPNP: retry 5 times to port-forward the port, waiting 5sec in between each
attempt
Modified: trunk/plugins/UPnP/UPnP.java
===================================================================
--- trunk/plugins/UPnP/UPnP.java 2007-05-23 22:19:05 UTC (rev 13345)
+++ trunk/plugins/UPnP/UPnP.java 2007-05-23 22:27:12 UTC (rev 13346)
@@ -170,8 +170,16 @@
}
Logger.normal(this, "Registering a port mapping for " +
fnpPortNumber + "/udp");
- isPortForwarded = addMapping("UDP", fnpPortNumber, "Freenet 0.7
FNP - " + _router.getInterfaceAddress());
- Logger.normal(this, isPortForwarded ? "Mapping is successful!"
: "Mapping has failed!");
+ int nbOfTries = 0;
+ while(nbOfTries++ < 5) {
+ isPortForwarded = addMapping("UDP", fnpPortNumber,
"Freenet 0.7 FNP - " + _router.getInterfaceAddress());
+ if(isPortForwarded)
+ break;
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {}
+ }
+ Logger.normal(this, (isPortForwarded ? "Mapping is successful!"
: "Mapping has failed!") + " ("+ nbOfTries + " tries)");
}
public void unregisterPortMapping() {