|
|
|
@ -24,9 +24,13 @@
|
|
|
|
|
|
|
|
|
|
package net.yacy.http;
|
|
|
|
|
|
|
|
|
|
import java.net.Inet4Address;
|
|
|
|
|
import java.net.InetAddress;
|
|
|
|
|
import java.net.InetSocketAddress;
|
|
|
|
|
import java.net.NetworkInterface;
|
|
|
|
|
import java.net.SocketException;
|
|
|
|
|
import java.util.EnumSet;
|
|
|
|
|
import java.util.Enumeration;
|
|
|
|
|
import javax.servlet.DispatcherType;
|
|
|
|
|
import net.yacy.cora.federate.solr.SolrServlet;
|
|
|
|
|
import net.yacy.cora.federate.solr.SolrServlet.Servlet404;
|
|
|
|
@ -204,8 +208,54 @@ public class Jetty8HttpServerImpl implements YaCyHttpServer {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public InetSocketAddress generateSocketAddress(String port) throws SocketException {
|
|
|
|
|
return null; // TODO:
|
|
|
|
|
public InetSocketAddress generateSocketAddress(String extendedPortString) throws SocketException {
|
|
|
|
|
// parsing the port configuration
|
|
|
|
|
String bindIP = null;
|
|
|
|
|
int bindPort;
|
|
|
|
|
|
|
|
|
|
int pos = extendedPortString.indexOf(':');
|
|
|
|
|
if (pos != -1) {
|
|
|
|
|
bindIP = extendedPortString.substring(0,pos).trim();
|
|
|
|
|
extendedPortString = extendedPortString.substring(pos+1);
|
|
|
|
|
|
|
|
|
|
if (bindIP.length() > 0 && bindIP.charAt(0) == '#') {
|
|
|
|
|
final String interfaceName = bindIP.substring(1);
|
|
|
|
|
String hostName = null;
|
|
|
|
|
if (ConcurrentLog.isFine("SERVER")) ConcurrentLog.fine("SERVER","Trying to determine IP address of interface '" + interfaceName + "'.");
|
|
|
|
|
|
|
|
|
|
final Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
|
|
|
|
|
if (interfaces != null) {
|
|
|
|
|
while (interfaces.hasMoreElements()) {
|
|
|
|
|
final NetworkInterface interf = interfaces.nextElement();
|
|
|
|
|
if (interf.getName().equalsIgnoreCase(interfaceName)) {
|
|
|
|
|
final Enumeration<InetAddress> addresses = interf.getInetAddresses();
|
|
|
|
|
if (addresses != null) {
|
|
|
|
|
while (addresses.hasMoreElements()) {
|
|
|
|
|
final InetAddress address = addresses.nextElement();
|
|
|
|
|
if (address instanceof Inet4Address) {
|
|
|
|
|
hostName = address.getHostAddress();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (hostName == null) {
|
|
|
|
|
ConcurrentLog.warn("SERVER", "Unable to find interface with name '" + interfaceName + "'. Binding server to all interfaces");
|
|
|
|
|
bindIP = null;
|
|
|
|
|
} else {
|
|
|
|
|
ConcurrentLog.info("SERVER", "Binding server to interface '" + interfaceName + "' with IP '" + hostName + "'.");
|
|
|
|
|
bindIP = hostName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bindPort = Integer.parseInt(extendedPortString);
|
|
|
|
|
|
|
|
|
|
return (bindIP == null)
|
|
|
|
|
? new InetSocketAddress(bindPort)
|
|
|
|
|
: new InetSocketAddress(bindIP, bindPort);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|