From 0174df12afc53bacd887f8c76f7b60f07c0d8320 Mon Sep 17 00:00:00 2001 From: orbiter Date: Wed, 27 Jul 2005 22:52:29 +0000 Subject: [PATCH] deny of global search in case DHT is switched off git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@445 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/IndexControl_p.html | 43 +++++++++++++++++++++++--------------- htroot/IndexControl_p.java | 5 +---- htroot/index.java | 16 +++++++++----- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/htroot/IndexControl_p.html b/htroot/IndexControl_p.html index 33c6f8055..7618f0548 100644 --- a/htroot/IndexControl_p.html +++ b/htroot/IndexControl_p.html @@ -9,9 +9,9 @@

Index Administration

+

The local index currently consists of (at least) #[wcount]# reverse word indexes and #[ucount]# URL references
- @@ -50,34 +50,43 @@ The local index currently consists of (at least) #[wcount]# reverse word indexes -
Word

+

- +

+DHT Transmission control:
+The transmission is necessary for the functionality of global search on other peers. +If you switch off distribution or receipt of RWIs you will be banned from global search. +

- - + + + -
Index Distribution: -This enables automated, DHT-ruled Index Transmission to other peers. This is currently only activated for junior peers.This enables automated, DHT-ruled Index Transmission to other peers. +
- - - + - + + + - - + + + + + - + + + +
Index Receive: -Accept remote Index Transmissions. This works only if you are a senior peer. The DHT-rules do not work without this function.Accept remote Index Transmissions. This works only if you are a senior peer. +The DHT-rules do not work without this function.
   -If checked, your peer silently ignores transmitted URLs that match your blacklist
  If checked, your peer silently ignores transmitted URLs that match your blacklist
Changes will take effect immediately
-

+ #[result]# diff --git a/htroot/IndexControl_p.java b/htroot/IndexControl_p.java index 9ed16be34..c86971668 100644 --- a/htroot/IndexControl_p.java +++ b/htroot/IndexControl_p.java @@ -105,13 +105,10 @@ public class IndexControl_p { boolean delurlref = post.containsKey("delurlref"); //System.out.println("DEBUG CHECK: " + ((delurl) ? "delurl" : "") + " " + ((delurlref) ? "delurlref" : "")); - if (post.containsKey("setIndexDistribute")) { + if (post.containsKey("setIndexTransmission")) { boolean allowDistributeIndex = ((String) post.get("indexDistribute", "")).equals("on"); switchboard.setConfig("allowDistributeIndex", (allowDistributeIndex) ? "true" : "false"); if (allowDistributeIndex) switchboard.indexDistribution.enable(); else switchboard.indexDistribution.disable(); - } - - if (post.containsKey("setIndexReceive")) { boolean allowReceiveIndex = ((String) post.get("indexReceive", "")).equals("on"); switchboard.setConfig("allowReceiveIndex", (allowReceiveIndex) ? "true" : "false"); yacyCore.seedDB.mySeed.setFlagAcceptRemoteIndex(allowReceiveIndex); diff --git a/htroot/index.java b/htroot/index.java index d00a1e3c2..05ba54593 100644 --- a/htroot/index.java +++ b/htroot/index.java @@ -66,7 +66,12 @@ public class index { public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) { plasmaSwitchboard sb = (plasmaSwitchboard) env; - // case if no values are requested + boolean global = (post == null) ? true : ((String) post.get("resource", "global")).equals("global"); + boolean indexDistributeGranted = sb.getConfig("allowDistributeIndex", "true").equals("true"); + boolean indexReceiveGranted = sb.getConfig("allowReceiveIndex", "true").equals("true"); + if ((!indexDistributeGranted) || (!indexReceiveGranted)) global = false; + + // case if no values are requested if ((post == null) || (env == null)) { // save referrer @@ -99,8 +104,8 @@ public class index { prop.put("count-1000", 0); prop.put("order-quality", 0); prop.put("order-date", 0); - prop.put("resource-global", 0); - prop.put("resource-local", 0); + prop.put("resource-global", ((global) ? 1 : 0)); + prop.put("resource-local", ((global) ? 0 : 1)); prop.put("time-1", 0); prop.put("time-3", 0); prop.put("time-10", 1); @@ -123,7 +128,8 @@ public class index { // prepare search order String order = (String) post.get("order", ""); int count = Integer.parseInt((String) post.get("count", "10")); - boolean global = ((String) post.get("resource", "global")).equals("global"); + + long searchtime = 1000 * Long.parseLong((String) post.get("time", "1")); boolean yacyonline = ((yacyCore.seedDB != null) && (yacyCore.seedDB.mySeed != null) && @@ -227,7 +233,7 @@ public class index { prop.put("order-quality", ((order.equals("Quality-Date")) ? 1 : 0)); prop.put("order-date", ((order.equals("Date-Quality")) ? 1 : 0)); prop.put("resource-global", ((global) ? 1 : 0)); - prop.put("resource-local", ((!global) ? 1 : 0)); + prop.put("resource-local", ((global) ? 0 : 1)); prop.put("time-1", ((searchtime == 1000) ? 1 : 0)); prop.put("time-3", ((searchtime == 3000) ? 1 : 0)); prop.put("time-10", ((searchtime == 10000) ? 1 : 0));