diff --git a/defaults/yacy.init b/defaults/yacy.init index a77f13a50..6dfc7b1a0 100644 --- a/defaults/yacy.init +++ b/defaults/yacy.init @@ -17,6 +17,8 @@ port = 8080 # use UPnP [true/false] upnp.enabled = +# remote host on UPnP device +upnp.remoteHost = #sometimes you may want yacy to bind to another port, than the one reachable from outside. #then set bindPort to the port yacy should bind on, and port to the port, visible from outside diff --git a/source/de/anomic/net/UPnP.java b/source/de/anomic/net/UPnP.java index f2abdbd6f..c65a1ad66 100644 --- a/source/de/anomic/net/UPnP.java +++ b/source/de/anomic/net/UPnP.java @@ -90,6 +90,10 @@ public class UPnP { return init; } + private static String getRemoteHost() { + return sb.getConfig(plasmaSwitchboardConstants.UPNP_REMOTEHOST, ""); + } + /** * add port mapping for configured port */ @@ -109,7 +113,7 @@ public class UPnP { if (mappedPort == 0 && ((IGDs != null && localHostIP != null) || init())) { for (InternetGatewayDevice IGD : IGDs) { try { - boolean mapped = IGD.addPortMapping(mappedName, null, port, port, localHostIP, 0, mappedProtocol); + boolean mapped = IGD.addPortMapping(mappedName, getRemoteHost(), port, port, localHostIP, 0, mappedProtocol); String msg = "port " + port + " on device "+ IGD.getIGDRootDevice().getFriendlyName(); if (mapped) { log.logInfo("mapped " + msg); @@ -128,7 +132,7 @@ public class UPnP { if (mappedPort > 0 && IGDs != null && localHostIP != null) { for (InternetGatewayDevice IGD : IGDs) { try { - boolean unmapped = IGD.deletePortMapping(null, mappedPort, mappedProtocol); + boolean unmapped = IGD.deletePortMapping(getRemoteHost(), mappedPort, mappedProtocol); String msg = "port " + mappedPort + " on device "+ IGD.getIGDRootDevice().getFriendlyName(); if (unmapped) log.logInfo("unmapped " + msg); else log.logWarning("could not unmap " + msg); diff --git a/source/de/anomic/plasma/plasmaSwitchboardConstants.java b/source/de/anomic/plasma/plasmaSwitchboardConstants.java index d983fd360..3ad2c08b7 100644 --- a/source/de/anomic/plasma/plasmaSwitchboardConstants.java +++ b/source/de/anomic/plasma/plasmaSwitchboardConstants.java @@ -443,6 +443,7 @@ public final class plasmaSwitchboardConstants { public static final String BROWSER_POP_UP_PAGE = "browserPopUpPage"; public static final String UPNP_ENABLED = "upnp.enabled"; + public static final String UPNP_REMOTEHOST = "upnp.remoteHost"; public static final String DEFAULT_SEARCHITEMS = "search.items";