Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
added option to Config_Network_p.html to enable remote search while DHT-Receive is switched off.
Michael Peter Christen087df05e2418
diff --git a/defaults/yacy.init b/defaults/yacy.initindex 25769d1a8..97718794b 100644--- a/defaults/yacy.init+++ b/defaults/yacy.init@@ -478,6 +478,7 @@ allowDistributeIndex=trueallowDistributeIndexWhileCrawling=falseallowDistributeIndexWhileIndexing=trueallowReceiveIndex=true+allowReceiveIndex.search=trueallowUnlimitedReceiveIndexFrom=indexReceiveBlockBlacklist=truediff --git a/htroot/ConfigBasic.java b/htroot/ConfigBasic.javaindex ef545eb13..8d48d786b 100644--- a/htroot/ConfigBasic.java+++ b/htroot/ConfigBasic.java@@ -180,6 +180,7 @@ public class ConfigBasic {// switch to p2p modesb.setConfig(SwitchboardConstants.INDEX_DIST_ALLOW, true);sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW, true);+ sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, true);// set default behavior for search verificationsb.setConfig(SwitchboardConstants.SEARCH_VERIFY, "iffresh"); // nocache,iffresh,ifexist,cacheonly,falsesb.setConfig(SwitchboardConstants.SEARCH_VERIFY_DELETE, "true");@@ -190,6 +191,7 @@ public class ConfigBasic {// switch to robinson modesb.setConfig(SwitchboardConstants.INDEX_DIST_ALLOW, false);sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW, false);+ sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, false);// set default behavior for search verificationsb.setConfig(SwitchboardConstants.SEARCH_VERIFY, "ifexist"); // nocache,iffresh,ifexist,cacheonly,falsesb.setConfig(SwitchboardConstants.SEARCH_VERIFY_DELETE, "false");@@ -200,6 +202,7 @@ public class ConfigBasic {// switch to p2p mode: enable ad-hoc networks between intranet userssb.setConfig(SwitchboardConstants.INDEX_DIST_ALLOW, false);sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW, false);+ sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, false);// set default behavior for search verificationsb.setConfig(SwitchboardConstants.SEARCH_VERIFY, "cacheonly"); // nocache,iffresh,ifexist,cacheonly,falsesb.setConfig(SwitchboardConstants.SEARCH_VERIFY_DELETE, "false");diff --git a/htroot/ConfigNetwork_p.html b/htroot/ConfigNetwork_p.htmlindex 63551f477..364ea7eb3 100644--- a/htroot/ConfigNetwork_p.html+++ b/htroot/ConfigNetwork_p.html@@ -11,17 +11,18 @@if(!(dist || recv)) {//robinson-modedocument.getElementById("ConfigForm").network[1].checked = true;- }- else {+ } else {//p2p-modedocument.getElementById("ConfigForm").network[0].checked = true;}+ document.getElementById("ConfigForm").indexReceiveSearch[recv ? 0 : 1].checked = true;}function EnableRobinson() {if(document.getElementById("ConfigForm").network[1].checked) {document.getElementById("ConfigForm").indexDistribute.checked = false;document.getElementById("ConfigForm").indexReceive.checked = false;+ document.getElementById("ConfigForm").indexReceiveSearch[1].checked = true;}}@@ -29,7 +30,7 @@if(document.getElementById("ConfigForm").network[0].checked) {document.getElementById("ConfigForm").indexDistribute.checked = true;document.getElementById("ConfigForm").indexReceive.checked = true;- document.getElementById("ConfigForm").crawlResponse.checked = true;+ document.getElementById("ConfigForm").indexReceiveSearch[0].checked = true;}}//-->@@ -143,7 +144,15 @@<input type="radio" value="off" id="indexReceiveBlockBlacklistOff"name="indexReceiveBlockBlacklist"#(indexReceiveBlockBlacklistChecked.off)#::checked="checked" #(/indexReceiveBlockBlacklistChecked.off)#/>- <label for="indexReceiveBlockBlacklistOff">accept transmitted URLs that match your blacklist</label>.+ <label for="indexReceiveBlockBlacklistOff">accept transmitted URLs that match your blacklist</label>.<br />+ <input type="radio" value="on" id="indexReceiveSearchOn"+ name="indexReceiveSearch"+ #(indexReceiveSearchChecked)#::checked="checked"#(/indexReceiveSearchChecked)#/>+ <label for="indexReceiveSearchOn">allow</label> /+ <input type="radio" value="off" id="indexReceiveSearchOff"+ name="indexReceiveSearch"+ #(indexReceiveSearchChecked)#checked="checked"::#(/indexReceiveSearchChecked)#/>+ <label for="indexReceiveSearchOff">deny remote search</label>.</dd><dt></dt><dd>diff --git a/htroot/ConfigNetwork_p.java b/htroot/ConfigNetwork_p.javaindex 75ae2f39e..cfc66a097 100644--- a/htroot/ConfigNetwork_p.java+++ b/htroot/ConfigNetwork_p.java@@ -89,6 +89,7 @@ public class ConfigNetwork_p// DHT controlboolean indexDistribute = "on".equals(post.get("indexDistribute", ""));boolean indexReceive = "on".equals(post.get("indexReceive", ""));+ boolean indexReceiveSearch = "on".equals(post.get("indexReceiveSearch", ""));if ( !indexReceive ) {// remove heuristicssb.setConfig(SwitchboardConstants.HEURISTIC_SITE, false);@@ -114,47 +115,21 @@ public class ConfigNetwork_p}}- if ( indexDistribute ) {- sb.setConfig(SwitchboardConstants.INDEX_DIST_ALLOW, true);- } else {- sb.setConfig(SwitchboardConstants.INDEX_DIST_ALLOW, false);- }+ sb.setConfig(SwitchboardConstants.INDEX_DIST_ALLOW, indexDistribute);+ sb.setConfig(SwitchboardConstants.INDEX_DIST_ALLOW_WHILE_CRAWLING, "on".equals(post.get("indexDistributeWhileCrawling", "")));+ sb.setConfig(SwitchboardConstants.INDEX_DIST_ALLOW_WHILE_INDEXING, "on".equals(post.get("indexDistributeWhileIndexing", "")));+ sb.peers.mySeed().setFlagAcceptRemoteIndex(indexReceive);+ sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW, indexReceive);+ sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, indexReceiveSearch);+ sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_AUTODISABLED, false);- if ( "on".equals(post.get("indexDistributeWhileCrawling", "")) ) {- sb.setConfig(SwitchboardConstants.INDEX_DIST_ALLOW_WHILE_CRAWLING, true);- } else {- sb.setConfig(SwitchboardConstants.INDEX_DIST_ALLOW_WHILE_CRAWLING, false);- }+ sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_BLOCK_BLACKLIST, "on".equals(post.get("indexReceiveBlockBlacklist", "")));- if ( "on".equals(post.get("indexDistributeWhileIndexing", "")) ) {- sb.setConfig(SwitchboardConstants.INDEX_DIST_ALLOW_WHILE_INDEXING, true);- } else {- sb.setConfig(SwitchboardConstants.INDEX_DIST_ALLOW_WHILE_INDEXING, false);+ if (post.containsKey("peertags")) {+ sb.peers.mySeed().setPeerTags(MapTools.string2set(normalizedList(post.get("peertags")), ","));}- if ( indexReceive ) {- sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW, true);- sb.peers.mySeed().setFlagAcceptRemoteIndex(true);- } else {- sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW, false);- sb.peers.mySeed().setFlagAcceptRemoteIndex(false);- sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_AUTODISABLED, false);- }-- if ( "on".equals(post.get("indexReceiveBlockBlacklist", "")) ) {- sb.setConfig("indexReceiveBlockBlacklist", true);- } else {- sb.setConfig("indexReceiveBlockBlacklist", false);- }-- if ( post.containsKey("peertags") ) {- sb.peers.mySeed().setPeerTags(- MapTools.string2set(normalizedList(post.get("peertags")), ","));- }-- sb.setConfig("cluster.mode", post.get(- SwitchboardConstants.CLUSTER_MODE,- SwitchboardConstants.CLUSTER_MODE_PUBLIC_PEER));+ sb.setConfig("cluster.mode", post.get(SwitchboardConstants.CLUSTER_MODE, SwitchboardConstants.CLUSTER_MODE_PUBLIC_PEER));sb.setConfig("cluster.peers.ipport", checkIPPortList(post.get("cluster.peers.ipport", "")));sb.setConfig("cluster.peers.yacydomain",@@ -176,37 +151,28 @@ public class ConfigNetwork_pfinal int RTCppm = (int) (60000L / RTCbusySleep);prop.put("acceptCrawlLimit", RTCppm);- final boolean indexDistribute = sb.getConfigBool(SwitchboardConstants.INDEX_DIST_ALLOW, true);- final boolean indexReceive = sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW, true);- prop.put("indexDistributeChecked", (indexDistribute) ? "1" : "0");- prop.put(- "indexDistributeWhileCrawling.on",- (sb.getConfigBool(SwitchboardConstants.INDEX_DIST_ALLOW_WHILE_CRAWLING, true)) ? "1" : "0");- prop.put(- "indexDistributeWhileCrawling.off",- (sb.getConfigBool(SwitchboardConstants.INDEX_DIST_ALLOW_WHILE_CRAWLING, true)) ? "0" : "1");- prop.put(- "indexDistributeWhileIndexing.on",- (sb.getConfigBool(SwitchboardConstants.INDEX_DIST_ALLOW_WHILE_INDEXING, true)) ? "1" : "0");- prop.put(- "indexDistributeWhileIndexing.off",- (sb.getConfigBool(SwitchboardConstants.INDEX_DIST_ALLOW_WHILE_INDEXING, true)) ? "0" : "1");- prop.put("indexReceiveChecked", (indexReceive) ? "1" : "0");- prop.put(- "indexReceiveBlockBlacklistChecked.on",- (sb.getConfigBool("indexReceiveBlockBlacklist", true)) ? "1" : "0");- prop.put(- "indexReceiveBlockBlacklistChecked.off",- (sb.getConfigBool("indexReceiveBlockBlacklist", true)) ? "0" : "1");+ prop.put("indexDistributeWhileCrawling.on", sb.getConfigBool(SwitchboardConstants.INDEX_DIST_ALLOW_WHILE_CRAWLING, true));+ prop.put("indexDistributeWhileCrawling.off", !sb.getConfigBool(SwitchboardConstants.INDEX_DIST_ALLOW_WHILE_CRAWLING, true));+ prop.put("indexDistributeWhileIndexing.on", sb.getConfigBool(SwitchboardConstants.INDEX_DIST_ALLOW_WHILE_INDEXING, true));+ prop.put("indexDistributeWhileIndexing.off", !sb.getConfigBool(SwitchboardConstants.INDEX_DIST_ALLOW_WHILE_INDEXING, true));+ prop.put("indexReceiveBlockBlacklistChecked.on", sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_BLOCK_BLACKLIST, true));+ prop.put("indexReceiveBlockBlacklistChecked.off", !sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_BLOCK_BLACKLIST, true));prop.putHTML("peertags", MapTools.set2string(sb.peers.mySeed().getPeerTags(), ",", false));+ final boolean indexDistribute = sb.getConfigBool(SwitchboardConstants.INDEX_DIST_ALLOW, true);+ final boolean indexReceive = sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW, true);+ final boolean indexReceiveSearch = sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, true);+ prop.put("indexDistributeChecked", indexDistribute);+ prop.put("indexReceiveChecked", indexReceive);+ prop.put("indexReceiveSearchChecked", indexReceiveSearch);+// set seed information directlysb.peers.mySeed().setFlagAcceptRemoteCrawl(sb.getConfigBool("crawlResponse", false));sb.peers.mySeed().setFlagAcceptRemoteIndex(indexReceive);// set p2p/robinson mode flags and values- prop.put("p2p.checked", (indexDistribute || indexReceive) ? "1" : "0");- prop.put("robinson.checked", (indexDistribute || indexReceive) ? "0" : "1");+ prop.put("p2p.checked", indexDistribute || indexReceive);+ prop.put("robinson.checked", !(indexDistribute || indexReceive));prop.putHTML("cluster.peers.ipport", sb.getConfig("cluster.peers.ipport", ""));prop.putHTML("cluster.peers.yacydomain", sb.getConfig("cluster.peers.yacydomain", ""));StringBuilder hashes = new StringBuilder();@@ -220,15 +186,9 @@ public class ConfigNetwork_pprop.put("cluster.peers.yacydomain.hashes", hashes.toString());// set p2p mode flags- prop.put(- "privatepeerChecked",- (SwitchboardConstants.CLUSTER_MODE_PRIVATE_PEER.equals(sb.getConfig(SwitchboardConstants.CLUSTER_MODE, ""))) ? "1" : "0");- prop.put(- "publicclusterChecked",- (SwitchboardConstants.CLUSTER_MODE_PUBLIC_CLUSTER.equals(sb.getConfig(SwitchboardConstants.CLUSTER_MODE, ""))) ? "1" : "0");- prop.put(- "publicpeerChecked",- (SwitchboardConstants.CLUSTER_MODE_PUBLIC_PEER.equals(sb.getConfig(SwitchboardConstants.CLUSTER_MODE, ""))) ? "1" : "0");+ prop.put("privatepeerChecked", SwitchboardConstants.CLUSTER_MODE_PRIVATE_PEER.equals(sb.getConfig(SwitchboardConstants.CLUSTER_MODE, "")));+ prop.put("publicclusterChecked", SwitchboardConstants.CLUSTER_MODE_PUBLIC_CLUSTER.equals(sb.getConfig(SwitchboardConstants.CLUSTER_MODE, "")));+ prop.put("publicpeerChecked", SwitchboardConstants.CLUSTER_MODE_PUBLIC_PEER.equals(sb.getConfig(SwitchboardConstants.CLUSTER_MODE, "")));// set network configurationprop.putHTML("network.unit.definition", sb.getConfig("network.unit.definition", ""));diff --git a/htroot/index.java b/htroot/index.javaindex 672a1da43..07edfc37f 100644--- a/htroot/index.java+++ b/htroot/index.java@@ -73,8 +73,7 @@ public class index {final int type = (post == null) ? 0 : post.getInt("type", 0);//final boolean indexDistributeGranted = sb.getConfigBool(SwitchboardConstants.INDEX_DIST_ALLOW, true);- final boolean indexReceiveGranted = sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW, true) ||- sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_AUTODISABLED, true);+ final boolean indexReceiveGranted = sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, true);global = global && indexReceiveGranted;// search domaindiff --git a/htroot/yacy/transferRWI.java b/htroot/yacy/transferRWI.javaindex bd6f18e67..03aa000f0 100644--- a/htroot/yacy/transferRWI.java+++ b/htroot/yacy/transferRWI.java@@ -96,7 +96,7 @@ public final class transferRWI {final int entryc = post.getInt("entryc", 0); // number of entries in indexesbyte[] indexes = post.get("indexes", "").getBytes(); // the indexes, as list of word entriesboolean granted = sb.getConfigBool("allowReceiveIndex", false);- final boolean blockBlacklist = sb.getConfigBool("indexReceiveBlockBlacklist", false);+ final boolean blockBlacklist = sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_BLOCK_BLACKLIST, false);final long cachelimit = sb.getConfigLong(SwitchboardConstants.WORDCACHE_MAX_COUNT, 100000);final Seed otherPeer = sb.peers.get(iam);final String otherPeerName = iam + ":" + ((otherPeer == null) ? "NULL" : (otherPeer.getName() + "/" + otherPeer.getVersion()));diff --git a/htroot/yacy/transferURL.java b/htroot/yacy/transferURL.javaindex f28fe9137..746d42c3d 100644--- a/htroot/yacy/transferURL.java+++ b/htroot/yacy/transferURL.java@@ -46,6 +46,7 @@ import net.yacy.peers.Protocol;import net.yacy.peers.Seed;import net.yacy.repository.Blacklist.BlacklistType;import net.yacy.search.Switchboard;+import net.yacy.search.SwitchboardConstants;import net.yacy.server.serverCore;import net.yacy.server.serverObjects;import net.yacy.server.serverSwitch;@@ -69,7 +70,7 @@ public final class transferURL {// final String key = post.get("key", ""); // transmission keyfinal int urlc = post.getInt("urlc", 0); // number of transported urlsfinal boolean granted = sb.getConfigBool("allowReceiveIndex", false);- final boolean blockBlacklist = sb.getConfigBool("indexReceiveBlockBlacklist", false);+ final boolean blockBlacklist = sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_BLOCK_BLACKLIST, false);// response valuesString result = "";diff --git a/htroot/yacysearch.java b/htroot/yacysearch.javaindex b79c8061b..9f2ba85e6 100644--- a/htroot/yacysearch.java+++ b/htroot/yacysearch.java@@ -153,10 +153,7 @@ public class yacysearch {prop.put("rssYacyImageURL", "http://" + hostName + "/env/grafics/yacy.gif");prop.put("thisaddress", hostName);final boolean clustersearch = sb.isRobinsonMode() && sb.getConfig(SwitchboardConstants.CLUSTER_MODE, "").equals(SwitchboardConstants.CLUSTER_MODE_PUBLIC_CLUSTER);- final boolean indexReceiveGranted =- sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW, true)- || sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_AUTODISABLED, true)- || clustersearch;+ final boolean indexReceiveGranted = sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, true) || clustersearch;boolean p2pmode = sb.peers != null && sb.peers.sizeConnected() > 0 && indexReceiveGranted;boolean global = post == null || (post.get("resource", "local").equals("global") && p2pmode);boolean stealthmode = p2pmode && !global;diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.javaindex 570dc5d2a..ffbf6a1ef 100644--- a/htroot/yacysearchitem.java+++ b/htroot/yacysearchitem.java@@ -260,10 +260,7 @@ public class yacysearchitem {prop.put("content_loc_lon", result.lon());}final boolean clustersearch = sb.isRobinsonMode() && sb.getConfig(SwitchboardConstants.CLUSTER_MODE, "").equals(SwitchboardConstants.CLUSTER_MODE_PUBLIC_CLUSTER);- final boolean indexReceiveGranted =- sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW, true)- || sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_AUTODISABLED, true)- || clustersearch;+ final boolean indexReceiveGranted = sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, true) || clustersearch;boolean p2pmode = sb.peers != null && sb.peers.sizeConnected() > 0 && indexReceiveGranted;boolean stealthmode = p2pmode && theSearch.query.isLocal();if ((sb.getConfigBool(SwitchboardConstants.HEURISTIC_SEARCHRESULTS, false) ||diff --git a/source/net/yacy/search/SwitchboardConstants.java b/source/net/yacy/search/SwitchboardConstants.javaindex d6dfd24c8..9660cab17 100644--- a/source/net/yacy/search/SwitchboardConstants.java+++ b/source/net/yacy/search/SwitchboardConstants.java@@ -243,6 +243,9 @@ public final class SwitchboardConstants {*/public static final String INDEX_DIST_ALLOW = "allowDistributeIndex";public static final String INDEX_RECEIVE_ALLOW = "allowReceiveIndex";+ public static final String INDEX_RECEIVE_ALLOW_SEARCH = "allowReceiveIndex.search";+ public static final String INDEX_RECEIVE_BLOCK_BLACKLIST = "indexReceiveBlockBlacklist";+/*** <p><code>public static final String <strong>INDEX_DIST_ALLOW_WHILE_CRAWLING</strong> = "allowDistributeIndexWhileCrawling"</code></p>* <p>Name of the setting whether Index Distribution shall be allowed while crawling is in progress, i.e.diff --git a/source/net/yacy/search/query/SearchEvent.java b/source/net/yacy/search/query/SearchEvent.javaindex 8b5f1777e..310fc9072 100644--- a/source/net/yacy/search/query/SearchEvent.java+++ b/source/net/yacy/search/query/SearchEvent.java@@ -245,7 +245,7 @@ public final class SearchEvent {this.IAmaxcounthash = null;this.IAneardhthash = null;this.localSearchThread = null;- this.remote = (peers != null && peers.sizeConnected() > 0) && (this.query.domType == QueryParams.Searchdom.CLUSTER || (this.query.domType == QueryParams.Searchdom.GLOBAL && Switchboard.getSwitchboard().getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW, false)));+ this.remote = (peers != null && peers.sizeConnected() > 0) && (this.query.domType == QueryParams.Searchdom.CLUSTER || (this.query.domType == QueryParams.Searchdom.GLOBAL && Switchboard.getSwitchboard().getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, false)));this.local_rwi_available = new AtomicInteger(0); // the number of results in the local peer after filteringthis.local_rwi_stored = new AtomicInteger(0);this.local_solr_available = new AtomicInteger(0);@@ -343,7 +343,7 @@ public final class SearchEvent {} else {this.primarySearchThreadsL = null;this.nodeSearchThreads = null;- this.pollImmediately = !query.getSegment().connectedRWI() || !Switchboard.getSwitchboard().getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW, false);+ this.pollImmediately = !query.getSegment().connectedRWI() || !Switchboard.getSwitchboard().getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, false);if ( generateAbstracts ) {// we need the results nowtry {diff --git a/source/net/yacy/server/serverObjects.java b/source/net/yacy/server/serverObjects.javaindex 62310a801..3937303f0 100644--- a/source/net/yacy/server/serverObjects.java+++ b/source/net/yacy/server/serverObjects.java@@ -204,6 +204,10 @@ public class serverObjects implements Serializable, Cloneable {map.getMap().put(key, aa);return;}++ public void put(final String key, final boolean value) {+ put(key, value ? "1" : "0");+ }public void put(final String key, final String value) {if (key == null) {