@Override public String toString() { StringBuilder buf = new StringBuilder("[SessionConfig: "); buf.append("\n\tDestination: ").append(getDestination()); buf.append("\n\tSignature: ").append(getSignature()); buf.append("\n\tCreation Date: ").append(getCreationDate()); buf.append("\n\tOptions: #: ").append(_options.size()); Properties sorted = new OrderedProperties(); sorted.putAll(_options); for (Map.Entry<Object, Object> e : sorted.entrySet()) { String key = (String) e.getKey(); String val = (String) e.getValue(); buf.append("\n\t\t[").append(key).append("] = [").append(val).append("]"); } buf.append("]"); return buf.toString(); } }
/** * Equivalent to getConfig().getDestination().calculateHash(); * will be null before session is established * 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() { SessionConfig cfg = getPrimaryConfig(); if (cfg != null) return cfg.getDestination().calculateHash(); return null; }
public void runJob() { Hash dest = _config.getDestination().calculateHash(); if (_log.shouldLog(Log.INFO)) _log.info("Requesting lease set for destination " + dest); ClientTunnelSettings settings = new ClientTunnelSettings(dest); Properties props = new Properties(); // We're NOT going to force all clients to use the router's defaults, since that may be // excessive. This means that unless the user says otherwise, we'll be satisfied with whatever // is available. Otherwise, when the router starts up, if there aren't sufficient tunnels with the // adequate number of hops, the user will have to wait. Once peer profiles are persistent, we can // reenable this, since on startup we'll have a sufficient number of high enough ranked peers to // tunnel through. (perhaps). // XXX take the router's defaults // XXX props.putAll(Router.getInstance().getConfigMap()); // override them by the client's settings props.putAll(_config.getOptions()); // and load 'em up (using anything not yet set as the software defaults) settings.readFromProperties(props); getContext().tunnelManager().buildTunnels(_config.getDestination(), settings); } }
Destination dest = config.getDestination(); Hash destHash = dest.calculateHash(); if (_log.shouldLog(Log.DEBUG))
@Override public boolean equals(Object object) { if ((object != null) && (object instanceof SessionConfig)) { SessionConfig cfg = (SessionConfig) object; return DataHelper.eq(getSignature(), cfg.getSignature()) && DataHelper.eq(getDestination(), cfg.getDestination()) && DataHelper.eq(getCreationDate(), cfg.getCreationDate()) && DataHelper.eq(getOptions(), cfg.getOptions()); } return false; }
public void timeReached() { if (!_isStarted) return; for (ClientConnectionRunner runner : _runners.values()) { if (runner instanceof QueuedClientConnectionRunner) continue; if (runner.isDead()) continue; SessionConfig cfg = runner.getPrimaryConfig(); if (cfg == null) continue; // simple session or no session yet if (runner.getLeaseSet(cfg.getDestination().calculateHash()) == null) continue; // don't confuse client while waiting for CreateLeaseSet msg try { // only send version if the client can handle it (0.8.7 or greater) runner.doSend(new SetDateMessage(runner.getClientVersion() != null ? CoreVersion.VERSION : null)); } catch (I2CPMessageException ime) {} } if (_isStarted) schedule(LOOP_TIME); } }
if (!message.getSessionConfig().getDestination().equals(cfg.getDestination())) { _log.error("Dest mismatch"); sendStatusMessage(id, SessionStatusMessage.STATUS_INVALID); return; Hash dest = cfg.getDestination().calculateHash(); cfg.getOptions().putAll(message.getSessionConfig().getOptions()); ClientTunnelSettings settings = new ClientTunnelSettings(dest);
if (getDestination() == null) { return false; } else { spk = getDestination().getSigningPublicKey();
Destination dest = in.getDestination(); if (in.verifySignature()) { if (_log.shouldLog(Log.DEBUG)) boolean ok = _context.tunnelManager().addAlias(dest, settings, pcfg.getDestination()); if (!ok) { _log.error("Add alias failed");
/** * Immediately send a fake leaseset */ @Override protected void startCreateSessionJob(SessionConfig config) { long exp = _context.clock().now() + 10*60*1000; LeaseSet ls = new LeaseSet(); Lease lease = new Lease(); lease.setGateway(Hash.FAKE_HASH); TunnelId id = new TunnelId(1); lease.setTunnelId(id); Date date = new Date(exp); lease.setEndDate(date); ls.addLease(lease); _runner.requestLeaseSet(config.getDestination().calculateHash(), ls, exp, null, null); }
return; Destination dest = cfg.getDestination(); Destination ndest = ls.getDestination(); if (!dest.equals(ndest)) {