- Logging tweaks inspired by Android

- Disable reusing Deflater on Android
This commit is contained in:
zzz
2011-06-02 18:29:06 +00:00
parent 761ad38bcc
commit fe15db51d8
9 changed files with 44 additions and 8 deletions

View File

@@ -36,3 +36,5 @@ ant install
#to rebuild and reinstall to emulator:
ant reinstall
# Now click on the I2P icon on your phone!

View File

@@ -6,17 +6,27 @@ i2p.dir.pid=/data/data/net.i2p.router/files/tmp
prng.buffers=2
router.decayingBloomFilterM=20
stat.full=false
i2np.udp.maxConnections=30
#
# no I2CP
#
i2p.dummyClientFacade=true
# for now
#
##### Transport
#
#
# NTCP
#
#i2np.ntcp.enable=false
i2np.ntcp.maxConnections=8
#
# UDP crashes the JVM, don't know why
#
i2np.udp.enable=false
i2np.udp.maxConnections=12
#
# no COMM at all!!!
#i2p.vmCommSystem=true
#
# not on android
i2np.upnp.enable=false
routerconsole.geoip.enable=false

View File

@@ -32,6 +32,9 @@ public final class SHA256Generator {
_useGnu = useGnu;
}
/**
* @param context unused
*/
public SHA256Generator(I2PAppContext context) {
_digests = new LinkedBlockingQueue(32);
}

View File

@@ -15,7 +15,9 @@ import net.i2p.data.DataHelper;
*/
public class ReusableGZIPOutputStream extends ResettableGZIPOutputStream {
// Apache Harmony 5.0M13 Deflater doesn't work after reset()
private static final boolean ENABLE_CACHING = !System.getProperty("java.vendor").startsWith("Apache");
// Neither does Android
private static final boolean ENABLE_CACHING = !(System.getProperty("java.vendor").startsWith("Apache") ||
System.getProperty("java.vendor").contains("Android"));
private static final LinkedBlockingQueue<ReusableGZIPOutputStream> _available;
static {
if (ENABLE_CACHING)

View File

@@ -1,3 +1,12 @@
2011-06-02 zzz
* Android: Build fixes
* Crypto:
- HMAC Javadocs and cleanups
- HMAC Use SimpleByteCache
* ElGamalAESEngine: Fixups required after SessionKey enforcement
* Reseed: Give up on a seed after 90% of fetches fail
* SessionKey: Enforce data size and prevent reuse
2011-06-01 zzz
* Crypto:
- Use java.security.MessageDigest instead of bundled GNU SHA-256 code

View File

@@ -150,12 +150,15 @@ public class DatabaseStoreMessage extends I2NPMessageImpl {
int len = Hash.HASH_LENGTH + 1 + 4; // key+type+replyToken
if (_replyToken > 0)
len += 4 + Hash.HASH_LENGTH; // replyTunnel+replyGateway
if (_dbEntry.getType() == DatabaseEntry.KEY_TYPE_LEASESET) {
int type = _dbEntry.getType();
if (type == DatabaseEntry.KEY_TYPE_LEASESET) {
_byteCache = _dbEntry.toByteArray();
} else if (_dbEntry.getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO) {
} else if (type == DatabaseEntry.KEY_TYPE_ROUTERINFO) {
byte uncompressed[] = _dbEntry.toByteArray();
_byteCache = DataHelper.compress(uncompressed);
len += 2;
} else {
throw new IllegalStateException("Invalid key type " + type);
}
len += _byteCache.length;
return len;
@@ -166,7 +169,7 @@ public class DatabaseStoreMessage extends I2NPMessageImpl {
if (_dbEntry == null) throw new I2NPMessageException("Missing entry");
int type = _dbEntry.getType();
if (type != DatabaseEntry.KEY_TYPE_LEASESET && type != DatabaseEntry.KEY_TYPE_ROUTERINFO)
throw new I2NPMessageException("Invalid key type");
throw new I2NPMessageException("Invalid key type " + type);
// Use the hash of the DatabaseEntry
System.arraycopy(getKey().getData(), 0, out, curIndex, Hash.HASH_LENGTH);

View File

@@ -311,8 +311,11 @@ public class Router {
}
public RouterInfo getRouterInfo() { return _routerInfo; }
public void setRouterInfo(RouterInfo info) {
_routerInfo = info;
if (_log.shouldLog(Log.INFO))
_log.info("setRouterInfo() : " + info, new Exception("I did it"));
if (info != null)
_context.jobQueue().addJob(new PersistRouterInfoJob(_context));
}
@@ -614,6 +617,10 @@ public class Router {
}
}
// hard and ugly
if (System.getProperty("wrapper.version") != null)
_log.log(Log.CRIT, "Restarting with new router identity");
else
_log.log(Log.CRIT, "Shutting down because old router identity was invalid - restart I2P");
finalShutdown(EXIT_HARD_RESTART);
}

View File

@@ -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 = 15;
public final static long BUILD = 16;
/** for example "-test" */
public final static String EXTRA = "";

View File

@@ -65,7 +65,7 @@ public class PublishLocalRouterInfoJob extends JobImpl {
try {
getContext().netDb().publish(ri);
} catch (IllegalArgumentException iae) {
_log.log(Log.CRIT, "Error publishing our identity - corrupt?", iae);
_log.log(Log.CRIT, "Error publishing our identity - corrupt? Restart required", iae);
getContext().router().rebuildNewIdentity();
}
} catch (DataFormatException dfe) {