Author: nextgens
Date: 2008-07-22 16:52:25 +0000 (Tue, 22 Jul 2008)
New Revision: 21320
Modified:
trunk/freenet/src/freenet/node/NodeDispatcher.java
Log:
Implement the FOAF-attack-mitigation hack
Modified: trunk/freenet/src/freenet/node/NodeDispatcher.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeDispatcher.java 2008-07-22 16:10:35 UTC
(rev 21319)
+++ trunk/freenet/src/freenet/node/NodeDispatcher.java 2008-07-22 16:52:25 UTC
(rev 21320)
@@ -154,8 +154,20 @@
double newLoc = m.getDouble(DMT.LOCATION);
ShortBuffer buffer = ((ShortBuffer)
m.getObject(DMT.PEER_LOCATIONS));
double[] locs = Fields.bytesToDoubles(buffer.getData());
- source.updateLocation(newLoc, locs);
+ /**
+ * Do *NOT* remove the sanity check below!
+ * @see
http://archives.freenetproject.org/message/20080718.144240.359e16d3.en.html
+ */
+ if((OpennetManager.MAX_PEERS_FOR_SCALING < locs.length)
&& (source.isOpennet())) {
+ Logger.error(this, "We received "+locs.length+
" locations from "+source.toString()+"! That should *NOT* happen!");
+ return true;
+ } else {
+ // We are on darknet and we trust our peers OR
we are on opennet
+ // and the amount of locations sent to us seems
reasonable
+ source.updateLocation(newLoc, locs);
+ }
+
return true;
}