possibility to set remote host on upnp device

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6097 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
lotus 16 years ago
parent 4d29e90708
commit db70badcf0

@ -17,6 +17,8 @@ port = 8080
# use UPnP [true/false] # use UPnP [true/false]
upnp.enabled = 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. #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 #then set bindPort to the port yacy should bind on, and port to the port, visible from outside

@ -90,6 +90,10 @@ public class UPnP {
return init; return init;
} }
private static String getRemoteHost() {
return sb.getConfig(plasmaSwitchboardConstants.UPNP_REMOTEHOST, "");
}
/** /**
* add port mapping for configured port * add port mapping for configured port
*/ */
@ -109,7 +113,7 @@ public class UPnP {
if (mappedPort == 0 && ((IGDs != null && localHostIP != null) || init())) { if (mappedPort == 0 && ((IGDs != null && localHostIP != null) || init())) {
for (InternetGatewayDevice IGD : IGDs) { for (InternetGatewayDevice IGD : IGDs) {
try { 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(); String msg = "port " + port + " on device "+ IGD.getIGDRootDevice().getFriendlyName();
if (mapped) { if (mapped) {
log.logInfo("mapped " + msg); log.logInfo("mapped " + msg);
@ -128,7 +132,7 @@ public class UPnP {
if (mappedPort > 0 && IGDs != null && localHostIP != null) { if (mappedPort > 0 && IGDs != null && localHostIP != null) {
for (InternetGatewayDevice IGD : IGDs) { for (InternetGatewayDevice IGD : IGDs) {
try { try {
boolean unmapped = IGD.deletePortMapping(null, mappedPort, mappedProtocol); boolean unmapped = IGD.deletePortMapping(getRemoteHost(), mappedPort, mappedProtocol);
String msg = "port " + mappedPort + " on device "+ IGD.getIGDRootDevice().getFriendlyName(); String msg = "port " + mappedPort + " on device "+ IGD.getIGDRootDevice().getFriendlyName();
if (unmapped) log.logInfo("unmapped " + msg); if (unmapped) log.logInfo("unmapped " + msg);
else log.logWarning("could not unmap " + msg); else log.logWarning("could not unmap " + msg);

@ -443,6 +443,7 @@ public final class plasmaSwitchboardConstants {
public static final String BROWSER_POP_UP_PAGE = "browserPopUpPage"; public static final String BROWSER_POP_UP_PAGE = "browserPopUpPage";
public static final String UPNP_ENABLED = "upnp.enabled"; public static final String UPNP_ENABLED = "upnp.enabled";
public static final String UPNP_REMOTEHOST = "upnp.remoteHost";
public static final String DEFAULT_SEARCHITEMS = "search.items"; public static final String DEFAULT_SEARCHITEMS = "search.items";

Loading…
Cancel
Save