2004-12-16 jrandom

* Catch another oddball case for a reset connection in the streaming lib.
    * Add a dumpprofile.jsp page, called with ?peer=base64OfPeerHash, which
      dumps the current state of that peer's profile.  Instead of the full
      base64, you can pass in however many characters you have and it will
      return the first match found.
This commit is contained in:
jrandom
2004-12-16 10:21:23 +00:00
committed by zzz
parent 3cb727561c
commit d969dd2d8d
8 changed files with 62 additions and 18 deletions

View File

@ -1,22 +1,37 @@
package net.i2p.router.web;
import java.util.Iterator;
import java.util.Set;
import java.io.ByteArrayOutputStream;
import java.io.Writer;
import net.i2p.data.Hash;
import net.i2p.router.RouterContext;
/**
* uuuugly. dump the peer profile data if given a peer.
*
*/
public class StatHelper {
private String _peer;
private Writer _writer;
public void setPeer(String peer) { _peer = peer; }
public void setWriter(Writer writer) { _writer = writer; }
public String getProfile() {
net.i2p.router.RouterContext ctx = (net.i2p.router.RouterContext)net.i2p.router.RouterContext.listContexts().get(0);
java.util.Set peers = ctx.profileOrganizer().selectAllPeers();
for (java.util.Iterator iter = peers.iterator(); iter.hasNext(); ) {
net.i2p.data.Hash peer = (net.i2p.data.Hash)iter.next();
if (_peer.indexOf(peer.toBase64().substring(0,10)) >= 0) {
RouterContext ctx = (RouterContext)net.i2p.router.RouterContext.listContexts().get(0);
Set peers = ctx.profileOrganizer().selectAllPeers();
for (Iterator iter = peers.iterator(); iter.hasNext(); ) {
Hash peer = (Hash)iter.next();
if (peer.toBase64().startsWith(_peer)) {
try {
java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(64*1024);
ctx.profileOrganizer().exportProfile(peer, baos);
return new String(baos.toByteArray());
WriterOutputStream wos = new WriterOutputStream(_writer);
ctx.profileOrganizer().exportProfile(peer, wos);
wos.flush();
_writer.flush();
return "";
} catch (Exception e) {
e.printStackTrace();
}