From 0a83510690baab02b17c9304c8faa9ab151f5cda Mon Sep 17 00:00:00 2001 From: zzz Date: Thu, 8 Sep 2011 14:20:19 +0000 Subject: [PATCH] * Blocklist: Include IP in shitlist reason --- history.txt | 9 ++++++++- .../src/net/i2p/router/RouterVersion.java | 2 +- .../router/tunnel/BloomFilterIVValidator.java | 20 ++++++++++++------- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/history.txt b/history.txt index 63faabcd8b..dd47b2809d 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,10 @@ +2011-09-08 zzz + * Blocklist: Include IP in shitlist reason + * Ministreaming: Drop old classes replaced by streaming + years ago. + * NTCP: Hopefully fix race NPE, thx devzero + * Tunnels: Limit Bloom filter size based on max memory + 2011-09-07 zzz * Console: Limit max displayed participating tunnels * JobQueue: Change queue from a Set to a TreeSet for more efficiency @@ -6,7 +13,7 @@ time List for space savings. 2011-09-06 zzz - * Console: Move configservice.jsp rendering code from + * Console: Move jobs.jsp rendering code from the router to the console * Crypto: Rework use of SHA256 for efficiency and to avoid clogging the Hash cache with one-time hashes, diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 7f4edb9752..31c35f8c3e 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 13; + public final static long BUILD = 14; /** for example "-test" */ public final static String EXTRA = ""; diff --git a/router/java/src/net/i2p/router/tunnel/BloomFilterIVValidator.java b/router/java/src/net/i2p/router/tunnel/BloomFilterIVValidator.java index 8cc8cee45d..c6383032cc 100644 --- a/router/java/src/net/i2p/router/tunnel/BloomFilterIVValidator.java +++ b/router/java/src/net/i2p/router/tunnel/BloomFilterIVValidator.java @@ -13,9 +13,9 @@ import net.i2p.util.DecayingHashSet; * */ public class BloomFilterIVValidator implements IVValidator { - private RouterContext _context; - private DecayingBloomFilter _filter; - private ByteCache _ivXorCache = ByteCache.getInstance(32, HopProcessor.IV_LENGTH); + private final RouterContext _context; + private final DecayingBloomFilter _filter; + private final ByteCache _ivXorCache = ByteCache.getInstance(32, HopProcessor.IV_LENGTH); /** * After 2*halflife, an entry is completely forgotten from the bloom filter. @@ -27,18 +27,24 @@ public class BloomFilterIVValidator implements IVValidator { private static final int MIN_SHARE_KBPS_TO_USE_BLOOM = 64; private static final int MIN_SHARE_KBPS_FOR_BIG_BLOOM = 512; private static final int MIN_SHARE_KBPS_FOR_HUGE_BLOOM = 1536; + private static final long MIN_MEM_TO_USE_BLOOM = 64*1024*1024l; + private static final long MIN_MEM_FOR_BIG_BLOOM = 128*1024*1024l; + private static final long MIN_MEM_FOR_HUGE_BLOOM = 256*1024*1024l; public BloomFilterIVValidator(RouterContext ctx, int KBps) { _context = ctx; - // Select the filter based on share bandwidth. + // Select the filter based on share bandwidth and memory. // Note that at rates above 512KB, we increase the filter size // to keep acceptable false positive rates. // See DBF, BloomSHA1, and KeySelector for details. - if (KBps < MIN_SHARE_KBPS_TO_USE_BLOOM) + long maxMemory = Runtime.getRuntime().maxMemory(); + if (maxMemory == Long.MAX_VALUE) + maxMemory = 96*1024*1024l; + if (KBps < MIN_SHARE_KBPS_TO_USE_BLOOM || maxMemory < MIN_MEM_TO_USE_BLOOM) _filter = new DecayingHashSet(ctx, HALFLIFE_MS, 16, "TunnelIVV"); // appx. 4MB max - else if (KBps >= MIN_SHARE_KBPS_FOR_HUGE_BLOOM) + else if (KBps >= MIN_SHARE_KBPS_FOR_HUGE_BLOOM && maxMemory >= MIN_MEM_FOR_HUGE_BLOOM) _filter = new DecayingBloomFilter(ctx, HALFLIFE_MS, 16, "TunnelIVV", 25); // 8MB fixed - else if (KBps >= MIN_SHARE_KBPS_FOR_BIG_BLOOM) + else if (KBps >= MIN_SHARE_KBPS_FOR_BIG_BLOOM && maxMemory >= MIN_MEM_FOR_BIG_BLOOM) _filter = new DecayingBloomFilter(ctx, HALFLIFE_MS, 16, "TunnelIVV", 24); // 4MB fixed else _filter = new DecayingBloomFilter(ctx, HALFLIFE_MS, 16, "TunnelIVV"); // 2MB fixed