possibility to use anonther bindPort than the externally reachable port.

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3161 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
allo 18 years ago
parent d98420a563
commit 6ff8359b98

@ -102,7 +102,8 @@ public final class serverCore extends serverAbstractThread implements serverThre
public static Hashtable bfHost = new Hashtable(); // for brute-force prevention
// class variables
private String extendedPort; // the listening port
private String extendedPort; // the port, which is visible from outside (in most cases bind-port)
private String bindPort; // if set, yacy will bind to this port, but set extendedPort in the seed
public boolean forceRestart = false; // specifies if the server should try to do a restart
public static boolean portForwardingEnabled = false;
@ -224,10 +225,11 @@ public final class serverCore extends serverAbstractThread implements serverThre
// read some config values
this.extendedPort = this.switchboard.getConfig("port", "8080").trim();
this.bindPort = this.switchboard.getConfig("bindPort", "").trim();
// Open a new server-socket channel
try {
this.initPort(this.extendedPort);
this.initPort(this.extendedPort, this.bindPort);
} catch (Exception e) {
String errorMsg = "FATAL ERROR: " + e.getMessage() + " - probably root access rights needed. check port number";
this.log.logSevere(errorMsg);
@ -278,16 +280,22 @@ public final class serverCore extends serverAbstractThread implements serverThre
this.theSessionPool = new SessionPool(new SessionFactory(this.theSessionThreadGroup),this.sessionPoolConfig);
}
public void initPort(String thePort) throws IOException {
this.log.logInfo("Trying to bind server to port " + thePort);
public void initPort(String seedPort, String bindPort) throws IOException {
// Binds the ServerSocket to a specific address
InetSocketAddress bindAddress = null;
this.socket = new ServerSocket();
this.socket.bind(bindAddress = generateSocketAddress(thePort));
if(bindPort == null || bindPort.equals("")){
this.log.logInfo("Trying to bind server to port " + seedPort);
this.socket.bind(bindAddress = generateSocketAddress(seedPort));
}else{ //bindPort set, use another port to bind than the port reachable from outside
this.log.logInfo("Trying to bind server to port " + bindPort+ " with "+ seedPort + "as seedPort.");
this.socket.bind(bindAddress = generateSocketAddress(bindPort));
}
// updating the port information
yacyCore.seedDB.mySeed.put(yacySeed.PORT,Integer.toString(bindAddress.getPort()));
//yacyCore.seedDB.mySeed.put(yacySeed.PORT,Integer.toString(bindAddress.getPort()));
yacyCore.seedDB.mySeed.put(yacySeed.PORT, seedPort);
}
public static int getPortNr(String extendedPortString) {

@ -15,6 +15,13 @@
# 192.168.0.1:8080
port = 8080
#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
#to run yacy on port 8080, reachable from port 80, set bindPort=8080, port=80 and use
#iptables -t nat -A PREROUTING -p tcp -s 192.168.24.0/16 --dport 80 -j DNAT --to 192.168.24.1:8080
#(of course you need to customize the ips)
bindPort =
# SSL support:
#
# For a German manual see http://yacy-websuche.de/wiki/index.php/De:Interface%C3%9CberHTTPS

Loading…
Cancel
Save