show upnp status

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5679 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
lotus 16 years ago
parent f0947a20a8
commit 8ee946bf1d

@ -86,6 +86,7 @@
</dt> </dt>
<dd> <dd>
<input type="checkbox" name="enableUpnp" id="enableUpnp" align="top" #(enabled)#::checked="checked"#(/enabled)# /> <input type="checkbox" name="enableUpnp" id="enableUpnp" align="top" #(enabled)#::checked="checked"#(/enabled)# />
#(success)#::<img src="/env/grafics/bad.png" height="16" width="16" alt="warning" /> Configuration was not successful. This may take a moment.::<img src="/env/grafics/ok.png" height="16" width="16" alt="ok" />#(/success)#
</dd>#(/upnp)# </dd>#(/upnp)#
</dl> </dl>
</fieldset> </fieldset>

@ -212,8 +212,11 @@ public class ConfigBasic {
prop.put("nextStep", NEXTSTEP_FINISHED); prop.put("nextStep", NEXTSTEP_FINISHED);
} }
final boolean upnp_enabled = env.getConfigBool(plasmaSwitchboardConstants.UPNP_ENABLED, false);
prop.put("upnp", "1"); prop.put("upnp", "1");
prop.put("upnp_enabled", (env.getConfigBool(plasmaSwitchboardConstants.UPNP_ENABLED, false)) ? "1" : "0"); prop.put("upnp_enabled", upnp_enabled ? "1" : "0");
if (upnp_enabled) prop.put("upnp_success", (UPnP.getMappedPort() > 0) ? "2" : "1");
else prop.put("upnp_success", "0");
// set default values // set default values
prop.putHTML("defaultName", env.getConfig("peerName", "")); prop.putHTML("defaultName", env.getConfig("peerName", ""));

@ -111,12 +111,14 @@ public class UPnP {
if (port < 1) return; if (port < 1) return;
if (mappedPort > 0) deletePortMapping(); // delete old mapping first if (mappedPort > 0) deletePortMapping(); // delete old mapping first
if (mappedPort == 0 && ((IGDs != null && localHostIP != null) || init())) { if (mappedPort == 0 && ((IGDs != null && localHostIP != null) || init())) {
mappedPort = port;
for (InternetGatewayDevice IGD : IGDs) { for (InternetGatewayDevice IGD : IGDs) {
try { try {
boolean mapped = IGD.addPortMapping(mappedName, null, mappedPort, mappedPort, localHostIP, 0, mappedProtocol); boolean mapped = IGD.addPortMapping(mappedName, null, port, port, localHostIP, 0, mappedProtocol);
String msg = "port " + mappedPort + " on device "+ IGD.getIGDRootDevice().getFriendlyName(); String msg = "port " + port + " on device "+ IGD.getIGDRootDevice().getFriendlyName();
if (mapped) log.logInfo("mapped " + msg); if (mapped) {
log.logInfo("mapped " + msg);
mappedPort = port;
}
else log.logWarning("could not map " + msg); else log.logWarning("could not map " + msg);
} catch (IOException e) {} catch (UPNPResponseException e) { log.logSevere("mapping error: " + e.getMessage()); } } catch (IOException e) {} catch (UPNPResponseException e) { log.logSevere("mapping error: " + e.getMessage()); }
} }

Loading…
Cancel
Save