Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
- more constants - display why global search is not available on search page
karlchenofhell6265d321bdc2
diff --git a/htroot/index.html b/htroot/index.htmlindex 2e1f910da..eae572fad 100644--- a/htroot/index.html+++ b/htroot/index.html@@ -58,9 +58,16 @@<td><label for="resource">Resource</label>:</td><td><select id="resource" name="resource">- <option value="global" #(resource-global)#::selected="selected"#(/resource-global)#>global</option>+ <option value="global" #(resource-global)#::selected="selected"#(/resource-global)#+ #(resource-global-disabled)#::disabled="disabled"#(/resource-global-disabled)#>global</option><option value="local" #(resource-local)#::selected="selected"#(/resource-local)#>local</option></select>+ #(resource-global-disabled)#::+ Global search is disabled because<br />#(reason)#+ <a class="lock" href="ConfigNetwork_p.html">DHT Distribution</a> is::+ <a class="lock" href="ConfigNetwork_p.html">Index Receive</a> is::+ <a class="lock" href="ConfigNetwork_p.html">DHT Distribution and Index Receive</a> are#(/reason)#+ disabled.#(/resource-global-disabled)#</td></tr><tr>diff --git a/htroot/index.java b/htroot/index.javaindex 1265d10b0..5a54bbe90 100644--- a/htroot/index.java+++ b/htroot/index.java@@ -74,11 +74,14 @@ public class index {final String cat = (post == null) ? "href" : post.get("cat", "href");final int type = (post == null) ? 0 : post.getInt("type", 0);- final boolean indexDistributeGranted = sb.getConfig(plasmaSwitchboard.INDEX_DIST_ALLOW, "true").equals("true");- final boolean indexReceiveGranted = sb.getConfig("allowReceiveIndex", "true").equals("true");+ final boolean indexDistributeGranted = sb.getConfigBool(plasmaSwitchboard.INDEX_DIST_ALLOW, true);+ final boolean indexReceiveGranted = sb.getConfigBool(plasmaSwitchboard.INDEX_RECEIVE_ALLOW, true);if (!indexDistributeGranted || !indexReceiveGranted) { global = false; }+ final boolean clustersearch = sb.isRobinsonMode() &&+ (sb.getConfig(plasmaSwitchboard.CLUSTER_MODE, "").equals(plasmaSwitchboard.CLUSTER_MODE_PRIVATE_CLUSTER) ||+ sb.getConfig(plasmaSwitchboard.CLUSTER_MODE, "").equals(plasmaSwitchboard.CLUSTER_MODE_PUBLIC_CLUSTER));- final String referer = (String) header.get("Referer");+ final String referer = (String) header.get(httpHeader.REFERER);if (referer != null) {URL url;try {@@ -89,8 +92,8 @@ public class index {if ((url != null) && (serverCore.isNotLocal(url))) {final HashMap referrerprop = new HashMap();referrerprop.put("count", "1");- referrerprop.put("clientip", header.get("CLIENTIP"));- referrerprop.put("useragent", header.get("User-Agent"));+ referrerprop.put("clientip", header.get(httpHeader.CONNECTION_PROP_CLIENTIP));+ referrerprop.put("useragent", header.get(httpHeader.USER_AGENT));referrerprop.put("date", (new serverDate()).toShortString(false));if (sb.facilityDB != null) try {sb.facilityDB.update("backlinks", referer, referrerprop);} catch (IOException e) {}}@@ -126,6 +129,8 @@ public class index {prop.put("searchoptions_count-100", (count == 100) ? 1 : 0);prop.put("searchoptions_count-1000", (count == 1000) ? 1 : 0);prop.put("searchoptions_resource-global", ((global) ? 1 : 0));+ prop.put("searchoptions_resource-global-disabled", (global || clustersearch) ? 0 : 1);+ prop.put("searchoptions_resource-global-disabled_reason", (indexReceiveGranted) ? 0 : (indexDistributeGranted) ? 1 : 2);prop.put("searchoptions_resource-local", ((global) ? 0 : 1));prop.put("searchoptions_time-1", (time == 1) ? 1 : 0);prop.put("searchoptions_time-3", (time == 3) ? 1 : 0);diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.javaindex 0c153814e..7ab51afe7 100644--- a/source/de/anomic/plasma/plasmaSwitchboard.java+++ b/source/de/anomic/plasma/plasmaSwitchboard.java@@ -582,6 +582,10 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serpublic static final String PROXY_PREFETCH_DEPTH = "proxyPrefetchDepth";public static final String PROXY_CRAWL_ORDER = "proxyCrawlOrder";+ public static final String PROXY_INDEXING_REMOTE = "proxyIndexingRemote";+ public static final String PROXY_INDEXING_LOCAL_TEXT = "proxyIndexingLocalText";+ public static final String PROXY_INDEXING_LOCAL_MEDIA = "proxyIndexingLocalMedia";+public static final String PROXY_CACHE_SIZE = "proxyCacheSize";/*** <p><code>public static final String <strong>PROXY_CACHE_LAYOUT</strong> = "proxyCacheLayout"</code></p>@@ -632,6 +636,16 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serpublic static final String PROXY_CACHE_LAYOUT_HASH = "hash";public static final String PROXY_CACHE_MIGRATION = "proxyCacheMigration";+ //////////////////////////////////////////////////////////////////////////////////////////////+ // Cluster settings+ //////////////////////////////////////////////////////////////////////////////////////////////++ public static final String CLUSTER_MODE = "cluster.mode";+ public static final String CLUSTER_MODE_PUBLIC_CLUSTER = "publiccluster";+ public static final String CLUSTER_MODE_PRIVATE_CLUSTER = "privatecluster";+ public static final String CLUSTER_MODE_PUBLIC_PEER = "publicpeer";+ public static final String CLUSTER_PEERS_IPPORT = "cluster.peers.ipport";+//////////////////////////////////////////////////////////////////////////////////////////////// Miscellaneous settings//////////////////////////////////////////////////////////////////////////////////////////////@@ -1354,8 +1368,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serpublic boolean isPublicRobinson() {// robinson peers may be member of robinson clusters, which can be public or private// this does not check the robinson attribute, only the specific subtype of the cluster- String clustermode = getConfig("cluster.mode", "publicpeer");- return (clustermode.equals("publiccluster")) || (clustermode.equals("publicepeer"));+ String clustermode = getConfig(CLUSTER_MODE, CLUSTER_MODE_PUBLIC_PEER);+ return (clustermode.equals(CLUSTER_MODE_PUBLIC_CLUSTER)) || (clustermode.equals(CLUSTER_MODE_PUBLIC_PEER));}public boolean isInMyCluster(String peer) {@@ -1364,12 +1378,12 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser// or a ip:port String or simply a ip String// if this robinson mode does not define a cluster membership, false is returnedif (!isRobinsonMode()) return false;- String clustermode = getConfig("cluster.mode", "publicpeer");- if (clustermode.equals("privatecluster")) {+ String clustermode = getConfig(CLUSTER_MODE, CLUSTER_MODE_PUBLIC_PEER);+ if (clustermode.equals(CLUSTER_MODE_PRIVATE_CLUSTER)) {// check if we got the request from a peer in the private cluster- String network = getConfig("cluster.peers.ipport", "");+ String network = getConfig(CLUSTER_PEERS_IPPORT, "");return network.indexOf(peer) >= 0;- } else if (clustermode.equals("publiccluster")) {+ } else if (clustermode.equals(CLUSTER_MODE_PUBLIC_CLUSTER)) {// check if we got the request from a peer in the public clusterreturn this.clusterhashes.containsKey(peer);} else {@@ -1382,12 +1396,12 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser// if this robinson mode does not define a cluster membership, false is returnedif (seed == null) return false;if (!isRobinsonMode()) return false;- String clustermode = getConfig("cluster.mode", "publicpeer");- if (clustermode.equals("privatecluster")) {+ String clustermode = getConfig(CLUSTER_MODE, CLUSTER_MODE_PUBLIC_PEER);+ if (clustermode.equals(CLUSTER_MODE_PRIVATE_CLUSTER)) {// check if we got the request from a peer in the private cluster- String network = getConfig("cluster.peers.ipport", "");+ String network = getConfig(CLUSTER_PEERS_IPPORT, "");return network.indexOf(seed.getPublicAddress()) >= 0;- } else if (clustermode.equals("publiccluster")) {+ } else if (clustermode.equals(CLUSTER_MODE_PUBLIC_CLUSTER)) {// check if we got the request from a peer in the public clusterreturn this.clusterhashes.containsKey(seed.hash);} else {@@ -1463,13 +1477,13 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serif (this.defaultProxyProfile == null) {// generate new default entry for proxy crawlingthis.defaultProxyProfile = this.profiles.newEntry("proxy", "", ".*", ".*",- Integer.parseInt(getConfig("proxyPrefetchDepth", "0")),- Integer.parseInt(getConfig("proxyPrefetchDepth", "0")),+ Integer.parseInt(getConfig(PROXY_PREFETCH_DEPTH, "0")),+ Integer.parseInt(getConfig(PROXY_PREFETCH_DEPTH, "0")),60 * 24, -1, -1, false,- getConfigBool("proxyIndexingLocalText", true),- getConfigBool("proxyIndexingLocalMedia", true),+ getConfigBool(PROXY_INDEXING_LOCAL_TEXT, true),+ getConfigBool(PROXY_INDEXING_LOCAL_MEDIA, true),true, true,- getConfigBool("proxyIndexingRemote", false), true, true, true);+ getConfigBool(PROXY_INDEXING_REMOTE, false), true, true, true);}if (this.defaultRemoteProfile == null) {// generate new default entry for remote crawling@@ -2016,8 +2030,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serreturn false;}boolean robinsonPrivateCase = ((isRobinsonMode()) &&- (!getConfig("cluster.mode", "").equals("publiccluster")) &&- (!getConfig("cluster.mode", "").equals("privatecluster")));+ (!getConfig(CLUSTER_MODE, "").equals(CLUSTER_MODE_PUBLIC_CLUSTER)) &&+ (!getConfig(CLUSTER_MODE, "").equals(CLUSTER_MODE_PRIVATE_CLUSTER)));if ((robinsonPrivateCase) || ((coreCrawlJobSize() <= 20) && (limitCrawlTriggerJobSize() > 10))) {// it is not efficient if the core crawl job is empty and we have too much to do@@ -2027,7 +2041,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serfor (int i = 0; i < toshift; i++) {noticeURL.shift(plasmaCrawlNURL.STACK_TYPE_LIMIT, plasmaCrawlNURL.STACK_TYPE_CORE);}- log.logInfo("shifted " + toshift + " jobs from global crawl to local crawl (coreCrawlJobSize()=" + coreCrawlJobSize() + ", limitCrawlTriggerJobSize()=" + limitCrawlTriggerJobSize() + ", cluster.mode=" + getConfig("cluster.mode", "") + ", robinsonMode=" + ((isRobinsonMode()) ? "on" : "off"));+ log.logInfo("shifted " + toshift + " jobs from global crawl to local crawl (coreCrawlJobSize()=" + coreCrawlJobSize() + ", limitCrawlTriggerJobSize()=" + limitCrawlTriggerJobSize() + ", cluster.mode=" + getConfig(CLUSTER_MODE, "") + ", robinsonMode=" + ((isRobinsonMode()) ? "on" : "off"));if (robinsonPrivateCase) return false;}