propagate from branch 'i2p.i2p.zzz.test' (head 5474e1a513fc8144a3d855e9c85d8b235f7f9816)

to branch 'i2p.i2p' (head 5932d3923108572b22a8a7a600f0f9e62ecac347)
This commit is contained in:
zzz
2012-07-30 22:29:02 +00:00
305 changed files with 54690 additions and 44647 deletions

View File

@ -16,7 +16,7 @@ package net.i2p;
public class CoreVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = "0.9";
public final static String VERSION = "0.9.1";
public static void main(String args[]) {
System.out.println("I2P Core version: " + VERSION);

View File

@ -110,10 +110,10 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
private final Object _leaseSetWait = new Object();
/** whether the session connection has already been closed (or not yet opened) */
protected boolean _closed;
protected volatile boolean _closed;
/** whether the session connection is in the process of being closed */
protected boolean _closing;
protected volatile boolean _closing;
/** have we received the current date from the router yet? */
private boolean _dateReceived;
@ -121,7 +121,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
private final Object _dateReceivedLock = new Object();
/** whether the session connection is in the process of being opened */
protected boolean _opening;
protected volatile boolean _opening;
/** monitor for waiting until opened */
private final Object _openingWait = new Object();

View File

@ -61,7 +61,8 @@ public class ElGamalAESEngine {
}
/**
* Decrypt the message using the given private key using tags from the default key manager.
* Decrypt the message using the given private key using tags from the default key manager,
* which is the router's key manager. Use extreme care if you aren't the router.
*
* @deprecated specify the key manager!
*/
@ -75,6 +76,10 @@ public class ElGamalAESEngine {
* This works according to the
* ElGamal+AES algorithm in the data structure spec.
*
* Warning - use the correct SessionKeyManager. Clients should instantiate their own.
* Clients using I2PAppContext.sessionKeyManager() may be correlated with the router,
* unless you are careful to use different keys.
*
* @return decrypted data or null on failure
*/
public byte[] decrypt(byte data[], PrivateKey targetPrivateKey, SessionKeyManager keyManager) throws DataFormatException {

View File

@ -59,7 +59,8 @@ public class SessionKeyManager {
* Associate a new session key with the specified target. Metrics to determine
* when to expire that key begin with this call.
*
* @deprecated racy
* Racy if called after getCurrentKey() to check for a current session;
* use getCurrentOrNewKey() in that case.
*/
public void createSession(PublicKey target, SessionKey key) { // nop
}
@ -67,7 +68,8 @@ public class SessionKeyManager {
/**
* Generate a new session key and associate it with the specified target.
*
* @deprecated racy
* Racy if called after getCurrentKey() to check for a current session;
* use getCurrentOrNewKey() in that case.
*/
public SessionKey createSession(PublicKey target) {
SessionKey key = KeyGenerator.getInstance().generateSessionKey();

View File

@ -303,7 +303,8 @@ public class TransientSessionKeyManager extends SessionKeyManager {
* Associate a new session key with the specified target. Metrics to determine
* when to expire that key begin with this call.
*
* @deprecated racy
* Racy if called after getCurrentKey() to check for a current session;
* use getCurrentOrNewKey() in that case.
*/
@Override
public void createSession(PublicKey target, SessionKey key) {

View File

@ -458,19 +458,32 @@ public class EepGet {
}
public void stopFetching() { _keepFetching = false; }
/**
* Blocking fetch, returning true if the URL was retrieved, false if all retries failed
* Blocking fetch, returning true if the URL was retrieved, false if all retries failed.
*
* Header timeout default 45 sec, total timeout default none, inactivity timeout default 60 sec.
*/
public boolean fetch() { return fetch(_fetchHeaderTimeout); }
/**
* Blocking fetch, timing out individual attempts if the HTTP response headers
* don't come back in the time given. If the timeout is zero or less, this will
* wait indefinitely.
*
* Total timeout default none, inactivity timeout default 60 sec.
*/
public boolean fetch(long fetchHeaderTimeout) {
return fetch(fetchHeaderTimeout, -1, -1);
}
/**
* Blocking fetch.
*
* @param fetchHeaderTimeout <= 0 for none (proxy will timeout if none, none isn't recommended if no proxy)
* @param totalTimeout <= 0 for default none
* @param inactivityTimeout <= 0 for default 60 sec
*/
public boolean fetch(long fetchHeaderTimeout, long totalTimeout, long inactivityTimeout) {
_fetchHeaderTimeout = fetchHeaderTimeout;
_fetchEndTime = (totalTimeout > 0 ? System.currentTimeMillis() + totalTimeout : -1);

View File

@ -9,12 +9,13 @@ import net.i2p.I2PAppContext;
*/
class Executor implements Runnable {
private final I2PAppContext _context;
private Log _log;
private final List _readyEvents;
private final Log _log;
private final List<SimpleTimer.TimedEvent> _readyEvents;
private final SimpleStore runn;
public Executor(I2PAppContext ctx, Log log, List events, SimpleStore x) {
public Executor(I2PAppContext ctx, Log log, List<SimpleTimer.TimedEvent> events, SimpleStore x) {
_context = ctx;
_log = log;
_readyEvents = events;
runn = x;
}
@ -26,7 +27,7 @@ class Executor implements Runnable {
if (_readyEvents.isEmpty())
try { _readyEvents.wait(); } catch (InterruptedException ie) {}
if (!_readyEvents.isEmpty())
evt = (SimpleTimer.TimedEvent)_readyEvents.remove(0);
evt = _readyEvents.remove(0);
}
if (evt != null) {
@ -34,21 +35,12 @@ class Executor implements Runnable {
try {
evt.timeReached();
} catch (Throwable t) {
log("Executing task " + evt + " exited unexpectedly, please report", t);
_log.error("Executing task " + evt + " exited unexpectedly, please report", t);
}
long time = _context.clock().now() - before;
// FIXME _log won't be non-null unless we already had a CRIT
if ( (time > 1000) && (_log != null) && (_log.shouldLog(Log.WARN)) )
if ( (time > 1000) && (_log.shouldLog(Log.WARN)) )
_log.warn("wtf, event execution took " + time + ": " + evt);
}
}
}
private void log(String msg, Throwable t) {
synchronized (this) {
if (_log == null)
_log = I2PAppContext.getGlobalContext().logManager().getLog(SimpleTimer.class);
}
_log.log(Log.CRIT, msg, t);
}
}

View File

@ -44,7 +44,7 @@ public class LookaheadInputStream extends FilterInputStream {
Arrays.fill(_footerLookahead, (byte)0x00);
int footerRead = 0;
while (footerRead < _footerLookahead.length) {
int read = in.read(_footerLookahead);
int read = in.read(_footerLookahead, footerRead, _footerLookahead.length - footerRead);
if (read == -1) throw new IOException("EOF reading the footer lookahead");
footerRead += read;
}

View File

@ -90,6 +90,8 @@ public class SSLEepGet extends EepGet {
/** may be null if init failed */
private SavingTrustManager _stm;
private static final boolean _isAndroid = System.getProperty("java.vendor").contains("Android");
/**
* A new SSLEepGet with a new SSLState
*/
@ -192,12 +194,23 @@ public class SSLEepGet extends EepGet {
String override = System.getProperty("javax.net.ssl.keyStore");
if (override != null)
success = loadCerts(new File(override), ks);
if (!success)
success = loadCerts(new File(System.getProperty("java.home"), "lib/security/jssecacerts"), ks);
if (!success)
success = loadCerts(new File(System.getProperty("java.home"), "lib/security/cacerts"), ks);
if (!success) {
if (_isAndroid) {
// thru API 13. As of API 14 (ICS), the file is gone, but
// ks.load(null, pw) will bring in the default certs?
success = loadCerts(new File(System.getProperty("java.home"), "etc/security/cacerts.bks"), ks);
} else {
success = loadCerts(new File(System.getProperty("java.home"), "lib/security/jssecacerts"), ks);
if (!success)
success = loadCerts(new File(System.getProperty("java.home"), "lib/security/cacerts"), ks);
}
}
if (!success) {
try {
// must be initted
ks.load(null, "changeit".toCharArray());
} catch (Exception e) {}
_log.error("All key store loads failed, will only load local certificates");
} else if (_log.shouldLog(Log.INFO)) {
int count = 0;