* I2CP: Use client tunnels for b32 lookups (ticket #1166)

- convert some calls to use getDestHash()
   - javadocs
This commit is contained in:
zzz
2014-01-28 13:27:44 +00:00
parent b2f4fde7e5
commit 5b9d669d79
5 changed files with 27 additions and 11 deletions

View File

@ -1,3 +1,6 @@
2014-01-28 zzz
* I2CP: Use client tunnels for b32 lookups (ticket #1166)
2014-01-27 zzz
Prop from i2p.i2p.zzz.i2cp:
* I2CP:

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 = 6;
public final static long BUILD = 7;
/** for example "-test" */
public final static String EXTRA = "";

View File

@ -182,7 +182,10 @@ class ClientConnectionRunner {
//_manager = null;
}
/** current client's config */
/**
* Current client's config,
* will be null before session is established
*/
public SessionConfig getConfig() { return _config; }
/**
@ -209,6 +212,10 @@ class ClientConnectionRunner {
public LeaseSet getLeaseSet() { return _currentLeaseSet; }
void setLeaseSet(LeaseSet ls) { _currentLeaseSet = ls; }
/**
* Equivalent to getConfig().getDestination().calculateHash();
* will be null before session is established
*/
public Hash getDestHash() { return _destHashCache; }
/** current client's sessionId */

View File

@ -222,7 +222,7 @@ class ClientMessageEventListener implements I2CPMessageReader.I2CPMessageEventLi
_runner.sessionEstablished(cfg);
if (_log.shouldLog(Log.DEBUG))
_log.debug("after sessionEstablished for " + message.getSessionConfig().getDestination().calculateHash().toBase64());
_log.debug("after sessionEstablished for " + _runner.getDestHash());
startCreateSessionJob();
}
@ -355,7 +355,7 @@ class ClientMessageEventListener implements I2CPMessageReader.I2CPMessageEventLi
}
if (_log.shouldLog(Log.INFO))
_log.info("New lease set granted for destination "
+ message.getLeaseSet().getDestination().calculateHash().toBase64());
+ _runner.getDestHash());
// leaseSetCreated takes care of all the LeaseRequestState stuff (including firing any jobs)
_runner.leaseSetCreated(message.getLeaseSet());
@ -363,7 +363,8 @@ class ClientMessageEventListener implements I2CPMessageReader.I2CPMessageEventLi
/** override for testing */
protected void handleDestLookup(DestLookupMessage message) {
_context.jobQueue().addJob(new LookupDestJob(_context, _runner, message.getHash()));
_context.jobQueue().addJob(new LookupDestJob(_context, _runner, message.getHash(),
_runner.getDestHash()));
}
/**
@ -373,7 +374,8 @@ class ClientMessageEventListener implements I2CPMessageReader.I2CPMessageEventLi
protected void handleHostLookup(HostLookupMessage message) {
_context.jobQueue().addJob(new LookupDestJob(_context, _runner, message.getReqID(),
message.getTimeout(), message.getSessionId(),
message.getHash(), message.getHostname()));
message.getHash(), message.getHostname(),
_runner.getDestHash()));
}
/**
@ -394,7 +396,7 @@ class ClientMessageEventListener implements I2CPMessageReader.I2CPMessageEventLi
return;
}
_runner.getConfig().getOptions().putAll(message.getSessionConfig().getOptions());
Hash dest = _runner.getConfig().getDestination().calculateHash();
Hash dest = _runner.getDestHash();
ClientTunnelSettings settings = new ClientTunnelSettings(dest);
Properties props = new Properties();
props.putAll(_runner.getConfig().getOptions());

View File

@ -29,21 +29,24 @@ class LookupDestJob extends JobImpl {
private final Hash _hash;
private final String _name;
private final SessionId _sessID;
private final Hash _fromLocalDest;
private static final long DEFAULT_TIMEOUT = 15*1000;
public LookupDestJob(RouterContext context, ClientConnectionRunner runner, Hash h) {
this(context, runner, -1, DEFAULT_TIMEOUT, null, h, null);
public LookupDestJob(RouterContext context, ClientConnectionRunner runner, Hash h, Hash fromLocalDest) {
this(context, runner, -1, DEFAULT_TIMEOUT, null, h, null, fromLocalDest);
}
/**
* One of h or name non-null
* @param reqID must be >= 0 if name != null
* @param sessID must non-null if reqID >= 0
* @param fromLocalDest use these tunnels for the lookup, or null for exploratory
* @since 0.9.11
*/
public LookupDestJob(RouterContext context, ClientConnectionRunner runner,
long reqID, long timeout, SessionId sessID, Hash h, String name) {
long reqID, long timeout, SessionId sessID, Hash h, String name,
Hash fromLocalDest) {
super(context);
if ((h == null && name == null) ||
(h != null && name != null) ||
@ -54,6 +57,7 @@ class LookupDestJob extends JobImpl {
_reqID = reqID;
_timeout = timeout;
_sessID = sessID;
_fromLocalDest = fromLocalDest;
if (name != null && name.length() == 60) {
// convert a b32 lookup to a hash lookup
String nlc = name.toLowerCase(Locale.US);
@ -84,7 +88,7 @@ class LookupDestJob extends JobImpl {
returnFail();
} else {
DoneJob done = new DoneJob(getContext());
getContext().netDb().lookupLeaseSet(_hash, done, done, _timeout);
getContext().netDb().lookupLeaseSet(_hash, done, done, _timeout, _fromLocalDest);
}
}