Streaming: Fix exception after sig verify fail

log tweaks
This commit is contained in:
zzz
2019-02-07 18:14:18 +00:00
parent 636016d107
commit 7544d0a590
4 changed files with 10 additions and 9 deletions

View File

@@ -913,11 +913,11 @@ class Connection {
/**
* @param id 0 to 0xffffffff
* @throws RuntimeException if already set to nonzero
* @throws IllegalStateException if already set to nonzero
*/
public void setSendStreamId(long id) {
if (!_sendStreamId.compareAndSet(0, id))
throw new RuntimeException("Send stream ID already set [" + _sendStreamId + ", " + id + "]");
throw new IllegalStateException("Send stream ID already set [" + _sendStreamId + ", " + id + "]");
}
/**
@@ -928,11 +928,11 @@ class Connection {
/**
* @param id 0 to 0xffffffff
* @throws RuntimeException if already set to nonzero
* @throws IllegalStateException if already set to nonzero
*/
public void setReceiveStreamId(long id) {
if (!_receiveStreamId.compareAndSet(0, id))
throw new RuntimeException("Receive stream ID already set [" + _receiveStreamId + ", " + id + "]");
throw new IllegalStateException("Receive stream ID already set [" + _receiveStreamId + ", " + id + "]");
synchronized (_connectLock) { _connectLock.notifyAll(); }
}

View File

@@ -572,8 +572,8 @@ class ConnectionPacketHandler {
boolean ok = packet.verifySignature(_context, spk, ba.getData());
_cache.release(ba);
if (!ok) {
if (_log.shouldLog(Log.ERROR))
_log.error("Received unsigned / forged RST on " + con);
if (_log.shouldWarn())
_log.warn("Received unsigned / forged RST on " + con);
return;
} else {
if (_log.shouldWarn())

View File

@@ -204,7 +204,8 @@ class PacketHandler {
} catch (I2PException ie) {
if (_log.shouldWarn())
_log.warn("Sig verify fail for " + con + "/" + oldId + ": " + packet, ie);
con.setSendStreamId(oldId);
// TODO we can't set the stream ID back to 0, throws ISE
//con.setSendStreamId(oldId);
if (packet.isFlagSet(Packet.FLAG_SYNCHRONIZE)) {
// send a reset, it's a known con, so it's unlikely to be spoofed
// don't bother to send reset if it's just a CLOSE

View File

@@ -71,10 +71,10 @@ class PacketLocal extends Packet implements MessageOutputStream.WriteStatus {
* @since 0.9.39 moved from super
*/
public void setOptionalFrom() {
setFlag(FLAG_FROM_INCLUDED, true);
setFlag(FLAG_FROM_INCLUDED);
_optionFrom = _session.getMyDestination();
if (_session.isOffline()) {
setFlag(FLAG_SIGNATURE_OFFLINE, true);
setFlag(FLAG_SIGNATURE_OFFLINE);
_transientExpires = _session.getOfflineExpiration();
_transientSigningPublicKey = _session.getTransientSigningPublicKey();
_offlineSignature = _session.getOfflineSignature();