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

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2114 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent df7e1d9df3
commit 82b2bc6932

@ -77,8 +77,10 @@ public final class transferRWI {
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();

@ -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 hashes
final 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);

@ -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

Loading…
Cancel
Save