Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
ipv6 fixes
Michael Peter Christen528f583d72db
diff --git a/htroot/Network.html b/htroot/Network.htmlindex cc745c8d2..8103772e4 100644--- a/htroot/Network.html+++ b/htroot/Network.html@@ -132,7 +132,7 @@ document.getElementById("apilink").setAttribute("href", "Network.xml?" + window.<td >#[hash]#</td><td #(special)#::class="TableCellActive"#(/special)#>#[shortname]##(ssl)#::<img src="env/grafics/lock.gif" width="11" height="15" title="https supported" alt="https supported" />#(/ssl)#</td><td nowrap>- #(type)##(direct)#<img src="env/grafics/JuniorPassive.gif" width="11" height="11" title="Type: Junior | Contact: passive" alt="Junior passive" />::<img src="env/grafics/JuniorDirect.gif" width="11" height="11" title="Type: Junior | Contact: direct" alt="Junior direct" />::<img src="env/grafics/JuniorOffline.gif" width="11" height="11" title="Type: Junior | Contact: offline" alt="Junior offline" />#(/direct)#::#(direct)#<img src="env/grafics/SeniorPassive.gif" width="11" height="11" title="Type: Senior | Contact: passive" alt="senior passive" />::<img src="env/grafics/SeniorDirect.gif" width="11" height="11" title="Type: Senior | Contact: direct" alt="Senior direct" />::<img src="env/grafics/SeniorOffline.gif" width="11" height="11" title="Type: Senior | Contact: offline" alt="Senior offline" />#(/direct)#::<a href="#[url]#" class="forceNoExternalIcon">#(direct)#<img src="env/grafics/PrincipalPassive.gif" width="11" height="11" title="Type: Principal | Contact: passive | Seed download: possible" alt="Principal passive" />::<img src="env/grafics/PrincipalDirect.gif" width="11" height="11" title="Type: Principal | Contact: direct | Seed download: possible" alt="Principal active" />::<img src="env/grafics/PrincipalOffline.gif" width="11" height="11" title="Type: Principal | Contact: offline | Seed download: ?" alt="Principal offline" />#(/direct)#</a>#(/type)##(acceptcrawl)#<img src="env/grafics/CrawlNo.gif" width="11" height="11" title="Accept Crawl: no" alt="no crawl" />::<img src="env/grafics/CrawlYes.gif" width="11" height="11" title="Accept Crawl: yes" alt="crawl possible" />::<img src="env/grafics/CrawlYesOffline.gif" width="11" height="11" title="Accept Crawl: yes" alt="crawl possible" />#(/acceptcrawl)##(dhtreceive)#<img src="env/grafics/DHTReceiveNo.gif" width="11" height="11" title="DHT Receive: no; #[peertags]#" alt="no DHT receive" />::<img src="env/grafics/DHTReceiveYes.gif" width="11" height="11" title="DHT Receive: yes" alt="DHT receive enabled" />::<img src="env/grafics/DHTReceiveYesOffline.gif" width="11" height="11" title="DHT Receive: yes" alt="DHT receive enabled" />#(/dhtreceive)##{ips}#<a href="#(c)#http://#(ipv6)#::[#(/ipv6)##[ip]##(ipv6)#::]#(/ipv6)#:#[port]#/Network.html?page=1::Network.html?page=4&peerHash=#[hash]#&peerIP=#[ip]#&peerPort=#[port]#&addPeer=add+Peer#(/c)#" class="forceNoExternalIcon"><img src="env/grafics/#(nodestate)#NodeDisqualified::NodeQualified#(/nodestate)##(c)##(ipv6)#IPv4::IPv6#(/ipv6)#::#(ipv6)#IPv4::IPv6#(/ipv6)##(/c)#.gif" width="11" height="11" title="#(c)##(ipv6)#IPv4::IPv6#(/ipv6)#::#(ipv6)#IPv4::IPv6#(/ipv6)##(/c)# #(nodestate)#Peer::Node Peer#(/nodestate)#" /></a>#{/ips}#</td>+ #(type)##(direct)#<img src="env/grafics/JuniorPassive.gif" width="11" height="11" title="Type: Junior | Contact: passive" alt="Junior passive" />::<img src="env/grafics/JuniorDirect.gif" width="11" height="11" title="Type: Junior | Contact: direct" alt="Junior direct" />::<img src="env/grafics/JuniorOffline.gif" width="11" height="11" title="Type: Junior | Contact: offline" alt="Junior offline" />#(/direct)#::#(direct)#<img src="env/grafics/SeniorPassive.gif" width="11" height="11" title="Type: Senior | Contact: passive" alt="senior passive" />::<img src="env/grafics/SeniorDirect.gif" width="11" height="11" title="Type: Senior | Contact: direct" alt="Senior direct" />::<img src="env/grafics/SeniorOffline.gif" width="11" height="11" title="Type: Senior | Contact: offline" alt="Senior offline" />#(/direct)#::<a href="#[url]#" class="forceNoExternalIcon">#(direct)#<img src="env/grafics/PrincipalPassive.gif" width="11" height="11" title="Type: Principal | Contact: passive | Seed download: possible" alt="Principal passive" />::<img src="env/grafics/PrincipalDirect.gif" width="11" height="11" title="Type: Principal | Contact: direct | Seed download: possible" alt="Principal active" />::<img src="env/grafics/PrincipalOffline.gif" width="11" height="11" title="Type: Principal | Contact: offline | Seed download: ?" alt="Principal offline" />#(/direct)#</a>#(/type)##(acceptcrawl)#<img src="env/grafics/CrawlNo.gif" width="11" height="11" title="Accept Crawl: no" alt="no crawl" />::<img src="env/grafics/CrawlYes.gif" width="11" height="11" title="Accept Crawl: yes" alt="crawl possible" />::<img src="env/grafics/CrawlYesOffline.gif" width="11" height="11" title="Accept Crawl: yes" alt="crawl possible" />#(/acceptcrawl)##(dhtreceive)#<img src="env/grafics/DHTReceiveNo.gif" width="11" height="11" title="DHT Receive: no; #[peertags]#" alt="no DHT receive" />::<img src="env/grafics/DHTReceiveYes.gif" width="11" height="11" title="DHT Receive: yes" alt="DHT receive enabled" />::<img src="env/grafics/DHTReceiveYesOffline.gif" width="11" height="11" title="DHT Receive: yes" alt="DHT receive enabled" />#(/dhtreceive)##{ips}#<a href="#(c)#http://#(ipv6)#::[#(/ipv6)##[ip]##(ipv6)#::]#(/ipv6)#:#[port]#/Network.html?page=1::Network.html?page=4&peerHash=#[hash]#&peerIP=#[ip]#&peerPort=#[port]#&addPeer=add+Peer#(/c)#"#(c)#:: target="_blank"#(/c)#class="forceNoExternalIcon"><img src="env/grafics/#(nodestate)#NodeDisqualified::NodeQualified#(/nodestate)##(c)##(ipv6)#IPv4::IPv6#(/ipv6)#::#(ipv6)#IPv4::IPv6#(/ipv6)##(/c)#.gif" width="11" height="11" title="#(c)##(ipv6)#IPv4::IPv6#(/ipv6)#::#(ipv6)#IPv4::IPv6#(/ipv6)##(/c)# #(nodestate)#Peer::Node Peer#(/nodestate)#" /></a>#{/ips}#</td><td align="right">#[version]#</td><td align="right">#[age]#</td><td align="right">#[seeds]#</td>diff --git a/htroot/Network.java b/htroot/Network.javaindex 0c4a87865..ab40fa801 100644--- a/htroot/Network.java+++ b/htroot/Network.java@@ -206,26 +206,30 @@ public class Network {}final ConcurrentMap<String, String> map = new ConcurrentHashMap<String, String>();- map.put(Seed.IP, post.get("peerIP"));- map.put(Seed.PORT, post.get("peerPort"));+ String challengeIP = post.get("peerIP");+ String challengePort = post.get("peerPort");+ map.put(Seed.IP, challengeIP);+ map.put(Seed.PORT, challengePort);Seed peer = post.get("peerHash") == null ? null : new Seed(post.get("peerHash"), map);-+ String challengeAddress = peer.getPublicAddress(challengeIP);sb.updateMySeed();- final Map<String, String> response = Protocol.hello(sb.peers.mySeed(), sb.peers.peerActions, peer.getPublicAddress(post.get("peerIP")), peer.hash);+ Seed mySeed = sb.peers.mySeed();+ final Map<String, String> response = Protocol.hello(mySeed, sb.peers.peerActions, challengeAddress, peer.hash);if (response == null) {+prop.put("table_comment",1);- prop.putHTML("table_comment_status","publish: no response from peer '" + peer.getName() + "/" + post.get("peerHash") + "' from " + peer.getIPs());+ prop.put("table_comment_status", "publish: no response from peer '" + peer.getName() + "/" + post.get("peerHash") + "' from <a href=\"http://" + challengeAddress + "\" target=\"_blank\">" + challengeAddress + "</a>");} else {String yourtype = response.get("yourtype");String yourip = response.get("yourip");peer = sb.peers.getConnected(peer.hash);if (peer == null) {prop.put("table_comment",1);- prop.putHTML("table_comment_status","publish: disconnected peer 'UNKNOWN/" + post.get("peerHash") + "' from UNKNOWN, yourtype = " + yourtype + ", yourip = " + yourip);+ prop.put("table_comment_status","publish: disconnected peer 'UNKNOWN/" + post.get("peerHash") + "' from <a href=\"http://" + challengeAddress + "\" target=\"_blank\">" + challengeAddress + "</a>, yourtype = " + yourtype + ", yourip = " + yourip);} else {prop.put("table_comment",2);- prop.putHTML("table_comment_status","publish: handshaked " + peer.get(Seed.PEERTYPE, Seed.PEERTYPE_SENIOR) + " peer '" + peer.getName() + "' at " + peer.getIPs() +", yourtype = " + yourtype + ", yourip = " + yourip);+ prop.put("table_comment_status","publish: handshaked " + peer.get(Seed.PEERTYPE, Seed.PEERTYPE_SENIOR) + " peer '" + peer.getName() + "' at <a href=\"http://" + challengeAddress + "\" target=\"_blank\">" + challengeAddress + "</a>, yourtype = " + yourtype + ", yourip = " + yourip);prop.putHTML("table_comment_details",peer.toString());}}diff --git a/htroot/env/templates/submenuComputation.template b/htroot/env/templates/submenuComputation.templateindex 544271965..b6062bcf8 100644--- a/htroot/env/templates/submenuComputation.template+++ b/htroot/env/templates/submenuComputation.template@@ -11,8 +11,8 @@<div class="SubMenugroup"><h3>Processes</h3><ul class="SubMenu">- <li><a href="Threaddump_p.html" class="MenuItemLink #(authorized)#lock::unlock#(/authorized)#">Thread Dump</a></li><li><a href="ViewLog_p.html" class="MenuItemLink #(authorized)#lock::unlock#(/authorized)#">Server Log</a></li>+ <li><a href="Threaddump_p.html" class="MenuItemLink #(authorized)#lock::unlock#(/authorized)#">Thread Dump</a></li><li><a href="PerformanceConcurrency_p.html" class="MenuItemLink #(authorized)#lock::unlock#(/authorized)#">Concurrent Indexing</a></li><li><a href="PerformanceMemory_p.html" class="MenuItemLink #(authorized)#lock::unlock#(/authorized)#">Memory Usage</a></li><li><a href="PerformanceSearch_p.html" class="MenuItemLink #(authorized)#lock::unlock#(/authorized)#">Search Sequence</a></li>diff --git a/source/net/yacy/cora/protocol/Domains.java b/source/net/yacy/cora/protocol/Domains.javaindex b3750b4bf..b7975682d 100644--- a/source/net/yacy/cora/protocol/Domains.java+++ b/source/net/yacy/cora/protocol/Domains.java@@ -40,6 +40,7 @@ import java.util.Collection;import java.util.Collections;import java.util.Enumeration;import java.util.HashSet;+import java.util.LinkedHashSet;import java.util.LinkedList;import java.util.List;import java.util.Locale;@@ -152,28 +153,43 @@ public class Domains {// fill a cache of local host namesfor (final InetAddress a: myHostAddresses) {- final String hostname = getHostName(a);- if (hostname != null) {- myHostNames.add(hostname);- myHostNames.add(a.getHostAddress());+ String hostaddressP = a.getHostAddress();+ int p = hostaddressP.indexOf('%');+ if (p > 0) hostaddressP = hostaddressP.substring(0, p);+ Set<String> hns = new LinkedHashSet<>();+ // generate alternative representations of IPv6 addresses which are needed to check access on the interface (i.e. localhost check)+ if (hostaddressP.indexOf("::") < 0) {+ hns.add(hostaddressP.replaceFirst(":0:0:0:0:0:0:", "::"));+ hns.add(hostaddressP.replaceFirst(":0:0:0:0:0:", "::"));+ hns.add(hostaddressP.replaceFirst(":0:0:0:0:", "::"));+ hns.add(hostaddressP.replaceFirst(":0:0:0:", "::"));+ hns.add(hostaddressP.replaceFirst(":0:0:", "::"));+ hns.add(hostaddressP.replaceFirst(":0:", "::"));}- // we write the local tests into variables to be able to debug these values- boolean isAnyLocalAddress = a.isAnyLocalAddress();- boolean isLinkLocalAddress = a.isLinkLocalAddress(); // true i.e. for localhost/fe80:0:0:0:0:0:0:1%1, myhost.local/fe80:0:0:0:223:dfff:fedf:30ce%7- boolean isLoopbackAddress = a.isLoopbackAddress(); // true i.e. for localhost/0:0:0:0:0:0:0:1, localhost/127.0.0.1- boolean isSiteLocalAddress = a.isSiteLocalAddress(); // true i.e. for myhost.local/192.168.1.33- if (isAnyLocalAddress || isLinkLocalAddress || isLoopbackAddress || isSiteLocalAddress) {- ConcurrentLog.info("Domain Init", "local host address: " + a + " (local)");- localHostAddresses.add(a);- if (hostname != null) {localHostNames.add(hostname); localHostNames.add(a.getHostAddress());}- } else {- ConcurrentLog.info("Domain Init", "local host address: " + a + " (public)");- if (a instanceof Inet4Address) {- publicIPv4HostAddresses.add(a);- if (hostname != null) {publicIPv4HostNames.add(hostname); publicIPv4HostNames.add(a.getHostAddress());}+ hns.add(hostaddressP);+ final String hostname = getHostName(a);+ if (hostname != null) myHostNames.add(hostname);+ myHostNames.addAll(hns);+ for (String hostaddress: hns) {+ if (hostaddress.contains("::0:") || hostaddress.contains(":0::")) continue; // not common (but possible); we skip that+ // we write the local tests into variables to be able to debug these values+ boolean isAnyLocalAddress = a.isAnyLocalAddress();+ boolean isLinkLocalAddress = a.isLinkLocalAddress(); // true i.e. for localhost/fe80:0:0:0:0:0:0:1%1, myhost.local/fe80:0:0:0:223:dfff:fedf:30ce%7+ boolean isLoopbackAddress = a.isLoopbackAddress(); // true i.e. for localhost/0:0:0:0:0:0:0:1, localhost/127.0.0.1+ boolean isSiteLocalAddress = a.isSiteLocalAddress(); // true i.e. for myhost.local/192.168.1.33+ if (isAnyLocalAddress || isLinkLocalAddress || isLoopbackAddress || isSiteLocalAddress) {+ ConcurrentLog.info("Domain Init", "local host address: " + hostaddress + " (local)");+ localHostAddresses.add(a);+ if (hostname != null) {localHostNames.add(hostname); localHostNames.add(hostaddress);}} else {- publicIPv6HostAddresses.add(a);- if (hostname != null) {publicIPv6HostNames.add(hostname); publicIPv6HostNames.add(a.getHostAddress());}+ ConcurrentLog.info("Domain Init", "local host address: " + hostaddress + " (public)");+ if (a instanceof Inet4Address) {+ publicIPv4HostAddresses.add(a);+ if (hostname != null) {publicIPv4HostNames.add(hostname); publicIPv4HostNames.add(hostaddress);}+ } else {+ publicIPv6HostAddresses.add(a);+ if (hostname != null) {publicIPv6HostNames.add(hostname); publicIPv6HostNames.add(hostaddress);}+ }}}}@@ -814,17 +830,23 @@ public class Domains {// may be IPv4 or IPv6, we chop off brackets if existif (target.charAt(0) == '[') target = target.substring(1);if (target.charAt(target.length() - 1) == ']') target = target.substring(0, target.length() - 1);+ p = target.lastIndexOf('%');+ if (p > 0) target = target.substring(0, p);return target;}// the ':' at pos p may be either a port divider or a part of an IPv6 addressif (target.charAt(p - 1) == ']') {target = target.substring(1, p - 1);+ p = target.lastIndexOf('%');+ if (p > 0) target = target.substring(0, p);return target;}// the ':' must be a port dividertarget = target.substring(0, p);+ p = target.lastIndexOf('%');+ if (p > 0) target = target.substring(0, p);return target;}diff --git a/source/net/yacy/http/AbstractRemoteHandler.java b/source/net/yacy/http/AbstractRemoteHandler.javaindex e9955e84c..d949b5d22 100644--- a/source/net/yacy/http/AbstractRemoteHandler.java+++ b/source/net/yacy/http/AbstractRemoteHandler.java@@ -97,13 +97,13 @@ abstract public class AbstractRemoteHandler extends ConnectHandler implements Haif (localVirtualHostNames.contains(hostOnly)) return; // no proxy request (quick check), continue processing by handlersif (Domains.isLocal(hostOnly, null)) return; // no proxy, continue processing by handlers- if (hostOnly.startsWith(sb.peers.myIP())) { // remote access to my external IP, continue processing by handlers- localVirtualHostNames.add(sb.peers.myIP()); // not available on init, add it now for quickcheck+ if (sb.peers.myIPs().contains(hostOnly)) { // remote access to my external IP, continue processing by handlers+ localVirtualHostNames.addAll(sb.peers.myIPs()); // not available on init, add it now for quickcheckreturn;}InetAddress resolvedIP = Domains.dnsResolve(hostOnly); // during testing isLocal() failed to resolve domain against publicIP- if (resolvedIP != null && sb.myPublicIP().equals(resolvedIP.getHostAddress())) {+ if (resolvedIP != null && sb.myPublicIPs().contains(resolvedIP.getHostAddress())) {localVirtualHostNames.add(resolvedIP.getHostName()); // remember resolved hostname//localVirtualHostNames.add(resolved.getHostAddress()); // might change ?return;diff --git a/source/net/yacy/peers/Protocol.java b/source/net/yacy/peers/Protocol.javaindex b465e5c95..f06c2eb99 100644--- a/source/net/yacy/peers/Protocol.java+++ b/source/net/yacy/peers/Protocol.java@@ -213,15 +213,7 @@ public final class Protocol {+ ((result == null) ? "result null" : ("result=" + result.toString())));return null;}- Network.log.info("yacyClient.hello thread '"- + Thread.currentThread().getName()- + "' contacted peer at "- + targetAddress- + ", received "- + ((content == null) ? "null" : content.length)- + " bytes, time = "- + responseTime- + " milliseconds");+ Network.log.info("yacyClient.hello thread '" + Thread.currentThread().getName() + "' contacted peer at " + targetAddress + ", received " + ((content == null) ? "null" : content.length) + " bytes, time = " + responseTime + " milliseconds");// check consistency with expectationSeed otherPeer = null;