diff --git a/core/java/src/net/i2p/client/impl/I2PSessionImpl.java b/core/java/src/net/i2p/client/impl/I2PSessionImpl.java index 0be40f87f5..a0dbdcf55c 100644 --- a/core/java/src/net/i2p/client/impl/I2PSessionImpl.java +++ b/core/java/src/net/i2p/client/impl/I2PSessionImpl.java @@ -42,9 +42,11 @@ import net.i2p.data.LeaseSet; import net.i2p.data.PrivateKey; import net.i2p.data.SigningPrivateKey; import net.i2p.data.i2cp.DestLookupMessage; +import net.i2p.data.i2cp.DestReplyMessage; import net.i2p.data.i2cp.GetBandwidthLimitsMessage; import net.i2p.data.i2cp.GetDateMessage; import net.i2p.data.i2cp.HostLookupMessage; +import net.i2p.data.i2cp.HostReplyMessage; import net.i2p.data.i2cp.I2CPMessage; import net.i2p.data.i2cp.I2CPMessageReader; import net.i2p.data.i2cp.MessagePayloadMessage; @@ -900,7 +902,9 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2 SessionId id = message.sessionId(); SessionId currId = _sessionId; if (id == null || id.equals(currId) || - (currId == null && id != null && type == SessionStatusMessage.MESSAGE_TYPE)) { + (currId == null && id != null && type == SessionStatusMessage.MESSAGE_TYPE) || + ((id == null || id.getSessionId() == 65535) && + (type == HostReplyMessage.MESSAGE_TYPE || type == DestReplyMessage.MESSAGE_TYPE))) { // it's for us I2CPMessageHandler handler = _handlerMap.getHandler(type); if (handler != null) { diff --git a/history.txt b/history.txt index 6081f8b952..1a2bda8de0 100644 --- a/history.txt +++ b/history.txt @@ -1,4 +1,5 @@ 2015-06-19 zzz + * I2CP: Fix simple session lookups, broken in prop * I2PSocketEepGet: Do hostname lookups in-session for efficiency * Tunnels: Increase default max tunnels diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index fecba78d69..a6204817e3 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 = 7; + public final static long BUILD = 8; /** for example "-test" */ public final static String EXTRA = ""; diff --git a/router/java/src/net/i2p/router/client/ClientConnectionRunner.java b/router/java/src/net/i2p/router/client/ClientConnectionRunner.java index f804c36746..d94bb897b0 100644 --- a/router/java/src/net/i2p/router/client/ClientConnectionRunner.java +++ b/router/java/src/net/i2p/router/client/ClientConnectionRunner.java @@ -303,15 +303,15 @@ class ClientConnectionRunner { /** * Equivalent to getConfig().getDestination().calculateHash(); * will be null before session is established - * Not subsession aware. Returns random hash from the sessions. + * Not subsession aware. Returns primary session hash. * Don't use if you can help it. * * @return primary hash or null if not yet set */ public Hash getDestHash() { - for (Hash h : _sessions.keySet()) { - return h; - } + SessionConfig cfg = getPrimaryConfig(); + if (cfg != null) + return cfg.getDestination().calculateHash(); return null; } @@ -890,17 +890,17 @@ class ClientConnectionRunner { SessionParams sp = _sessions.get(h); if (sp == null) { if (_log.shouldLog(Log.WARN)) - _log.warn("cancelling rerequest, session went away"); + _log.warn("cancelling rerequest, session went away: " + h); return; } synchronized(ClientConnectionRunner.this) { if (sp.rerequestTimer != Rerequest.this) { if (_log.shouldLog(Log.WARN)) - _log.warn("cancelling rerequest, newer request came in"); + _log.warn("cancelling rerequest, newer request came in: " + h); return; } } - requestLeaseSet(_ls.getDestination().calculateHash(), _ls, _expirationTime, _onCreate, _onFailed); + requestLeaseSet(h, _ls, _expirationTime, _onCreate, _onFailed); } } diff --git a/router/java/src/net/i2p/router/client/ClientMessageEventListener.java b/router/java/src/net/i2p/router/client/ClientMessageEventListener.java index f0b273c4ad..8db9da336e 100644 --- a/router/java/src/net/i2p/router/client/ClientMessageEventListener.java +++ b/router/java/src/net/i2p/router/client/ClientMessageEventListener.java @@ -540,11 +540,22 @@ class ClientMessageEventListener implements I2CPMessageReader.I2CPMessageEventLi * @since 0.9.11 */ protected void handleHostLookup(HostLookupMessage message) { - Hash h = _runner.getDestHash(message.getSessionId()); - if (h == null) - return; // ok? + SessionId sid = message.getSessionId(); + Hash h; + if (sid != null) { + h = _runner.getDestHash(sid); + } else { + // fixup if necessary + if (message.getReqID() >= 0) + sid = new SessionId(65535); + h = null; + } + if (h == null) { + h = _runner.getDestHash(); + // h may still be null, an LS lookup for b32 will go out expl. tunnels + } _context.jobQueue().addJob(new LookupDestJob(_context, _runner, message.getReqID(), - message.getTimeout(), message.getSessionId(), + message.getTimeout(), sid, message.getHash(), message.getHostname(), h)); }