* 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 2014-01-27 zzz
Prop from i2p.i2p.zzz.i2cp: Prop from i2p.i2p.zzz.i2cp:
* I2CP: * I2CP:

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

View File

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

View File

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

View File

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