I2CP: Fix simple session lookups, broken in prop

This commit is contained in:
zzz
2015-06-19 15:55:07 +00:00
parent 586defc802
commit 1b2d4c75eb
5 changed files with 29 additions and 13 deletions

View File

@ -42,9 +42,11 @@ import net.i2p.data.LeaseSet;
import net.i2p.data.PrivateKey; import net.i2p.data.PrivateKey;
import net.i2p.data.SigningPrivateKey; import net.i2p.data.SigningPrivateKey;
import net.i2p.data.i2cp.DestLookupMessage; import net.i2p.data.i2cp.DestLookupMessage;
import net.i2p.data.i2cp.DestReplyMessage;
import net.i2p.data.i2cp.GetBandwidthLimitsMessage; import net.i2p.data.i2cp.GetBandwidthLimitsMessage;
import net.i2p.data.i2cp.GetDateMessage; import net.i2p.data.i2cp.GetDateMessage;
import net.i2p.data.i2cp.HostLookupMessage; import net.i2p.data.i2cp.HostLookupMessage;
import net.i2p.data.i2cp.HostReplyMessage;
import net.i2p.data.i2cp.I2CPMessage; import net.i2p.data.i2cp.I2CPMessage;
import net.i2p.data.i2cp.I2CPMessageReader; import net.i2p.data.i2cp.I2CPMessageReader;
import net.i2p.data.i2cp.MessagePayloadMessage; import net.i2p.data.i2cp.MessagePayloadMessage;
@ -900,7 +902,9 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2
SessionId id = message.sessionId(); SessionId id = message.sessionId();
SessionId currId = _sessionId; SessionId currId = _sessionId;
if (id == null || id.equals(currId) || 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 // it's for us
I2CPMessageHandler handler = _handlerMap.getHandler(type); I2CPMessageHandler handler = _handlerMap.getHandler(type);
if (handler != null) { if (handler != null) {

View File

@ -1,4 +1,5 @@
2015-06-19 zzz 2015-06-19 zzz
* I2CP: Fix simple session lookups, broken in prop
* I2PSocketEepGet: Do hostname lookups in-session for efficiency * I2PSocketEepGet: Do hostname lookups in-session for efficiency
* Tunnels: Increase default max tunnels * Tunnels: Increase default max tunnels

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */ /** deprecated */
public final static String ID = "Monotone"; public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION; public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 7; public final static long BUILD = 8;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = ""; public final static String EXTRA = "";

View File

@ -303,15 +303,15 @@ class ClientConnectionRunner {
/** /**
* Equivalent to getConfig().getDestination().calculateHash(); * Equivalent to getConfig().getDestination().calculateHash();
* will be null before session is established * 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. * Don't use if you can help it.
* *
* @return primary hash or null if not yet set * @return primary hash or null if not yet set
*/ */
public Hash getDestHash() { public Hash getDestHash() {
for (Hash h : _sessions.keySet()) { SessionConfig cfg = getPrimaryConfig();
return h; if (cfg != null)
} return cfg.getDestination().calculateHash();
return null; return null;
} }
@ -890,17 +890,17 @@ class ClientConnectionRunner {
SessionParams sp = _sessions.get(h); SessionParams sp = _sessions.get(h);
if (sp == null) { if (sp == null) {
if (_log.shouldLog(Log.WARN)) if (_log.shouldLog(Log.WARN))
_log.warn("cancelling rerequest, session went away"); _log.warn("cancelling rerequest, session went away: " + h);
return; return;
} }
synchronized(ClientConnectionRunner.this) { synchronized(ClientConnectionRunner.this) {
if (sp.rerequestTimer != Rerequest.this) { if (sp.rerequestTimer != Rerequest.this) {
if (_log.shouldLog(Log.WARN)) if (_log.shouldLog(Log.WARN))
_log.warn("cancelling rerequest, newer request came in"); _log.warn("cancelling rerequest, newer request came in: " + h);
return; return;
} }
} }
requestLeaseSet(_ls.getDestination().calculateHash(), _ls, _expirationTime, _onCreate, _onFailed); requestLeaseSet(h, _ls, _expirationTime, _onCreate, _onFailed);
} }
} }

View File

@ -540,11 +540,22 @@ class ClientMessageEventListener implements I2CPMessageReader.I2CPMessageEventLi
* @since 0.9.11 * @since 0.9.11
*/ */
protected void handleHostLookup(HostLookupMessage message) { protected void handleHostLookup(HostLookupMessage message) {
Hash h = _runner.getDestHash(message.getSessionId()); SessionId sid = message.getSessionId();
if (h == null) Hash h;
return; // ok? 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(), _context.jobQueue().addJob(new LookupDestJob(_context, _runner, message.getReqID(),
message.getTimeout(), message.getSessionId(), message.getTimeout(), sid,
message.getHash(), message.getHostname(), h)); message.getHash(), message.getHostname(), h));
} }