From 204e98db3ac8c0f4b5d696e904a14b3f27177f1e Mon Sep 17 00:00:00 2001 From: orbiter Date: Mon, 10 Oct 2011 01:10:49 +0000 Subject: [PATCH] added a protection against rwi flooding git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7993 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/yacy/transferRWI.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htroot/yacy/transferRWI.java b/htroot/yacy/transferRWI.java index 3ad19f7b7..475b69917 100644 --- a/htroot/yacy/transferRWI.java +++ b/htroot/yacy/transferRWI.java @@ -41,10 +41,10 @@ import net.yacy.kelondro.index.HandleSet; import net.yacy.kelondro.logging.Log; import net.yacy.kelondro.rwi.IndexCell; import net.yacy.kelondro.util.FileUtils; -import net.yacy.peers.Seed; import net.yacy.peers.EventChannel; -import net.yacy.peers.Protocol; import net.yacy.peers.Network; +import net.yacy.peers.Protocol; +import net.yacy.peers.Seed; import net.yacy.peers.dht.FlatWordPartitionScheme; import net.yacy.repository.Blacklist; import net.yacy.search.Switchboard; @@ -153,13 +153,16 @@ public final class transferRWI { int blocked = 0; int receivedURL = 0; final IndexCell cell = sb.indexSegments.termIndex(Segments.Process.DHTIN); + int count = 0; while (it.hasNext()) { serverCore.checkInterruption(); estring = it.next(); + count++; + if (count > 1000) break; // protection against flooding // check if RWI entry is well-formed p = estring.indexOf('{'); - if ((p < 0) || (estring.indexOf("x=") < 0) || !(estring.indexOf("[B@") < 0)) { + if (p < 0 || estring.indexOf("x=") < 0 || !(estring.indexOf("[B@") < 0)) { blocked++; continue; }