Skip to content

Commit

Permalink
patch for index-transfer DoS problem
Browse files Browse the repository at this point in the history
see http://www.yacy-forum.de/viewtopic.php?p=21627#21627
note that this function will make the index-transfer functionality void

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2114 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed May 18, 2006
1 parent df7e1d9 commit 82b2bc6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
4 changes: 3 additions & 1 deletion htroot/yacy/transferRWI.java
Expand Up @@ -77,8 +77,10 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
final int wordc = Integer.parseInt(post.get("wordc", "")); // number of different words
final int entryc = Integer.parseInt(post.get("entryc", "")); // number of entries in indexes
byte[] 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 values
String result = "";
StringBuffer unknownURLs = new StringBuffer();
Expand Down
12 changes: 10 additions & 2 deletions source/de/anomic/yacy/yacyClient.java
Expand Up @@ -897,7 +897,11 @@ public static String transferIndex(yacySeed targetSeed, plasmaWordIndexEntryCont
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 hashes
final String uhss = (String) in.get("unknownURL");
Expand All @@ -920,7 +924,11 @@ public static String transferIndex(yacySeed targetSeed, plasmaWordIndexEntryCont
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);

Expand Down
16 changes: 16 additions & 0 deletions source/de/anomic/yacy/yacySeedDB.java
Expand Up @@ -478,6 +478,22 @@ public yacySeed get(String hash) {
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

Expand Down

0 comments on commit 82b2bc6

Please sign in to comment.