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

@ -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 = "";

View File

@ -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);
}
}

View File

@ -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));
}