public static String toShortenedBase32(Destination destination) { return toBase32(destination).substring(0, 8) + "..."; }
@Override public List<String> toStrings() { Locale locale = new Locale(I2PBote.getLanguage()); DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale); List<String> row = new ArrayList<String>(); row.add(String.valueOf(peer)); row.add(Util.toBase32(destination)); row.add(bucketPrefix); row.add(distance.shiftRight((Hash.HASH_LENGTH-2)*8).toString()); // show the 2 most significant bytes row.add(String.valueOf(isLocked ? renderer.translateContent(Content.YES)+"("+consecTimeouts+")" : renderer.translateContent(Content.NO))); String firstSeen = formatter.format(this.firstSeen); row.add(String.valueOf(firstSeen)); return row; } }
private void listen() throws Exception { System.out.println("Listening for pings on I2P destination " + Util.toBase32(i2pSession.getMyDestination()) + ".b32.i2p"); i2pSession.addSessionListener(new I2PSessionListener() { private int count;
/** * Notifies the <code>BucketManager</code> that a peer didn't respond to * a request. * @param destination */ public synchronized void noResponse(Destination destination) { KademliaPeer peer = getPeer(destination); if (peer != null) peer.noResponse(); else log.debug("Peer not found in buckets: " + Util.toBase32(destination)); // this happens when a peer that was not yet known is contacted and fails to respond }
public void remove(Destination peer) { AbstractBucket bucket = getBucket(peer); if (bucket != null) { bucket.remove(peer); if (bucket instanceof SBucket) refillSiblings(); } else log.debug("Can't remove peer because no bucket contains it: " + Util.toBase32(peer)); }
RelayRequest packet = iterator.next(); if (System.currentTimeMillis() >= packet.getSendTime()) { log.debug("Sending relay packet to destination " + Util.toBase32(packet.getNextDestination())); CountDownLatch sentSignal; Destination nextDestination = packet.getNextDestination();
log.info("Trying " + Util.toBase32(bootstrapNode) + " for bootstrapping."); Collection<Destination> closestNodes = getClosestNodes(localDestinationHash); log.info("No response from bootstrap node " + Util.toBase32(bootstrapNode)); bucketManager.remove(bootstrapNode); log.info("Response from bootstrap node received, refreshing all buckets. Bootstrap node = " + Util.toBase32(bootstrapNode)); refreshAll(); log.info("Bootstrapping finished. Number of peers = " + bucketManager.getPeerCount()); for (Destination peer: bucketManager.getAllPeers()) log.debug(" Peer: " + Util.toBase32(peer)); break outerLoop;
Iterator<Destination> i = responses.iterator(); while (i.hasNext()) log.debug(" Node: " + Util.toBase32(i.next()));
if (log.shouldLog(Log.DEBUG)) { StringBuilder logMessage = new StringBuilder(" "); logMessage.append(Util.toBase32(peer)); logMessage.append(" "); for (boolean responded: peer.getAllSamples())
log.info("Local destination key (base64): " + localDestination.toBase64()); log.info("Local destination hash (base64): " + localDestination.calculateHash().toBase64()); log.info("Local destination hash (base32): " + Util.toBase32(localDestination));
/** * Sends an Email Packet Delete Request to a peer. If the peer is the local node, * the Email Packet is deleted directly. * @param dhtKey The DHT key of the email packet that is to be deleted * @param delAuthorization The delete authorization key for the email packet * @param peer */ private void sendDeleteRequest(Hash dhtKey, UniqueId delAuthorization, Destination peer) { EmailPacketDeleteRequest request = new EmailPacketDeleteRequest(dhtKey, delAuthorization); if (localDestination.equals(peer)) { log.debug("Handling email packet delete request locally. DHT key: " + dhtKey); emailPacketFolder.process(request); } else { log.debug("Sending an EmailPacketDeleteRequest for DHT key " + dhtKey + " to " + Util.toBase32(peer)); sendQueue.send(request, peer); } } }
/** * Adds a <code>{@link KademliaPeer}</code> to the s-bucket or a k-bucket, * depending on its distance to the local node and how full the buckets are. * @param destination */ public void addOrUpdate(KademliaPeer peer) { Hash destHash = peer.getDestinationHash(); if (localDestinationHash.equals(destHash)) { log.debug("Not adding local destination to bucket."); return; } KademliaPeer removedOrNotAdded = sBucket.addOrUpdate(peer); if (removedOrNotAdded == null) getKBucket(destHash).remove(peer); // if the peer was in a k-bucket, remove it because it is now in the s-bucket else addToKBucket(removedOrNotAdded); // if a peer was removed from the s-bucket or didn't qualify as a sibling, add it to a k-bucket // log int numBuckets = kBuckets.size(); int numPeers = getAllPeers().size(); int numSiblings = sBucket.size(); log.debug("Peer " + Util.toBase32(destHash) + " added/updated. Peers=" + numPeers + " sib=" + numSiblings + " buk=" + numBuckets + " (not counting the sibling bucket)"); }
log.debug("Packet found for retrieve request: [" + retrieveRequest + "], replying to sender: [" + Util.toBase32(sender) + "]"); else log.debug("No matching packet found for retrieve request: [" + retrieveRequest + "]");