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();
}

View File

@ -0,0 +1,17 @@
package net.i2p.router.web;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
/**
* Treat a writer as an output stream. Quick 'n dirty, none
* of that "intarnasheeonaleyzayshun" stuff. So we can treat
* the jsp's PrintWriter as an OutputStream
*/
public class WriterOutputStream extends OutputStream {
private Writer _writer;
public WriterOutputStream(Writer writer) { _writer = writer; }
public void write(int b) throws IOException { _writer.write(b); }
}

View File

@ -1,4 +1,5 @@
<%@page contentType="text/plain" %>
<jsp:useBean id="helper" class="net.i2p.router.web.StatHelper" />
<jsp:setProperty name="helper" property="peer" value="<%=request.getParameter("peer")%>" />
<jsp:getProperty name="helper" property="profile" />
<%@page contentType="text/plain"
%><jsp:useBean id="helper" class="net.i2p.router.web.StatHelper"
/><jsp:setProperty name="helper" property="peer" value="<%=request.getParameter("peer")%>"
/><jsp:setProperty name="helper" property="writer" value="<%=out%>"
/><jsp:getProperty name="helper" property="profile" />

View File

@ -32,6 +32,7 @@ public class Connection {
private long _lastSendTime;
private long _lastSendId;
private boolean _resetReceived;
private boolean _resetSent;
private boolean _connected;
private boolean _hardDisconnected;
private MessageInputStream _inputStream;
@ -178,6 +179,7 @@ public class Connection {
*
*/
void sendReset() {
_resetSent = true;
if ( (_remotePeer == null) || (_sendStreamId == null) ) return;
PacketLocal reply = new PacketLocal(_context, _remotePeer);
reply.setFlag(Packet.FLAG_RESET);
@ -380,6 +382,7 @@ public class Connection {
public boolean getIsConnected() { return _connected; }
public boolean getHardDisconnected() { return _hardDisconnected; }
public boolean getResetSent() { return _resetSent; }
void disconnect(boolean cleanDisconnect) {
disconnect(cleanDisconnect, true);

View File

@ -34,7 +34,7 @@ class SchedulerHardDisconnected extends SchedulerImpl {
public boolean accept(Connection con) {
if (con == null) return false;
long timeSinceClose = _context.clock().now() - con.getCloseSentOn();
boolean ok = (con.getHardDisconnected()) &&
boolean ok = (con.getHardDisconnected() || con.getResetSent()) &&
(timeSinceClose < Connection.DISCONNECT_TIMEOUT);
return ok;
}

View File

@ -1,4 +1,11 @@
$Id: history.txt,v 1.108 2004/12/15 21:45:56 jrandom Exp $
$Id: history.txt,v 1.109 2004/12/16 00:42:04 jrandom Exp $
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.
2004-12-16 jrandom
* Remove the randomized factor in the tunnel rejection by bandwidth -

View File

@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
*
*/
public class RouterVersion {
public final static String ID = "$Revision: 1.113 $ $Date: 2004/12/15 21:45:55 $";
public final static String ID = "$Revision: 1.114 $ $Date: 2004/12/16 00:42:04 $";
public final static String VERSION = "0.4.2.3";
public final static long BUILD = 7;
public final static long BUILD = 8;
public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION);
System.out.println("Router ID: " + RouterVersion.ID);

View File

@ -70,9 +70,9 @@ class ProfilePersistenceHelper {
groups = "not failing";
} else {
if (_context.profileOrganizer().isFast(profile.getPeer()))
groups = "fast and reliable";
groups = "fast and high capacity";
else
groups = "reliable";
groups = "high capacity";
if (_context.profileOrganizer().isWellIntegrated(profile.getPeer()))
groups = groups + ", well integrated";
@ -85,6 +85,7 @@ class ProfilePersistenceHelper {
buf.append("# as calculated by ").append(_us.toBase64()).append(NL);
buf.append("#").append(NL);
buf.append("# reliability: ").append(profile.getReliabilityValue()).append(NL);
buf.append("# capacity: ").append(profile.getCapacityValue()).append(NL);
buf.append("# integration: ").append(profile.getIntegrationValue()).append(NL);
buf.append("# speedValue: ").append(profile.getSpeedValue()).append(NL);
buf.append("#").append(NL);