Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
implement Jetty8HttpServerImpl.generateSocketAddress (code 1:1 copied from serverCore)
regerb29d262e70f3
diff --git a/source/net/yacy/http/Jetty8HttpServerImpl.java b/source/net/yacy/http/Jetty8HttpServerImpl.javaindex 673a52ac2..46dad83a4 100644--- a/source/net/yacy/http/Jetty8HttpServerImpl.java+++ b/source/net/yacy/http/Jetty8HttpServerImpl.java@@ -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);+}@Overridediff --git a/source/net/yacy/server/serverCore.java b/source/net/yacy/server/serverCore.javaindex d5344ed80..0342cea38 100644--- a/source/net/yacy/server/serverCore.java+++ b/source/net/yacy/server/serverCore.java@@ -250,6 +250,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread,return Integer.parseInt(extendedPortString);}+ @Overridepublic InetSocketAddress generateSocketAddress(String extendedPortString) throws SocketException {// parsing the port configuration@@ -971,6 +972,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread,if ((currentThread instanceof serverCore.Session) && ((serverCore.Session)currentThread).isStopped()) throw new InterruptedException();}+ @Overridepublic void reconnect(final int delay) {final Thread restart = new Restarter(delay);restart.start();