diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index a6204817e3..f2522cd4ed 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -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 = 8; + public final static long BUILD = 9; /** for example "-test" */ public final static String EXTRA = ""; diff --git a/router/java/src/net/i2p/router/transport/udp/EstablishmentManager.java b/router/java/src/net/i2p/router/transport/udp/EstablishmentManager.java index 330efbe2df..0f7cbe8304 100644 --- a/router/java/src/net/i2p/router/transport/udp/EstablishmentManager.java +++ b/router/java/src/net/i2p/router/transport/udp/EstablishmentManager.java @@ -778,12 +778,17 @@ class EstablishmentManager { _context.statManager().addRateData("udp.receiveIntroRelayResponse", state.getLifetime(), 0); int port = reader.getRelayResponseReader().readCharliePort(); if (_log.shouldLog(Log.INFO)) - _log.info("Received relay intro for " + state.getRemoteIdentity().calculateHash() + " - they are on " + _log.info("Received RelayResponse for " + state.getRemoteIdentity().calculateHash() + " - they are on " + addr.toString() + ":" + port + " (according to " + bob + ")"); RemoteHostId oldId = state.getRemoteHostId(); state.introduced(addr, ip, port); - _outboundStates.remove(oldId); - _outboundStates.put(state.getRemoteHostId(), state); + RemoteHostId newId = state.getRemoteHostId(); + // Swap out the RemoteHostId the state is indexed under + // TODO only if !oldId.equals(newId) ? synch? + OutboundEstablishState oldState = _outboundStates.remove(oldId); + _outboundStates.put(newId, state); + if (_log.shouldLog(Log.DEBUG)) + _log.debug("RR replaced " + oldId + " -> " + oldState + " with " + newId + " -> " + state); notifyActivity(); } @@ -1035,7 +1040,8 @@ class EstablishmentManager { synchronized (outboundState) { boolean expired = outboundState.getLifetime() > MAX_OB_ESTABLISH_TIME; switch (outboundState.getState()) { - case OB_STATE_UNKNOWN: + case OB_STATE_UNKNOWN: // fall thru + case OB_STATE_INTRODUCED: if (expired) processExpired(outboundState); else diff --git a/router/java/src/net/i2p/router/transport/udp/InboundEstablishState.java b/router/java/src/net/i2p/router/transport/udp/InboundEstablishState.java index f5a63f421c..add2ffa5a2 100644 --- a/router/java/src/net/i2p/router/transport/udp/InboundEstablishState.java +++ b/router/java/src/net/i2p/router/transport/udp/InboundEstablishState.java @@ -370,7 +370,7 @@ class InboundEstablishState { @Override public String toString() { StringBuilder buf = new StringBuilder(128); - buf.append(super.toString()); + buf.append("IES ").append(super.toString()); if (_receivedX != null) buf.append(" ReceivedX: ").append(Base64.encode(_receivedX, 0, 4)); if (_sentY != null) @@ -379,7 +379,7 @@ class InboundEstablishState { buf.append(" Bob: ").append(Addresses.toString(_bobIP, _bobPort)); buf.append(" RelayTag: ").append(_sentRelayTag); buf.append(" SignedOn: ").append(_sentSignedOnTime); - buf.append(" state: ").append(_currentState); + buf.append(' ').append(_currentState); return buf.toString(); } } diff --git a/router/java/src/net/i2p/router/transport/udp/OutboundEstablishState.java b/router/java/src/net/i2p/router/transport/udp/OutboundEstablishState.java index c40247bf19..2d3395cf58 100644 --- a/router/java/src/net/i2p/router/transport/udp/OutboundEstablishState.java +++ b/router/java/src/net/i2p/router/transport/udp/OutboundEstablishState.java @@ -79,7 +79,9 @@ class OutboundEstablishState { /** we have received a data packet */ OB_STATE_CONFIRMED_COMPLETELY, /** we need to have someone introduce us to the peer, but haven't received a RelayResponse yet */ - OB_STATE_PENDING_INTRO + OB_STATE_PENDING_INTRO, + /** RelayResponse received */ + OB_STATE_INTRODUCED } /** basic delay before backoff */ @@ -105,7 +107,6 @@ class OutboundEstablishState { _remotePeer = remotePeer; _introKey = introKey; _queuedMessages = new LinkedBlockingQueue(); - _currentState = OutboundState.OB_STATE_UNKNOWN; _establishBegin = ctx.clock().now(); _remoteAddress = addr; _introductionNonce = -1; @@ -116,6 +117,8 @@ class OutboundEstablishState { if (_log.shouldLog(Log.DEBUG)) _log.debug("new outbound establish to " + remotePeer.calculateHash() + ", with address: " + addr); _currentState = OutboundState.OB_STATE_PENDING_INTRO; + } else { + _currentState = OutboundState.OB_STATE_UNKNOWN; } } @@ -194,7 +197,10 @@ class OutboundEstablishState { + " SignedOn: " + _receivedSignedOnTime + "\nthis: " + this.toString()); - if ( (_currentState == OutboundState.OB_STATE_UNKNOWN) || (_currentState == OutboundState.OB_STATE_REQUEST_SENT) ) + if (_currentState == OutboundState.OB_STATE_UNKNOWN || + _currentState == OutboundState.OB_STATE_REQUEST_SENT || + _currentState == OutboundState.OB_STATE_INTRODUCED || + _currentState == OutboundState.OB_STATE_PENDING_INTRO) _currentState = OutboundState.OB_STATE_CREATED_RECEIVED; packetReceived(); } @@ -400,9 +406,11 @@ class OutboundEstablishState { _nextSend = _lastSend + delay; if (_log.shouldLog(Log.DEBUG)) _log.debug("Send confirm packets, nextSend in " + delay); - if ( (_currentState == OutboundState.OB_STATE_UNKNOWN) || - (_currentState == OutboundState.OB_STATE_REQUEST_SENT) || - (_currentState == OutboundState.OB_STATE_CREATED_RECEIVED) ) + if (_currentState == OutboundState.OB_STATE_UNKNOWN || + _currentState == OutboundState.OB_STATE_PENDING_INTRO || + _currentState == OutboundState.OB_STATE_INTRODUCED || + _currentState == OutboundState.OB_STATE_REQUEST_SENT || + _currentState == OutboundState.OB_STATE_CREATED_RECEIVED) _currentState = OutboundState.OB_STATE_CONFIRMED_PARTIALLY; } @@ -426,7 +434,8 @@ class OutboundEstablishState { _nextSend = _lastSend + delay; if (_log.shouldLog(Log.DEBUG)) _log.debug("Send a request packet, nextSend in " + delay); - if (_currentState == OutboundState.OB_STATE_UNKNOWN) + if (_currentState == OutboundState.OB_STATE_UNKNOWN || + _currentState == OutboundState.OB_STATE_INTRODUCED) _currentState = OutboundState.OB_STATE_REQUEST_SENT; } @@ -472,11 +481,7 @@ class OutboundEstablishState { if (_currentState != OutboundState.OB_STATE_PENDING_INTRO) return; // we've already successfully been introduced, so don't overwrite old settings _nextSend = _context.clock().now() + 500; // wait briefly for the hole punching - if (_currentState == OutboundState.OB_STATE_PENDING_INTRO) { - // OB_STATE_UNKNOWN will probe the EstablishmentManager to send a new - // session request to this newly known address - _currentState = OutboundState.OB_STATE_UNKNOWN; - } + _currentState = OutboundState.OB_STATE_INTRODUCED; _bobIP = bobIP; _bobPort = bobPort; _remoteHostId = new RemoteHostId(bobIP, bobPort); @@ -507,6 +512,6 @@ class OutboundEstablishState { /** @since 0.8.9 */ @Override public String toString() { - return "OES " + _remoteHostId; + return "OES " + _remoteHostId + ' ' + _currentState; } }