/** * Works even if tunnel is not running. * @return "{52 chars}.b32.i2p" or "" * @since 0.9.30 */ public String getAltDestHashBase32(int tunnel) { Destination d = getAltDestination(tunnel); if (d != null) return d.toBase32(); return ""; }
/** * Works even if tunnel is not running. * @return "{52 chars}.b32.i2p" or "" */ public String getDestHashBase32(int tunnel) { Destination d = getDestination(tunnel); if (d != null) return d.toBase32(); return ""; }
/** * Make a dummy header from a dest, * for those cases where we want to receive unsolicited datagrams. * Unused for now. */ public SOCKSHeader(Destination dest) { this.header = new byte[beg.length + 60 + end.length]; System.arraycopy(beg, 0, this.header, 0, beg.length); String b32 = dest.toBase32(); System.arraycopy(DataHelper.getASCII(b32), 0, this.header, beg.length, 60); System.arraycopy(end, 0, this.header, beg.length + 60, end.length); }
/** * Returns null if not running. * @return "{52 chars}.b32.i2p" or null */ public String getMyDestHashBase32() { Destination dest = getDestination(); if (dest != null) return dest.toBase32(); return null; }
/** * @return b32hash.b32.i2p, or "i2p" on lookup failure. * Prior to 0.7.12, returned b64 key */ private final String getHostName(String host) { if(host == null) { return null; } if(host.length() == 60 && host.toLowerCase(Locale.US).endsWith(".b32.i2p")) { return host; } Destination dest = _context.namingService().lookup(host); if (dest == null) return "i2p"; return dest.toBase32(); }
@Override public String toString() { StringBuilder s = new StringBuilder(128); s.append("Dest: "); s.append(this.dest != null ? this.dest.toBase64() : "null"); s.append("\nB32: "); s.append(this.dest != null ? this.dest.toBase32() : "null"); s.append("\nContains: "); s.append(this.dest); s.append("\nPrivate Key: "); s.append(this.privKey); s.append("\nSigining Private Key: "); if (isOffline()) { s.append("offline\nOffline Signature Expires: "); s.append(new Date(getOfflineExpiration())); s.append("\nTransient Signing Public Key: "); s.append(_transientSigningPubKey); s.append("\nOffline Signature: "); s.append(_offlineSignature); s.append("\nTransient Signing Private Key: "); s.append(_transientSigningPrivKey); } else { s.append(this.signingPrivKey); s.append("\n"); } return s.toString(); }
public String getB32Hostname() { return sockMgr.getSession().getMyDestination().toBase32(); }
/** * Read in the given destination, display it, and write it to the given location * Deprecated - only used by CLI * * @param readFrom stream to read the destination from * @param pubDest stream to write the destination to * @param l logger to send messages to */ private static void showKey(InputStream readFrom, OutputStream pubDest, Logging l) { try { Destination d = new Destination(); d.readBytes(readFrom); l.log("Destination: " + d.toBase32()); readFrom.close(); writePubKey(d, pubDest, l); } catch (I2PException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } }
/** * Create a new destination, storing the destination and its private keys where * instructed. * Does NOT support non-default sig types. * Deprecated - only used by CLI * * @param writeTo location to store the destination and private keys * @param pubDest location to store the destination * @param l logger to send messages to */ private static void makeKey(OutputStream writeTo, OutputStream pubDest, Logging l) { try { l.log("Generating new keys..."); I2PClient client = I2PClientFactory.createClient(); Destination d = client.createDestination(writeTo); l.log("New destination: " + d.toBase32()); writeTo.flush(); writeTo.close(); writePubKey(d, pubDest, l); } catch (I2PException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } }
throw new DataFormatException("Bad number of leases decrypting " + _destination.toBase32() + " - is this destination encrypted?"); int datalen = DATA_LEN * size;
"New Base32 is " + newdest.toBase32() + "New Destination is " + newdest.toBase64();
log("You should backup this file in a secure place."); log("New destination: " + destStr); String b32 = dest.toBase32(); log("Base32: " + b32); File backupDir = new SecureFile(I2PAppContext.getGlobalContext().getConfigDir(), KEY_BACKUP_DIR);
if (_log.shouldLog(Log.WARN)) _log.warn("Old leaseSet! not storing it: " + leaseSet.getDestination().toBase32() + " first exp. " + new Date(earliest) + " last exp. " + new Date(latest), new Exception("Rejecting store")); return "Expired leaseSet for " + leaseSet.getDestination().toBase32() + " expired " + DataHelper.formatDuration(age) + " ago"; + leaseSet.getDestination().toBase32() + " expires " + DataHelper.formatDuration(age) + " from now"); return "Future expiring leaseSet for " + leaseSet.getDestination().toBase32() + " expiring in " + DataHelper.formatDuration(age);
Hash dest = client.calculateHash(); if (_log.shouldLog(Log.DEBUG)) _log.debug("Building tunnels for the client " + client.toBase32() + ": " + settings); TunnelPool inbound = null; TunnelPool outbound = null;
/** * Request that a particular client authorize the Leases contained in the * LeaseSet, after which the onCreateJob is queued up. If that doesn't occur * within the timeout specified, queue up the onFailedJob. This call does not * block. * * UNUSED, the call below without jobs is always used. * * @param dest Destination from which the LeaseSet's authorization should be requested * @param set LeaseSet with requested leases - this object must be updated to contain the * signed version (as well as any changed/added/removed Leases). * The LeaseSet contains Leases only; it is unsigned and does not have the destination set. * @param timeout ms to wait before failing * @param onCreateJob Job to run after the LeaseSet is authorized * @param onFailedJob Job to run after the timeout passes without receiving authorization */ public void requestLeaseSet(Destination dest, LeaseSet set, long timeout, Job onCreateJob, Job onFailedJob) { ClientConnectionRunner runner = getRunner(dest); if (runner == null) { if (_log.shouldLog(Log.WARN)) _log.warn("Cannot request the lease set, as we can't find a client runner for " + dest.toBase32() + ". disconnected?"); _ctx.jobQueue().addJob(onFailedJob); } else { runner.requestLeaseSet(dest.calculateHash(), set, timeout, onCreateJob, onFailedJob); } }
} catch (DataFormatException dfe) { Log log = I2PAppContext.getGlobalContext().logManager().getLog(LeaseSet.class); log.error("Error decrypting " + _destination.toBase32() + " - is this destination encrypted?", dfe); } catch (IOException ioe) { Log log = I2PAppContext.getGlobalContext().logManager().getLog(LeaseSet.class); log.error("Error decrypting " + _destination.toBase32() + " - is this destination encrypted?", ioe);
@Override public boolean verifyClientLiveliness() { if (_manager == null) return true; boolean lively = true; for (Destination dest : _manager.getRunnerDestinations()) { ClientConnectionRunner runner = _manager.getRunner(dest); if ( (runner == null) || (runner.getIsDead())) continue; LeaseSet ls = runner.getLeaseSet(dest.calculateHash()); if (ls == null) continue; // still building long howLongAgo = _context.clock().now() - ls.getEarliestLeaseDate(); if (howLongAgo > MAX_TIME_TO_REBUILD) { if (_log.shouldLog(Log.ERROR)) _log.error("Client " + dest.toBase32() + " has a leaseSet that expired " + DataHelper.formatDuration(howLongAgo) + " ago"); lively = false; } } return lively; }
log("You should backup this file in a secure place."); log("New alternate destination: " + destStr); String b32 = d.toBase32(); log("Base32: " + b32); File backupDir = new SecureFile(I2PAppContext.getGlobalContext().getConfigDir(), KEY_BACKUP_DIR);