mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
*) make DHT DoS check configurable (requested by KoH)
- check can be disabled via property indexDistribution.dhtReceiptLimitEnabled - upper bound can be configured via indexDistribution.dhtReceiptLimit git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2234 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
parent
650c7e9e55
commit
b20496e42b
|
@ -78,6 +78,8 @@ public final class transferRWI {
|
||||||
final int entryc = Integer.parseInt(post.get("entryc", "")); // number of entries in indexes
|
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
|
byte[] indexes = post.get("indexes", "").getBytes(); // the indexes, as list of word entries
|
||||||
boolean granted = sb.getConfig("allowReceiveIndex", "false").equals("true");
|
boolean granted = sb.getConfig("allowReceiveIndex", "false").equals("true");
|
||||||
|
boolean checkLimit = sb.getConfigBool("indexDistribution.dhtReceiptLimitEnabled", true);
|
||||||
|
final long cachelimit = sb.getConfigLong("indexDistribution.dhtReceiptLimit", 1000);
|
||||||
final yacySeed otherPeer = yacyCore.seedDB.get(iam);
|
final yacySeed otherPeer = yacyCore.seedDB.get(iam);
|
||||||
final String otherPeerName = iam + ":" + ((otherPeer == null) ? "NULL" : (otherPeer.getName() + "/" + otherPeer.getVersion()));
|
final String otherPeerName = iam + ":" + ((otherPeer == null) ? "NULL" : (otherPeer.getName() + "/" + otherPeer.getVersion()));
|
||||||
|
|
||||||
|
@ -91,7 +93,7 @@ public final class transferRWI {
|
||||||
sb.getLog().logInfo("Rejecting RWIs from peer " + otherPeerName + ". Not granted.");
|
sb.getLog().logInfo("Rejecting RWIs from peer " + otherPeerName + ". Not granted.");
|
||||||
result = "not_granted";
|
result = "not_granted";
|
||||||
pause = 0;
|
pause = 0;
|
||||||
} else if (sb.wordIndex.kSize() > 1000) {
|
} else if (checkLimit && sb.wordIndex.kSize() > cachelimit) {
|
||||||
// we are too busy to receive indexes
|
// we are too busy to receive indexes
|
||||||
sb.getLog().logInfo("Rejecting RWIs from peer " + otherPeerName + ". We are too busy (buffersize=" + sb.wordIndex.kSize() + ").");
|
sb.getLog().logInfo("Rejecting RWIs from peer " + otherPeerName + ". We are too busy (buffersize=" + sb.wordIndex.kSize() + ").");
|
||||||
granted = false; // don't accept more words if there are too many words to flush
|
granted = false; // don't accept more words if there are too many words to flush
|
||||||
|
@ -171,8 +173,11 @@ public final class transferRWI {
|
||||||
sb.getLog().logInfo("Received " + received + " Words [" + wordhashes[0] + " .. " + wordhashes[received - 1] + "]/" + avdist + " from " + otherPeerName + ", processed in " + (System.currentTimeMillis() - startProcess) + " milliseconds, requesting " + unknownURL.size() + " URLs");
|
sb.getLog().logInfo("Received " + received + " Words [" + wordhashes[0] + " .. " + wordhashes[received - 1] + "]/" + avdist + " from " + otherPeerName + ", processed in " + (System.currentTimeMillis() - startProcess) + " milliseconds, requesting " + unknownURL.size() + " URLs");
|
||||||
}
|
}
|
||||||
result = "ok";
|
result = "ok";
|
||||||
|
|
||||||
|
if (checkLimit) {
|
||||||
pause = (sb.wordIndex.kSize() < 500) ? 0 : 60 * sb.wordIndex.kSize(); // estimation of necessary pause time
|
pause = (sb.wordIndex.kSize() < 500) ? 0 : 60 * sb.wordIndex.kSize(); // estimation of necessary pause time
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
prop.put("unknownURL", unknownURLs.toString());
|
prop.put("unknownURL", unknownURLs.toString());
|
||||||
prop.put("result", result);
|
prop.put("result", result);
|
||||||
|
|
|
@ -258,13 +258,14 @@ public class plasmaDHTTransfer extends Thread {
|
||||||
if (transferRWIResult != null && transferRWIResult.containsKey("pause")) {
|
if (transferRWIResult != null && transferRWIResult.containsKey("pause")) {
|
||||||
String pauseStr = (String) transferRWIResult.get("pause");
|
String pauseStr = (String) transferRWIResult.get("pause");
|
||||||
try { pause = Integer.valueOf(pauseStr).intValue(); } catch (NumberFormatException numEx){}
|
try { pause = Integer.valueOf(pauseStr).intValue(); } catch (NumberFormatException numEx){}
|
||||||
if (pause <= 0) pause = 60000;
|
if (pause < 0) pause = 60000;
|
||||||
else if (pause > 1800000) pause = 1800000;
|
else if (pause > 1800000) pause = 1800000;
|
||||||
}
|
}
|
||||||
return pause;
|
return pause;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pause(long sleepTime) throws InterruptedException {
|
private void pause(long sleepTime) throws InterruptedException {
|
||||||
|
if (sleepTime == 0) return;
|
||||||
long sleepCounter = sleepTime / 1000;
|
long sleepCounter = sleepTime / 1000;
|
||||||
long sleepRest = sleepTime % 1000;
|
long sleepRest = sleepTime % 1000;
|
||||||
while (!this.isAborted() && sleepCounter > 0) {
|
while (!this.isAborted() && sleepCounter > 0) {
|
||||||
|
|
|
@ -649,6 +649,14 @@ indexDistribution.minChunkSize = 5
|
||||||
indexDistribution.maxChunkSize = 1000
|
indexDistribution.maxChunkSize = 1000
|
||||||
indexDistribution.startChunkSize = 50
|
indexDistribution.startChunkSize = 50
|
||||||
|
|
||||||
|
# defines if the peer should reject incoming index transfer
|
||||||
|
# request if a given limit is reached
|
||||||
|
indexDistribution.dhtReceiptLimitEnabled = false
|
||||||
|
|
||||||
|
# defines the word cache for DHT reaches this level
|
||||||
|
# the peer reports itself as busy
|
||||||
|
indexDistribution.dhtReceiptLimit = 1000
|
||||||
|
|
||||||
# Distribution of Citation-Reference (CR-) files
|
# Distribution of Citation-Reference (CR-) files
|
||||||
# The distribution is done in two steps:
|
# The distribution is done in two steps:
|
||||||
# first step to anonymize the records
|
# first step to anonymize the records
|
||||||
|
|
Loading…
Reference in New Issue
Block a user