Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
patch for index-transfer DoS problem see http://www.yacy-forum.de/viewtopic.php?p=21627#21627 note that this function will make the index-transfer functionality void
orbiter82b2bc6932f0
diff --git a/htroot/yacy/transferRWI.java b/htroot/yacy/transferRWI.javaindex e7b879580..29f2788cc 100644--- a/htroot/yacy/transferRWI.java+++ b/htroot/yacy/transferRWI.java@@ -77,8 +77,10 @@ public final class transferRWI {final int wordc = Integer.parseInt(post.get("wordc", "")); // number of different wordsfinal int entryc = Integer.parseInt(post.get("entryc", "")); // number of entries in indexesbyte[] indexes = post.get("indexes", "").getBytes(); // the indexes, as list of word entries- final boolean granted = sb.getConfig("allowReceiveIndex", "false").equals("true");+ boolean granted = sb.getConfig("allowReceiveIndex", "false").equals("true");+ if (sb.wordIndex.kSize() > 1000) granted = false; // don't accept more words if there are too many words to flush+// response valuesString result = "";StringBuffer unknownURLs = new StringBuffer();diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.javaindex ad972c37b..7afa347b2 100644--- a/source/de/anomic/yacy/yacyClient.java+++ b/source/de/anomic/yacy/yacyClient.java@@ -897,7 +897,11 @@ public final class yacyClient {if (in == null) { return "no_connection_1"; }String result = (String) in.get("result");if (result == null) { return "no_result_1"; }- if (!(result.equals("ok"))) return result;+ if (!(result.equals("ok"))) {+ targetSeed.setFlagAcceptRemoteIndex(false);+ yacyCore.seedDB.update(targetSeed.hash, targetSeed);+ return result;+ }// in now contains a list of unknown hashesfinal String uhss = (String) in.get("unknownURL");@@ -920,7 +924,11 @@ public final class yacyClient {if (in == null) { return "no_connection_2"; }result = (String) in.get("result");if (result == null) { return "no_result_2"; }- if (!(result.equals("ok"))) { return result; }+ if (!(result.equals("ok"))) {+ targetSeed.setFlagAcceptRemoteIndex(false);+ yacyCore.seedDB.update(targetSeed.hash, targetSeed);+ return result;+ }// int doubleentries = Integer.parseInt((String) in.get("double"));// System.out.println("DEBUG tansferIndex: transferred " + uhs.length + " URL's, double=" + doubleentries);diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.javaindex 90731c04a..e4abb25d0 100644--- a/source/de/anomic/yacy/yacySeedDB.java+++ b/source/de/anomic/yacy/yacySeedDB.java@@ -478,6 +478,22 @@ public final class yacySeedDB {return seed;}+ public void update(String hash, yacySeed seed) {+ if ((mySeed != null) && (hash.equals(mySeed.hash))) {+ mySeed = seed;+ return;+ }++ yacySeed s = get(hash, seedActiveDB);+ if (s != null) try { seedActiveDB.set(hash, seed.getMap()); return;} catch (IOException e) {}++ s = get(hash, seedPassiveDB);+ if (s != null) try { seedPassiveDB.set(hash, seed.getMap()); return;} catch (IOException e) {}++ s = get(hash, seedPotentialDB);+ if (s != null) try { seedPotentialDB.set(hash, seed.getMap()); return;} catch (IOException e) {}+ }+public yacySeed lookupByName(String peerName) {// reads a seed by searching by name