* I2PTunnel & I2CP:
- Fix tunnel reduction/restore, hook in the GUI - Hook leaseset encryption into the GUI - Implement saves for all the new stuff - Add cancel button - Add b32 display for non-http servers - Prep for CONNECT - Fix error msg when connection goes away
This commit is contained in:
@ -442,8 +442,8 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
||||
long before = System.currentTimeMillis();
|
||||
_sessionListener.messageAvailable(I2PSessionImpl.this, msgId.intValue(), size.intValue());
|
||||
long duration = System.currentTimeMillis() - before;
|
||||
if ((duration > 100) && _log.shouldLog(Log.WARN))
|
||||
_log.warn("Message availability notification for " + msgId.intValue() + " took "
|
||||
if ((duration > 100) && _log.shouldLog(Log.INFO))
|
||||
_log.info("Message availability notification for " + msgId.intValue() + " took "
|
||||
+ duration + " to " + _sessionListener);
|
||||
} catch (Exception e) {
|
||||
_log.log(Log.CRIT, "Error notifying app of message availability", e);
|
||||
@ -678,6 +678,8 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
||||
_lastActivity = _context.clock().now();
|
||||
if (_isReduced) {
|
||||
_isReduced = false;
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn(getPrefix() + "Restoring original tunnel quantity");
|
||||
try {
|
||||
_producer.updateTunnels(this, 0);
|
||||
} catch (I2PSessionException ise) {
|
||||
|
@ -79,15 +79,16 @@ class RequestLeaseSetMessageHandler extends HandlerImpl {
|
||||
|
||||
leaseSet.setEncryptionKey(li.getPublicKey());
|
||||
leaseSet.setSigningKey(li.getSigningPublicKey());
|
||||
String sk = session.getOptions().getProperty("i2cp.sessionKey");
|
||||
if (sk != null) {
|
||||
boolean encrypt = Boolean.valueOf(session.getOptions().getProperty("i2cp.encryptLeaseset")).booleanValue();
|
||||
String sk = session.getOptions().getProperty("i2cp.leaseSetKey");
|
||||
if (encrypt && sk != null) {
|
||||
SessionKey key = new SessionKey();
|
||||
try {
|
||||
key.fromBase64(sk);
|
||||
leaseSet.encrypt(key);
|
||||
_context.keyRing().put(session.getMyDestination().calculateHash(), key);
|
||||
} catch (DataFormatException dfe) {
|
||||
_log.error("Bad session key: " + sk);
|
||||
_log.error("Bad leaseset key: " + sk);
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
@ -31,6 +31,7 @@ public class SessionIdleTimer implements SimpleTimer.TimedEvent {
|
||||
private boolean _shutdownEnabled;
|
||||
private long _shutdownTime;
|
||||
private long _minimumTime;
|
||||
private long _lastActive;
|
||||
|
||||
/**
|
||||
* reduce, shutdown, or both must be true
|
||||
@ -44,6 +45,7 @@ public class SessionIdleTimer implements SimpleTimer.TimedEvent {
|
||||
throw new IllegalArgumentException("At least one must be enabled");
|
||||
Properties props = session.getOptions();
|
||||
_minimumTime = Long.MAX_VALUE;
|
||||
_lastActive = 0;
|
||||
if (reduce) {
|
||||
_reduceQuantity = 1;
|
||||
String p = props.getProperty("i2cp.reduceQuantity");
|
||||
@ -83,10 +85,16 @@ public class SessionIdleTimer implements SimpleTimer.TimedEvent {
|
||||
long lastActivity = _session.lastActivity();
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Fire idle timer, last activity: " + DataHelper.formatDuration(now - lastActivity) + " ago ");
|
||||
long nextDelay = 0;
|
||||
if (_shutdownEnabled && now - lastActivity >= _shutdownTime) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Closing on idle " + _session);
|
||||
_session.destroySession();
|
||||
return;
|
||||
} else if (lastActivity <= _lastActive && !_shutdownEnabled) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Still idle, sleeping again " + _session);
|
||||
nextDelay = _reduceTime;
|
||||
} else if (_reduceEnabled && now - lastActivity >= _reduceTime) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Reducing quantity on idle " + _session);
|
||||
@ -96,11 +104,14 @@ public class SessionIdleTimer implements SimpleTimer.TimedEvent {
|
||||
_log.error("bork idle reduction " + ise);
|
||||
}
|
||||
_session.setReduced();
|
||||
_lastActive = lastActivity;
|
||||
if (_shutdownEnabled)
|
||||
SimpleScheduler.getInstance().addEvent(this, _shutdownTime - (now - lastActivity));
|
||||
// else sessionimpl must reschedule??
|
||||
nextDelay = _shutdownTime - (now - lastActivity);
|
||||
else
|
||||
nextDelay = _reduceTime;
|
||||
} else {
|
||||
SimpleScheduler.getInstance().addEvent(this, _minimumTime - (now - lastActivity));
|
||||
nextDelay = _minimumTime - (now - lastActivity);
|
||||
}
|
||||
SimpleScheduler.getInstance().addEvent(this, nextDelay);
|
||||
}
|
||||
}
|
||||
|
@ -34,8 +34,13 @@ public class I2CPMessageHandler {
|
||||
* message - if it is an unknown type or has improper formatting, etc.
|
||||
*/
|
||||
public static I2CPMessage readMessage(InputStream in) throws IOException, I2CPMessageException {
|
||||
int length = -1;
|
||||
try {
|
||||
length = (int) DataHelper.readLong(in, 4);
|
||||
} catch (DataFormatException dfe) {
|
||||
throw new IOException("Connection closed");
|
||||
}
|
||||
try {
|
||||
int length = (int) DataHelper.readLong(in, 4);
|
||||
if (length < 0) throw new I2CPMessageException("Invalid message length specified");
|
||||
int type = (int) DataHelper.readLong(in, 1);
|
||||
I2CPMessage msg = createMessage(in, length, type);
|
||||
|
Reference in New Issue
Block a user