mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
show upnp status
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5679 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
parent
f0947a20a8
commit
8ee946bf1d
|
@ -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>
|
||||
|
|
|
@ -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", ""));
|
||||
|
|
|
@ -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()); }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user