From 33a00efd82ea5b22a99e7eb970f9dd6bd9aae263 Mon Sep 17 00:00:00 2001 From: zzz Date: Mon, 30 Jul 2012 22:39:47 +0000 Subject: [PATCH] * RoutingKeyGenerator: Cleanups (ticket #672) --- .../src/net/i2p/data/RoutingKeyGenerator.java | 19 ++++++++------- history.txt | 24 +++++++++++++++++++ .../src/net/i2p/router/RouterVersion.java | 2 +- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/core/java/src/net/i2p/data/RoutingKeyGenerator.java b/core/java/src/net/i2p/data/RoutingKeyGenerator.java index b5bbc02a1c..08e8ee66d5 100644 --- a/core/java/src/net/i2p/data/RoutingKeyGenerator.java +++ b/core/java/src/net/i2p/data/RoutingKeyGenerator.java @@ -57,7 +57,9 @@ public class RoutingKeyGenerator { private volatile long _lastChanged; private final static Calendar _cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT")); - private final static SimpleDateFormat _fmt = new SimpleDateFormat("yyyyMMdd"); + private static final String FORMAT = "yyyyMMdd"; + private static final int LENGTH = FORMAT.length(); + private final static SimpleDateFormat _fmt = new SimpleDateFormat(FORMAT); public byte[] getModData() { return _currentModData; @@ -74,9 +76,7 @@ public class RoutingKeyGenerator { * @return true if changed */ public synchronized boolean generateDateBasedModData() { - Date today = null; long now = _context.clock().now(); - synchronized (_cal) { _cal.setTime(new Date(now)); _cal.set(Calendar.YEAR, _cal.get(Calendar.YEAR)); // gcj <= 4.0 workaround _cal.set(Calendar.DAY_OF_YEAR, _cal.get(Calendar.DAY_OF_YEAR)); // gcj <= 4.0 workaround @@ -84,12 +84,13 @@ public class RoutingKeyGenerator { _cal.set(Calendar.MINUTE, 0); _cal.set(Calendar.SECOND, 0); _cal.set(Calendar.MILLISECOND, 0); - today = _cal.getTime(); - } + Date today = _cal.getTime(); String modVal = _fmt.format(today); - byte[] mod = new byte[modVal.length()]; - for (int i = 0; i < modVal.length(); i++) + if (modVal.length() != LENGTH) + throw new IllegalStateException(); + byte[] mod = new byte[LENGTH]; + for (int i = 0; i < LENGTH; i++) mod[i] = (byte)(modVal.charAt(i) & 0xFF); boolean changed = !DataHelper.eq(_currentModData, mod); if (changed) { @@ -112,9 +113,9 @@ public class RoutingKeyGenerator { */ public Hash getRoutingKey(Hash origKey) { if (origKey == null) throw new IllegalArgumentException("Original key is null"); - byte modVal[] = new byte[Hash.HASH_LENGTH + _currentModData.length]; + byte modVal[] = new byte[Hash.HASH_LENGTH + LENGTH]; System.arraycopy(origKey.getData(), 0, modVal, 0, Hash.HASH_LENGTH); - System.arraycopy(_currentModData, 0, modVal, Hash.HASH_LENGTH, _currentModData.length); + System.arraycopy(_currentModData, 0, modVal, Hash.HASH_LENGTH, LENGTH); return SHA256Generator.getInstance().calculateHash(modVal); } diff --git a/history.txt b/history.txt index 76794f1cc6..a8663bba12 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,27 @@ +2012-07-30 zzz + * build.xml: Move more default properties to build.properties + * DecayingBloomFilter, DecayingHashSet, xlattice filters: + - Move from core to router + - Comment out tests + * ElGamal/AES/SessionTag: + - Increase TX expire from 10 to 12 min, while keeping RX expire at 15 min. + 3 minutes should be plenty of clock skew + delay. + - Move tags-to-send and low-threshold values to be per-SKM + - New session config options crypto.tagsToSend and crypto.lowTagThreshold + - Prep for per-packet override of tags and thresholds + - Cleanups and Javadocs + * GarlicMessageBuilder: + - Put data clove last to speed acks and leaseset store on far end + * I2PTunnel: Add some defaults for the new session config options + * OCMOSJ: + - Don't bundle LeaseSet just because we're requesting an ACK + - Changed session config option shouldBundleReplyInfo to default to true + and be used to disable bundling altogether when set to false. + Was previously an undocumented option to force bundling with a certain probability. + - Don't send tags unless we've already generated a reply token (race) + - Cleanups and Javadocs + * RoutingKeyGenerator: Cleanups (ticket #672) + * 2012-07-30 0.9.1 released 2012-07-28 str4d diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index a411b00998..87e5bffca0 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 = 0; + public final static long BUILD = 1; /** for example "-test" */ public final static String EXTRA = "";