diff options
| author | lotus <lotus@6c8d7289-2bf4-0310-a012-ef5d649a1542> | 2009-03-07 15:31:24 +0000 |
|---|---|---|
| committer | lotus <lotus@6c8d7289-2bf4-0310-a012-ef5d649a1542> | 2009-03-07 15:31:24 +0000 |
| commit | 8ee946bf1d02db51aa6e8993aace78da71dc88ee (patch) | |
| tree | 1b10b88d65a171d1c82b85238143e522f1803493 | |
| parent | f0947a20a871d82739c4f043662a98415fa04818 (diff) | |
show upnp status
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5679 6c8d7289-2bf4-0310-a012-ef5d649a1542
| -rw-r--r-- | htroot/ConfigBasic.html | 1 | ||||
| -rw-r--r-- | htroot/ConfigBasic.java | 5 | ||||
| -rw-r--r-- | source/de/anomic/net/UPnP.java | 10 |
3 files changed, 11 insertions, 5 deletions
diff --git a/htroot/ConfigBasic.html b/htroot/ConfigBasic.html index c60f32407..4e6e91d9a 100644 --- a/htroot/ConfigBasic.html +++ b/htroot/ConfigBasic.html @@ -86,6 +86,7 @@ </dt> <dd> <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)# </dl> </fieldset> diff --git a/htroot/ConfigBasic.java b/htroot/ConfigBasic.java index 428bbfa0a..2ee2915cb 100644 --- a/htroot/ConfigBasic.java +++ b/htroot/ConfigBasic.java @@ -212,8 +212,11 @@ public class ConfigBasic { prop.put("nextStep", NEXTSTEP_FINISHED); } + final boolean upnp_enabled = env.getConfigBool(plasmaSwitchboardConstants.UPNP_ENABLED, false); 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 prop.putHTML("defaultName", env.getConfig("peerName", "")); diff --git a/source/de/anomic/net/UPnP.java b/source/de/anomic/net/UPnP.java index 19010a95e..d7be4c543 100644 --- a/source/de/anomic/net/UPnP.java +++ b/source/de/anomic/net/UPnP.java @@ -111,12 +111,14 @@ public class UPnP { if (port < 1) return;
if (mappedPort > 0) deletePortMapping(); // delete old mapping first
if (mappedPort == 0 && ((IGDs != null && localHostIP != null) || init())) {
- mappedPort = port;
for (InternetGatewayDevice IGD : IGDs) {
try {
- boolean mapped = IGD.addPortMapping(mappedName, null, mappedPort, mappedPort, localHostIP, 0, mappedProtocol);
- String msg = "port " + mappedPort + " on device "+ IGD.getIGDRootDevice().getFriendlyName();
- if (mapped) log.logInfo("mapped " + msg);
+ boolean mapped = IGD.addPortMapping(mappedName, null, port, port, localHostIP, 0, mappedProtocol);
+ String msg = "port " + port + " on device "+ IGD.getIGDRootDevice().getFriendlyName();
+ if (mapped) {
+ log.logInfo("mapped " + msg);
+ mappedPort = port;
+ }
else log.logWarning("could not map " + msg);
} catch (IOException e) {} catch (UPNPResponseException e) { log.logSevere("mapping error: " + e.getMessage()); }
}
|
