Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
fix for bad node flag setting with IPv6
Michael Peter Christen92c5d9748628
diff --git a/source/net/yacy/cora/protocol/Domains.java b/source/net/yacy/cora/protocol/Domains.javaindex 254441884..7df76b942 100644--- a/source/net/yacy/cora/protocol/Domains.java+++ b/source/net/yacy/cora/protocol/Domains.java@@ -1076,26 +1076,37 @@ public class Domains {return localHostAddresses;}+ /**+ * this method is deprecated in some way because it is not applicable on IPv6+ * TODO: remove / replace+ * @param hostName+ * @return+ */public static boolean isThisHostIP(final String hostName) {if ((hostName == null) || (hostName.isEmpty())) return false;+ if (hostName.indexOf(':') > 0) return false; // IPv6 addresses do not count because they are always host IPsreturn isThisHostIP(Domains.dnsResolve(hostName));}+ /**+ * this method is deprecated in some way because it is not applicable on IPv6+ * TODO: remove / replace+ * @param hostName+ * @return+ */+ public static boolean isThisHostIP(final Set<String> hostNames) {+ if ((hostNames == null) || (hostNames.isEmpty())) return false;+ for (String hostName: hostNames) {+ if (hostName.indexOf(':') > 0) return false; // IPv6 addresses do not count because they are always host IPs+ if (isThisHostIP(Domains.dnsResolve(hostName))) return true;+ }+ return false;+ }+public static boolean isThisHostIP(final InetAddress clientAddress) {if (clientAddress == null) return false;-- boolean isThisHostIP = false;- try {- if (clientAddress.isAnyLocalAddress() || clientAddress.isLoopbackAddress()) return true;-- for (final InetAddress a: myHostAddresses) {- if (a.equals(clientAddress)) {- isThisHostIP = true;- break;- }- }- } catch (final Exception e) {}- return isThisHostIP;+ if (clientAddress.isAnyLocalAddress() || clientAddress.isLoopbackAddress()) return true;+ return myHostAddresses.contains(clientAddress);}public static int getDomainID(final String host, final InetAddress hostaddress) {diff --git a/source/net/yacy/http/ProxyHandler.java b/source/net/yacy/http/ProxyHandler.javaindex 3d176ff42..ff75d5760 100644--- a/source/net/yacy/http/ProxyHandler.java+++ b/source/net/yacy/http/ProxyHandler.java@@ -246,8 +246,8 @@ public class ProxyHandler extends AbstractRemoteHandler implements Handler {* adds specific header elements for the connection of the internal* httpclient to the remote server according to local config*- * @param header header f��r http client (already preset with headers from- * original ServletRequest+ * @param header header for http client (already preset with headers from+ * original ServletRequest)* @param origServletRequest original request/header*/private void setProxyHeaderForClient(final HttpServletRequest origServletRequest, final HeaderFramework header) {diff --git a/source/net/yacy/peers/Protocol.java b/source/net/yacy/peers/Protocol.javaindex 2cdc5f14c..1fa8e2a39 100644--- a/source/net/yacy/peers/Protocol.java+++ b/source/net/yacy/peers/Protocol.java@@ -265,7 +265,8 @@ public final class Protocol {}mySeed.setFlagRootNode((mytype.equals(Seed.PEERTYPE_SENIOR) || mytype.equals(Seed.PEERTYPE_PRINCIPAL)) &&- responseTime < 1000 && Domains.isThisHostIP(mySeed.getIP())+ Switchboard.getSwitchboard().index.fulltext().connectedLocalSolr() &&+ responseTime < 1000 && Domains.isThisHostIP(mySeed.getIPs()));// change our seed-type