I2CP: Prevent sending lookup or bw limit messages before handshake with router is complete

This commit is contained in:
zzz
2015-05-30 14:13:13 +00:00
parent 94824e4d2b
commit 4fdcb6ce29

View File

@ -1202,10 +1202,15 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2
if (rv != null) if (rv != null)
return rv; return rv;
} }
if (isClosed()) { synchronized (_stateLock) {
if (_log.shouldLog(Log.INFO)) // not before GOTDATE
_log.info("Session closed, cannot lookup " + h); if (_state == State.CLOSED ||
return null; _state == State.INIT ||
_state == State.OPENING) {
if (_log.shouldLog(Log.INFO))
_log.info("Session closed, cannot lookup " + h);
return null;
}
} }
LookupWaiter waiter; LookupWaiter waiter;
long nonce; long nonce;
@ -1341,8 +1346,16 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2
* @return null on failure * @return null on failure
*/ */
public int[] bandwidthLimits() throws I2PSessionException { public int[] bandwidthLimits() throws I2PSessionException {
if (isClosed()) synchronized (_stateLock) {
return null; // not before GOTDATE
if (_state == State.CLOSED ||
_state == State.INIT ||
_state == State.OPENING) {
if (_log.shouldLog(Log.INFO))
_log.info("Session closed, cannot get bw limits");
return null;
}
}
sendMessage(new GetBandwidthLimitsMessage()); sendMessage(new GetBandwidthLimitsMessage());
try { try {
synchronized (_bwReceivedLock) { synchronized (_bwReceivedLock) {