peers.jsp: cleanup and tag

This commit is contained in:
zzz
2010-04-27 12:55:37 +00:00
parent ab4ff5548d
commit 46f341d782
7 changed files with 242 additions and 175 deletions

View File

@ -40,7 +40,10 @@ ROUTERFILES="\
../../../router/java/src/net/i2p/router/transport/GetBidsJob.java \ ../../../router/java/src/net/i2p/router/transport/GetBidsJob.java \
../../../router/java/src/net/i2p/router/Blocklist.java \ ../../../router/java/src/net/i2p/router/Blocklist.java \
../../../router/java/src/net/i2p/router/transport/ntcp/EstablishState.java \ ../../../router/java/src/net/i2p/router/transport/ntcp/EstablishState.java \
../../../router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java" ../../../router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java \
../../../router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java \
../../../router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java \
../../../router/java/src/net/i2p/router/transport/udp/UDPTransport.java"
# add ../java/ so the refs will work in the po file # add ../java/ so the refs will work in the po file
JPATHS="../java/src ../jsp/WEB-INF ../java/strings $JFILE $ROUTERFILES" JPATHS="../java/src ../jsp/WEB-INF ../java/strings $JFILE $ROUTERFILES"

View File

@ -1,3 +1,9 @@
2010-04-27 zzz
* i2psnark: Serve downloaded files from the servlet rather
than with a file: link
* Jetty: Backport directory listing bugfix from jetty 6
* peers.jsp: Cleanup and tag
* 2010-04-27 0.7.13 released * 2010-04-27 0.7.13 released
2010-04-23 zzz 2010-04-23 zzz

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */ /** deprecated */
public final static String ID = "Monotone"; public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION; public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 0; public final static long BUILD = 1;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = ""; public final static String EXTRA = "";

View File

@ -495,7 +495,7 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
buf.append("<tt>"); buf.append("<tt>");
boolean found = _context.netDb().lookupRouterInfoLocally(peer) != null; boolean found = _context.netDb().lookupRouterInfoLocally(peer) != null;
if (found) if (found)
buf.append("<a title=\"NetDb entry\" href=\"netdb.jsp?r=").append(h).append("\">"); buf.append("<a title=\"").append(_("NetDb entry")).append("\" href=\"netdb.jsp?r=").append(h).append("\">");
buf.append(h); buf.append(h);
if (found) if (found)
buf.append("</a>"); buf.append("</a>");
@ -503,6 +503,13 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
return buf.toString(); return buf.toString();
} }
/**
* Translate
*/
private final String _(String s) {
return Translate.getString(s, _context, BUNDLE_NAME);
}
/* /*
* Timestamper stuff * Timestamper stuff
* *

View File

@ -32,6 +32,7 @@ import net.i2p.router.RouterContext;
import net.i2p.router.transport.ntcp.NTCPTransport; import net.i2p.router.transport.ntcp.NTCPTransport;
import net.i2p.router.transport.udp.UDPTransport; import net.i2p.router.transport.udp.UDPTransport;
import net.i2p.util.Log; import net.i2p.util.Log;
import net.i2p.util.Translate;
public class TransportManager implements TransportEventListener { public class TransportManager implements TransportEventListener {
private Log _log; private Log _log;
@ -499,13 +500,14 @@ public class TransportManager implements TransportEventListener {
t.renderStatusHTML(out, urlBase, sortFlags); t.renderStatusHTML(out, urlBase, sortFlags);
} }
StringBuilder buf = new StringBuilder(4*1024); StringBuilder buf = new StringBuilder(4*1024);
buf.append("<h3>Router Transport Addresses</h3><pre>\n"); buf.append("<h3>").append(_("Router Transport Addresses")).append("</h3><pre>\n");
for (int i = 0; i < _transports.size(); i++) { for (int i = 0; i < _transports.size(); i++) {
Transport t = _transports.get(i); Transport t = _transports.get(i);
if (t.getCurrentAddress() != null) if (t.getCurrentAddress() != null)
buf.append(t.getCurrentAddress()).append("\n\n"); buf.append(t.getCurrentAddress());
else else
buf.append(t.getStyle()).append(" is used for outbound connections only\n\n"); buf.append(_("{0} is used for outbound connections only", t.getStyle()));
buf.append("\n\n");
} }
buf.append("</pre>\n"); buf.append("</pre>\n");
out.write(buf.toString()); out.write(buf.toString());
@ -525,4 +527,20 @@ public class TransportManager implements TransportEventListener {
return s; return s;
} }
private static final String BUNDLE_NAME = "net.i2p.router.web.messages";
/**
* Translate
*/
private final String _(String s) {
return Translate.getString(s, _context, BUNDLE_NAME);
}
/**
* Translate
*/
private final String _(String s, Object o) {
return Translate.getString(s, o, _context, BUNDLE_NAME);
}
} }

View File

@ -28,6 +28,7 @@ import net.i2p.router.transport.Transport;
import net.i2p.router.transport.TransportBid; import net.i2p.router.transport.TransportBid;
import net.i2p.router.transport.TransportImpl; import net.i2p.router.transport.TransportImpl;
import net.i2p.util.Log; import net.i2p.util.Log;
import net.i2p.util.Translate;
/** /**
* *
@ -687,22 +688,22 @@ public class NTCPTransport extends TransportImpl {
long totalRecv = 0; long totalRecv = 0;
StringBuilder buf = new StringBuilder(512); StringBuilder buf = new StringBuilder(512);
buf.append("<div class=\"wideload\"><h3 id=\"ntcpcon\">NTCP connections: ").append(peers.size()); buf.append("<div class=\"wideload\"><h3 id=\"ntcpcon\">").append(_("NTCP connections")).append(": ").append(peers.size());
buf.append(". Limit: ").append(getMaxConnections()); buf.append(". ").append(_("Limit")).append(": ").append(getMaxConnections());
buf.append(". Timeout: ").append(DataHelper.formatDuration(_pumper.getIdleTimeout())); buf.append(". ").append(_("Timeout")).append(": ").append(DataHelper.formatDuration(_pumper.getIdleTimeout()));
buf.append(".</h3>\n" + buf.append(".</h3>\n" +
"<table>\n" + "<table>\n" +
"<tr><th><a href=\"#def.peer\">Peer</a></th>" + "<tr><th><a href=\"#def.peer\">").append(_("Peer")).append("</a></th>" +
"<th>Dir</th>" + "<th>").append(_("Dir")).append("</th>" +
"<th align=\"right\"><a href=\"#def.idle\">Idle</a></th>" + "<th align=\"right\"><a href=\"#def.idle\">").append(_("Idle")).append("</a></th>" +
"<th align=\"right\"><a href=\"#def.rate\">In/Out</a></th>" + "<th align=\"right\"><a href=\"#def.rate\">").append(_("In/Out")).append("</a></th>" +
"<th align=\"right\"><a href=\"#def.up\">Up</a></th>" + "<th align=\"right\"><a href=\"#def.up\">").append(_("Up")).append("</a></th>" +
"<th align=\"right\"><a href=\"#def.skew\">Skew</a></th>" + "<th align=\"right\"><a href=\"#def.skew\">").append(_("Skew")).append("</a></th>" +
"<th align=\"right\"><a href=\"#def.send\">TX</a></th>" + "<th align=\"right\"><a href=\"#def.send\">").append(_("TX")).append("</a></th>" +
"<th align=\"right\"><a href=\"#def.recv\">RX</a></th>" + "<th align=\"right\"><a href=\"#def.recv\">").append(_("RX")).append("</a></th>" +
"<th>Out queue</th>" + "<th>").append(_("Out Queue")).append("</th>" +
"<th>Backlogged?</th>" + "<th>").append(_("Backlogged?")).append("</th>" +
"<th>Reading?</th>" + //"<th>").append(_("Reading?")).append("</th>" +
" </tr>\n"); " </tr>\n");
out.write(buf.toString()); out.write(buf.toString());
buf.setLength(0); buf.setLength(0);
@ -715,13 +716,13 @@ public class NTCPTransport extends TransportImpl {
// buf.append(' ').append(_context.blocklist().toStr(ip)); // buf.append(' ').append(_context.blocklist().toStr(ip));
buf.append("</td><td class=\"cells\" align=\"center\">"); buf.append("</td><td class=\"cells\" align=\"center\">");
if (con.isInbound()) if (con.isInbound())
buf.append("<img src=\"/themes/console/images/inbound.png\" alt=\"Inbound\" title=\"Inbound\"/>"); buf.append("<img src=\"/themes/console/images/inbound.png\" alt=\"Inbound\" title=\"").append(_("Inbound")).append("\"/>");
else else
buf.append("<img src=\"/themes/console/images/outbound.png\" alt=\"Outbound\" title=\"Outbound\"/>"); buf.append("<img src=\"/themes/console/images/outbound.png\" alt=\"Outbound\" title=\"").append(_("Outbound")).append("\"/>");
buf.append("</td><td class=\"cells\" align=\"right\">"); buf.append("</td><td class=\"cells\" align=\"right\">");
buf.append(con.getTimeSinceReceive()/1000); buf.append(con.getTimeSinceReceive()/1000);
buf.append("s / ").append(con.getTimeSinceSend()/1000); buf.append("s / ").append(con.getTimeSinceSend()/1000);
buf.append("s</td> <td class=\"cells\" align=\"center\">"); buf.append("s</td><td class=\"cells\" align=\"right\">");
if (con.getTimeSinceReceive() < 10*1000) { if (con.getTimeSinceReceive() < 10*1000) {
buf.append(formatRate(con.getRecvRate()/1024)); buf.append(formatRate(con.getRecvRate()/1024));
bpsRecv += con.getRecvRate(); bpsRecv += con.getRecvRate();
@ -735,30 +736,28 @@ public class NTCPTransport extends TransportImpl {
} else { } else {
buf.append(formatRate(0)); buf.append(formatRate(0));
} }
buf.append("K/s"); //buf.append(" K/s");
buf.append("</td> <td class=\"cells\" align=\"center\">").append(DataHelper.formatDuration(con.getUptime())); buf.append("</td><td class=\"cells\" align=\"right\">").append(DataHelper.formatDuration(con.getUptime()));
totalUptime += con.getUptime(); totalUptime += con.getUptime();
offsetTotal = offsetTotal + con.getClockSkew(); offsetTotal = offsetTotal + con.getClockSkew();
buf.append("</td> <td class=\"cells\" align=\"center\">").append(con.getClockSkew()); buf.append("</td><td class=\"cells\" align=\"right\">").append(con.getClockSkew());
buf.append("s</td> <td class=\"cells\" align=\"center\">").append(con.getMessagesSent()); buf.append("s</td><td class=\"cells\" align=\"right\">").append(con.getMessagesSent());
totalSend += con.getMessagesSent(); totalSend += con.getMessagesSent();
buf.append("</td> <td class=\"cells\" align=\"center\">").append(con.getMessagesReceived()); buf.append("</td><td class=\"cells\" align=\"right\">").append(con.getMessagesReceived());
totalRecv += con.getMessagesReceived(); totalRecv += con.getMessagesReceived();
long outQueue = con.getOutboundQueueSize(); long outQueue = con.getOutboundQueueSize();
if (outQueue <= 0) { buf.append("</td><td class=\"cells\" align=\"center\">").append(outQueue);
buf.append("</td> <td class=\"cells\" align=\"center\">No messages"); buf.append("</td><td class=\"cells\" align=\"center\">");
} else { if (con.getConsecutiveBacklog() > 0)
buf.append("</td> <td class=\"cells\" align=\"center\">").append(outQueue).append(" message"); buf.append("&#x2713;");
if (outQueue > 1) else
buf.append("s"); buf.append("&nbsp;");
} //long readTime = con.getReadTime();
buf.append("</td> <td class=\"cells\" align=\"center\">").append(con.getConsecutiveBacklog() > 0 ? "true" : "false"); //if (readTime <= 0) {
long readTime = con.getReadTime(); // buf.append("</td> <td class=\"cells\" align=\"center\">0");
if (readTime <= 0) { //} else {
buf.append("</td> <td class=\"cells\" align=\"center\">No"); // buf.append("</td> <td class=\"cells\" align=\"center\">").append(DataHelper.formatDuration(readTime));
} else { //}
buf.append("</td> <td class=\"cells\">For ").append(DataHelper.formatDuration(readTime));
}
buf.append("</td></tr>\n"); buf.append("</td></tr>\n");
out.write(buf.toString()); out.write(buf.toString());
buf.setLength(0); buf.setLength(0);
@ -766,13 +765,12 @@ public class NTCPTransport extends TransportImpl {
if (peers.size() > 0) { if (peers.size() > 0) {
// buf.append("<tr> <td colspan=\"11\"><hr></td></tr>\n"); // buf.append("<tr> <td colspan=\"11\"><hr></td></tr>\n");
buf.append("<tr class=\"tablefooter\"> <td align=\"center\"><b>").append(peers.size()).append(" peers</b></td> <td>&nbsp;</td> <td>&nbsp;"); buf.append("<tr class=\"tablefooter\"><td align=\"center\"><b>").append(peers.size()).append(' ').append(_("peers")).append("</b></td><td>&nbsp;</td><td>&nbsp;");
buf.append("</td> <td align=\"center\"><b>").append(formatRate(bpsRecv/1024)).append("/").append(formatRate(bpsSend/1024)).append("K/s</b>"); buf.append("</td><td align=\"center\"><b>").append(formatRate(bpsRecv/1024)).append("/").append(formatRate(bpsSend/1024)).append("</b>");
buf.append("</td><td align=\"center\"><b>").append(DataHelper.formatDuration(totalUptime/peers.size())); buf.append("</td><td align=\"center\"><b>").append(DataHelper.formatDuration(totalUptime/peers.size()));
buf.append("</b></td><td align=\"center\"><b>").append(peers.size() > 0 ? DataHelper.formatDuration(offsetTotal*1000/peers.size()) : "0ms"); buf.append("</b></td><td align=\"center\"><b>").append(peers.size() > 0 ? DataHelper.formatDuration(offsetTotal*1000/peers.size()) : "0ms");
buf.append("</b></td><td align=\"center\"><b>").append(totalSend).append("</b></td><td align=\"center\"><b>").append(totalRecv); buf.append("</b></td><td align=\"center\"><b>").append(totalSend).append("</b></td><td align=\"center\"><b>").append(totalRecv);
buf.append("</b></td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;" + buf.append("</b></td><td>&nbsp;</td><td>&nbsp;</td></tr>\n");
"</td></tr>\n");
} }
buf.append("</table>\n"); buf.append("</table>\n");
@ -818,6 +816,15 @@ public class NTCPTransport extends TransportImpl {
} }
} }
private static final String BUNDLE_NAME = "net.i2p.router.web.messages";
/**
* Translate
*/
private final String _(String s) {
return Translate.getString(s, _context, BUNDLE_NAME);
}
/** /**
* Cache the bid to reduce object churn * Cache the bid to reduce object churn
*/ */

View File

@ -37,6 +37,7 @@ import net.i2p.util.ConcurrentHashSet;
import net.i2p.util.Log; import net.i2p.util.Log;
import net.i2p.util.SimpleScheduler; import net.i2p.util.SimpleScheduler;
import net.i2p.util.SimpleTimer; import net.i2p.util.SimpleTimer;
import net.i2p.util.Translate;
/** /**
* *
@ -1834,17 +1835,22 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
} }
} }
private void appendSortLinks(StringBuilder buf, String urlBase, int sortFlags, String descr, int ascending) { private static void appendSortLinks(StringBuilder buf, String urlBase, int sortFlags, String descr, int ascending) {
if (sortFlags == ascending) { if (ascending == FLAG_ALPHA) { // 0
buf.append(" <a href=\"").append(urlBase).append("?sort=0" +
"#udpcon\" title=\"").append(descr).append("\"><img src=\"/themes/console/images/inbound.png\" alt=\"V\"></a>");
} else if (sortFlags == ascending) {
buf.append(" <a href=\"").append(urlBase).append("?sort=").append(0-ascending); buf.append(" <a href=\"").append(urlBase).append("?sort=").append(0-ascending);
buf.append("\" title=\"").append(descr).append("\">V</a><b>^</b> "); buf.append("#udpcon\" title=\"").append(descr).append("\"><img src=\"/themes/console/images/inbound.png\" alt=\"V\"></a>" +
"<b><img src=\"/themes/console/images/outbound.png\" alt=\"^\"></b>");
} else if (sortFlags == 0 - ascending) { } else if (sortFlags == 0 - ascending) {
buf.append(" <b>V</b><a href=\"").append(urlBase).append("?sort=").append(ascending); buf.append(" <b><img src=\"/themes/console/images/inbound.png\" alt=\"V\"></b><a href=\"").append(urlBase).append("?sort=").append(ascending);
buf.append("\" title=\"").append(descr).append("\">^</a> "); buf.append("#udpcon\" title=\"").append(descr).append("\"><img src=\"/themes/console/images/outbound.png\" alt=\"^\"></a>");
} else { } else {
buf.append(" <a href=\"").append(urlBase).append("?sort=").append(0-ascending); buf.append(" <a href=\"").append(urlBase).append("?sort=").append(0-ascending);
buf.append("\" title=\"").append(descr).append("\">V</a><a href=\"").append(urlBase).append("?sort=").append(ascending); buf.append("#udpcon\" title=\"").append(descr).append("\"><img src=\"/themes/console/images/inbound.png\" alt=\"V\"></a>" +
buf.append("\" title=\"").append(descr).append("\">^</a> "); "<a href=\"").append(urlBase).append("?sort=").append(ascending);
buf.append("#udpcon\" title=\"").append(descr).append("\"><img src=\"/themes/console/images/outbound.png\" alt=\"^\"></a>");
} }
} }
@ -1869,54 +1875,55 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
int numPeers = 0; int numPeers = 0;
StringBuilder buf = new StringBuilder(512); StringBuilder buf = new StringBuilder(512);
buf.append("<h3 id=\"udpcon\">UDP connections: ").append(peers.size()); buf.append("<h3 id=\"udpcon\">").append(_("UDP connections")).append(": ").append(peers.size());
buf.append(". Limit: ").append(getMaxConnections()); buf.append(". ").append(_("Limit")).append(": ").append(getMaxConnections());
buf.append(". Timeout: ").append(DataHelper.formatDuration(_expireTimeout)); buf.append(". ").append(_("Timeout")).append(": ").append(DataHelper.formatDuration(_expireTimeout));
buf.append(".</h3>\n"); buf.append(".</h3>\n");
buf.append("<table>\n"); buf.append("<table>\n");
buf.append("<tr><th class=\"smallhead\" nowrap><a href=\"#def.peer\">Peer</a>"); buf.append("<tr><th class=\"smallhead\" nowrap><a href=\"#def.peer\">").append(_("Peer")).append("</a><br>");
if (sortFlags != FLAG_ALPHA) if (sortFlags != FLAG_ALPHA)
buf.append(" <a href=\"").append(urlBase).append("?sort=0\">V</a> "); appendSortLinks(buf, urlBase, sortFlags, _("Sort by peer hash"), FLAG_ALPHA);
buf.append("</th><th class=\"smallhead\" nowrap><a href=\"#def.dir\" title=\"Direction/Introduction\">Dir</a></th><th class=\"smallhead\" nowrap><a href=\"#def.idle\">Idle</a><br>"); buf.append("</th><th class=\"smallhead\" nowrap><a href=\"#def.dir\" title=\"")
appendSortLinks(buf, urlBase, sortFlags, "Sort by idle inbound", FLAG_IDLE_IN); .append(_("Direction/Introduction")).append("\">").append(_("Dir"))
.append("</a></th><th class=\"smallhead\" nowrap><a href=\"#def.idle\">").append(_("Idle")).append("</a><br>");
appendSortLinks(buf, urlBase, sortFlags, _("Sort by idle inbound"), FLAG_IDLE_IN);
buf.append(" / "); buf.append(" / ");
appendSortLinks(buf, urlBase, sortFlags, "Sort by idle outbound", FLAG_IDLE_OUT); appendSortLinks(buf, urlBase, sortFlags, _("Sort by idle outbound"), FLAG_IDLE_OUT);
buf.append("</th>"); buf.append("</th>");
buf.append("<th class=\"smallhead\" nowrap><a href=\"#def.rate\">In/Out</a><br>"); buf.append("<th class=\"smallhead\" nowrap><a href=\"#def.rate\">").append(_("In/Out")).append("</a><br>");
appendSortLinks(buf, urlBase, sortFlags, "Sort by inbound rate", FLAG_RATE_IN); appendSortLinks(buf, urlBase, sortFlags, _("Sort by inbound rate"), FLAG_RATE_IN);
buf.append(" / "); buf.append(" / ");
appendSortLinks(buf, urlBase, sortFlags, "Sort by outbound rate", FLAG_RATE_OUT); appendSortLinks(buf, urlBase, sortFlags, _("Sort by outbound rate"), FLAG_RATE_OUT);
buf.append("</th>\n"); buf.append("</th>\n");
buf.append("<th class=\"smallhead\" nowrap><a href=\"#def.up\">Up</a><br>"); buf.append("<th class=\"smallhead\" nowrap><a href=\"#def.up\">").append(_("Up")).append("</a><br>");
appendSortLinks(buf, urlBase, sortFlags, "Sort by connection uptime", FLAG_UPTIME); appendSortLinks(buf, urlBase, sortFlags, _("Sort by connection uptime"), FLAG_UPTIME);
buf.append("</th><th class=\"smallhead\" nowrap><a href=\"#def.skew\">Skew</a><br>"); buf.append("</th><th class=\"smallhead\" nowrap><a href=\"#def.skew\">").append(_("Skew")).append("</a><br>");
appendSortLinks(buf, urlBase, sortFlags, "Sort by clock skew", FLAG_SKEW); appendSortLinks(buf, urlBase, sortFlags, _("Sort by clock skew"), FLAG_SKEW);
buf.append("</th>\n"); buf.append("</th>\n");
buf.append("<th class=\"smallhead\" nowrap><a href=\"#def.cwnd\">Cwnd</a><br>"); buf.append("<th class=\"smallhead\" nowrap><a href=\"#def.cwnd\">CWND</a><br>");
appendSortLinks(buf, urlBase, sortFlags, "Sort by congestion window", FLAG_CWND); appendSortLinks(buf, urlBase, sortFlags, _("Sort by congestion window"), FLAG_CWND);
buf.append("</th><th class=\"smallhead\" nowrap><a href=\"#def.ssthresh\">Sst</a><br>"); buf.append("</th><th class=\"smallhead\" nowrap><a href=\"#def.ssthresh\">SST</a><br>");
appendSortLinks(buf, urlBase, sortFlags, "Sort by slow start threshold", FLAG_SSTHRESH); appendSortLinks(buf, urlBase, sortFlags, _("Sort by slow start threshold"), FLAG_SSTHRESH);
buf.append("</th>\n"); buf.append("</th>\n");
buf.append("<th class=\"smallhead\" nowrap><a href=\"#def.rtt\">Rtt</a><br>"); buf.append("<th class=\"smallhead\" nowrap><a href=\"#def.rtt\">RTT</a><br>");
appendSortLinks(buf, urlBase, sortFlags, "Sort by round trip time", FLAG_RTT); appendSortLinks(buf, urlBase, sortFlags, _("Sort by round trip time"), FLAG_RTT);
buf.append("</th><th class=\"smallhead\" nowrap><a href=\"#def.dev\">Dev</a><br>"); buf.append("</th><th class=\"smallhead\" nowrap><a href=\"#def.dev\">").append(_("Dev")).append("</a><br>");
appendSortLinks(buf, urlBase, sortFlags, "Sort by round trip time deviation", FLAG_DEV); appendSortLinks(buf, urlBase, sortFlags, _("Sort by round trip time deviation"), FLAG_DEV);
buf.append("</th><th class=\"smallhead\" nowrap><a href=\"#def.rto\">Rto</a><br>"); buf.append("</th><th class=\"smallhead\" nowrap><a href=\"#def.rto\">RTO</a><br>");
appendSortLinks(buf, urlBase, sortFlags, "Sort by retransmission timeout", FLAG_RTO); appendSortLinks(buf, urlBase, sortFlags, _("Sort by retransmission timeout"), FLAG_RTO);
buf.append("</th>\n"); buf.append("</th>\n");
buf.append("<th class=\"smallhead\" nowrap><a href=\"#def.mtu\">Mtu</a><br>"); buf.append("<th class=\"smallhead\" nowrap><a href=\"#def.mtu\">MTU</a><br>");
appendSortLinks(buf, urlBase, sortFlags, "Sort by maximum transmit unit", FLAG_MTU); appendSortLinks(buf, urlBase, sortFlags, _("Sort by outbound maximum transmit unit"), FLAG_MTU);
buf.append("</th><th class=\"smallhead\" nowrap><a href=\"#def.send\">TX</a><br>"); buf.append("</th><th class=\"smallhead\" nowrap><a href=\"#def.send\">").append(_("TX")).append("</a><br>");
appendSortLinks(buf, urlBase, sortFlags, "Sort by packets sent", FLAG_SEND); appendSortLinks(buf, urlBase, sortFlags, _("Sort by packets sent"), FLAG_SEND);
buf.append("</th><th class=\"smallhead\" nowrap><a href=\"#def.recv\">RX</a><br>"); buf.append("</th><th class=\"smallhead\" nowrap><a href=\"#def.recv\">").append(_("RX")).append("</a><br>");
appendSortLinks(buf, urlBase, sortFlags, "Sort by packets received", FLAG_RECV); appendSortLinks(buf, urlBase, sortFlags, _("Sort by packets received"), FLAG_RECV);
buf.append("</th>\n"); buf.append("</th>\n");
buf.append("<th class=\"smallhead\" nowrap><a href=\"#def.resent\">ReTX</a><br>"); buf.append("<th class=\"smallhead\" nowrap><a href=\"#def.resent\">").append(_("Dup TX")).append("</a><br>");
appendSortLinks(buf, urlBase, sortFlags, "Sort by packets retransmitted", FLAG_RESEND); appendSortLinks(buf, urlBase, sortFlags, _("Sort by packets retransmitted"), FLAG_RESEND);
buf.append("</th><th class=\"smallhead\" nowrap><a href=\"#def.dupRecv\">DupRX</a><br>"); buf.append("</th><th class=\"smallhead\" nowrap><a href=\"#def.dupRecv\">").append(_("Dup RX")).append("</a><br>");
appendSortLinks(buf, urlBase, sortFlags, "Sort by packets received more than once", FLAG_DUP); appendSortLinks(buf, urlBase, sortFlags, _("Sort by packets received more than once"), FLAG_DUP);
buf.append("</th>\n"); buf.append("</th></tr>\n");
buf.append("</tr>\n");
out.write(buf.toString()); out.write(buf.toString());
buf.setLength(0); buf.setLength(0);
long now = _context.clock().now(); long now = _context.clock().now();
@ -1932,30 +1939,27 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
// buf.append(' ').append(_context.blocklist().toStr(ip)); // buf.append(' ').append(_context.blocklist().toStr(ip));
buf.append("</td><td class=\"cells\" nowrap align=\"left\">"); buf.append("</td><td class=\"cells\" nowrap align=\"left\">");
if (peer.isInbound()) if (peer.isInbound())
buf.append("<img src=\"/themes/console/images/inbound.png\" alt=\"Inbound\" title=\"Inbound\"/> "); buf.append("<img src=\"/themes/console/images/inbound.png\" alt=\"Inbound\" title=\"").append(_("Inbound")).append("\">");
else else
buf.append("<img src=\"/themes/console/images/outbound.png\" alt=\"Outbound\" title=\"Outbound\"/> "); buf.append("<img src=\"/themes/console/images/outbound.png\" alt=\"Outbound\" title=\"").append(_("Outbound")).append("\">");
if (peer.getWeRelayToThemAs() > 0) if (peer.getWeRelayToThemAs() > 0)
buf.append("^"); buf.append("&nbsp;&nbsp;<img src=\"/themes/console/images/outbound.png\" height=\"8\" width=\"12\" alt=\"^\" title=\"").append(_("We offered to introduce them")).append("\">");
else
buf.append("&nbsp;");
if (peer.getTheyRelayToUsAs() > 0) if (peer.getTheyRelayToUsAs() > 0)
buf.append("v"); buf.append("&nbsp;&nbsp;<img src=\"/themes/console/images/inbound.png\" height=\"8\" width=\"12\" alt=\"V\" title=\"").append(_("They offered to introduce us")).append("\">");
boolean appended = false; boolean appended = false;
if (_activeThrottle.isChoked(peer.getRemotePeer())) { if (_activeThrottle.isChoked(peer.getRemotePeer())) {
if (!appended) buf.append("<br>"); buf.append("<br><i>").append(_("Choked")).append("</i>");
buf.append(" <i>Choked</i>");
appended = true; appended = true;
} }
if (peer.getConsecutiveFailedSends() > 0) { if (peer.getConsecutiveFailedSends() > 0) {
if (!appended) buf.append("<br>"); if (!appended) buf.append("<br>");
buf.append(" <i>").append(peer.getConsecutiveFailedSends()).append(" fail(s)</i>"); buf.append(" <i>").append(peer.getConsecutiveFailedSends()).append(' ').append(_("fail(s)")).append("</i>");
appended = true; appended = true;
} }
if (_context.shitlist().isShitlisted(peer.getRemotePeer(), STYLE)) { if (_context.shitlist().isShitlisted(peer.getRemotePeer(), STYLE)) {
if (!appended) buf.append("<br>"); if (!appended) buf.append("<br>");
buf.append(" <i>Banned</i>"); buf.append(" <i>").append(_("Banned")).append("</i>");
appended = true; appended = true;
} }
//byte[] ip = getIP(peer.getRemotePeer()); //byte[] ip = getIP(peer.getRemotePeer());
@ -1981,7 +1985,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
buf.append(formatKBps(recvBps)); buf.append(formatKBps(recvBps));
buf.append(" / "); buf.append(" / ");
buf.append(formatKBps(sendBps)); buf.append(formatKBps(sendBps));
buf.append("K/s "); //buf.append(" K/s");
//buf.append(formatKBps(peer.getReceiveACKBps())); //buf.append(formatKBps(peer.getReceiveACKBps()));
//buf.append("K/s/"); //buf.append("K/s/");
//buf.append(formatKBps(peer.getSendACKBps())); //buf.append(formatKBps(peer.getSendACKBps()));
@ -1990,11 +1994,11 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
long uptime = now - peer.getKeyEstablishedTime(); long uptime = now - peer.getKeyEstablishedTime();
buf.append(" <td class=\"cells\" align=\"center\" >"); buf.append("<td class=\"cells\" align=\"right\">");
buf.append(DataHelper.formatDuration(uptime)); buf.append(DataHelper.formatDuration(uptime));
buf.append("</td>"); buf.append("</td>");
buf.append(" <td class=\"cells\" align=\"center\" >"); buf.append("<td class=\"cells\" align=\"right\">");
buf.append(peer.getClockSkew() / 1000); buf.append(peer.getClockSkew() / 1000);
buf.append("s</td>"); buf.append("s</td>");
offsetTotal = offsetTotal + peer.getClockSkew(); offsetTotal = offsetTotal + peer.getClockSkew();
@ -2009,7 +2013,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
buf.append(" / ").append(peer.getConsecutiveSendRejections()); buf.append(" / ").append(peer.getConsecutiveSendRejections());
buf.append("</td>"); buf.append("</td>");
buf.append(" <td class=\"cells\" align=\"center\" >"); buf.append("<td class=\"cells\" align=\"right\">");
buf.append(peer.getSlowStartThreshold()/1024); buf.append(peer.getSlowStartThreshold()/1024);
buf.append("K</td>"); buf.append("K</td>");
@ -2039,11 +2043,11 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
long sent = peer.getPacketsTransmitted(); long sent = peer.getPacketsTransmitted();
long recv = peer.getPacketsReceived(); long recv = peer.getPacketsReceived();
buf.append(" <td class=\"cells\" align=\"center\" >"); buf.append("<td class=\"cells\" align=\"right\">");
buf.append(sent); buf.append(sent);
buf.append("</td>"); buf.append("</td>");
buf.append(" <td class=\"cells\" align=\"center\" >"); buf.append("<td class=\"cells\" align=\"right\">");
buf.append(recv); buf.append(recv);
buf.append("</td>"); buf.append("</td>");
@ -2055,14 +2059,14 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
long resent = peer.getPacketsRetransmitted(); long resent = peer.getPacketsRetransmitted();
long dupRecv = peer.getPacketsReceivedDuplicate(); long dupRecv = peer.getPacketsReceivedDuplicate();
buf.append(" <td class=\"cells\" align=\"center\" >"); buf.append("<td class=\"cells\" align=\"right\">");
//buf.append(formatPct(sendLostPct)); //buf.append(formatPct(sendLostPct));
buf.append(resent); // + "/" + peer.getPacketsPeriodRetransmitted() + "/" + sent); buf.append(resent); // + "/" + peer.getPacketsPeriodRetransmitted() + "/" + sent);
//buf.append(peer.getPacketRetransmissionRate()); //buf.append(peer.getPacketRetransmissionRate());
buf.append("</td>"); buf.append("</td>");
double recvDupPct = (double)peer.getPacketsReceivedDuplicate()/(double)peer.getPacketsReceived(); double recvDupPct = (double)peer.getPacketsReceivedDuplicate()/(double)peer.getPacketsReceived();
buf.append(" <td class=\"cells\" align=\"center\" >"); buf.append("<td class=\"cells\" align=\"right\">");
buf.append(dupRecv); //formatPct(recvDupPct)); buf.append(dupRecv); //formatPct(recvDupPct));
buf.append("</td>"); buf.append("</td>");
@ -2087,24 +2091,24 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
} }
// buf.append("<tr><td colspan=\"16\"><hr></td></tr>\n"); // buf.append("<tr><td colspan=\"16\"><hr></td></tr>\n");
buf.append(" <tr class=\"tablefooter\"> <td colspan=\"3\" align=\"right\"><b>Total</b></td>"); buf.append("<tr class=\"tablefooter\"> <td colspan=\"3\" align=\"left\"><b>").append(_("SUMMARY")).append("</b></td>" +
buf.append(" <td align=\"center\" nowrap><b>"); "<td align=\"center\" nowrap><b>");
buf.append(formatKBps(bpsIn)).append(" / ").append(formatKBps(bpsOut)); buf.append(formatKBps(bpsIn)).append(" / ").append(formatKBps(bpsOut));
buf.append("K/s</b></td>"); buf.append("</b></td>" +
buf.append(" <td align=\"center\"><b>").append(numPeers > 0 ? DataHelper.formatDuration(uptimeMsTotal/numPeers) : "0s"); "<td align=\"center\"><b>").append(numPeers > 0 ? DataHelper.formatDuration(uptimeMsTotal/numPeers) : "0s");
buf.append("</b></td> <td align=\"center\"><b>").append(numPeers > 0 ? DataHelper.formatDuration(offsetTotal/numPeers) : "0ms").append("</b></td>\n"); buf.append("</b></td><td align=\"center\"><b>").append(numPeers > 0 ? DataHelper.formatDuration(offsetTotal/numPeers) : "0ms").append("</b></td>\n" +
buf.append(" <td align=\"center\"><b>"); "<td align=\"center\"><b>");
buf.append(numPeers > 0 ? cwinTotal/(numPeers*1024) + "K" : "0K"); buf.append(numPeers > 0 ? cwinTotal/(numPeers*1024) + "K" : "0K");
buf.append("</b></td> <td>&nbsp;</td>\n"); buf.append("</b></td><td>&nbsp;</td>\n" +
buf.append(" <td align=\"center\"><b>"); "<td align=\"center\"><b>");
buf.append(numPeers > 0 ? rttTotal/numPeers : 0); buf.append(numPeers > 0 ? rttTotal/numPeers : 0);
buf.append("</b></td><td>&nbsp;</td> <td align=\"center\"><b>"); buf.append("</b></td><td>&nbsp;</td> <td align=\"center\"><b>");
buf.append(numPeers > 0 ? rtoTotal/numPeers : 0); buf.append(numPeers > 0 ? rtoTotal/numPeers : 0);
buf.append("</b></td>\n <td>&nbsp;</td> <td align=\"center\"><b>"); buf.append("</b></td><td>&nbsp;</td> <td align=\"center\"><b>");
buf.append(sendTotal).append("</b></td> <td align=\"center\"><b>").append(recvTotal).append("</b></td>\n"); buf.append(sendTotal).append("</b></td> <td align=\"center\"><b>").append(recvTotal).append("</b></td>\n" +
buf.append(" <td align=\"center\"><b>").append(resentTotal); "<td align=\"center\"><b>").append(resentTotal);
buf.append("</b></td> <td align=\"center\"><b>").append(dupRecvTotal).append("</b></td>\n"); buf.append("</b></td><td align=\"center\"><b>").append(dupRecvTotal).append("</b></td>\n" +
buf.append(" </tr></table></div>\n"); "</tr></table></div>\n");
/***** /*****
long bytesTransmitted = _context.bandwidthLimiter().getTotalAllocatedOutboundBytes(); long bytesTransmitted = _context.bandwidthLimiter().getTotalAllocatedOutboundBytes();
@ -2120,7 +2124,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
out.write(buf.toString()); out.write(buf.toString());
buf.setLength(0); buf.setLength(0);
out.write(KEY); out.write(getKey());
} }
private static final DecimalFormat _fmt = new DecimalFormat("#,##0.00"); private static final DecimalFormat _fmt = new DecimalFormat("#,##0.00");
@ -2136,27 +2140,47 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
} }
} }
private static final String KEY = "<h3>Definitions</h3><div class=\"configure\">" + private final String getKey() {
"<p><b id=\"def.peer\">Peer</b>: the remote peer.<br>\n" + StringBuilder buf = new StringBuilder(1024);
"<b id=\"def.dir\">Dir</b>: v means they offer to introduce us, ^ means we offer to introduce them.<br>\n" + buf.append("<h3>").append(_("Definitions")).append("</h3><div class=\"configure\">" +
"<b id=\"def.idle\">Idle</b>: the idle time is how long since a packet has been received or sent.<br>\n" + "<p><b id=\"def.peer\">").append(_("Peer")).append("</b>: ").append(_("The remote peer, identified by router hash")).append("<br>\n" +
"<b id=\"def.rate\">In/out</b>: the rates show a smoothed inbound and outbound transfer rate (KBytes per second).<br>\n" + "<b id=\"def.dir\">").append(_("Dir")).append("</b>: " +
"<b id=\"def.up\">Up</b>: the uptime is how long ago this session was established.<br>\n" + "<img src=\"/themes/console/images/inbound.png\"> ").append(_("Inbound connection")).append("<br>\n" +
"<b id=\"def.skew\">Skew</b>: the skew says how far off the other user's clock is, relative to your own.<br>\n" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
"<b id=\"def.cwnd\">Cwnd</b>: the congestion window is how many bytes in 'in flight' you can send w/out an acknowledgement, / <br>\n" + "<img src=\"/themes/console/images/outbound.png\"> ").append(_("Outbound connection")).append("<br>\n" +
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the number of currently active messages being sent, /<br>\n" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the maximum number of concurrent messages to send, /<br>\n"+ "<img src=\"/themes/console/images/inbound.png\" alt=\"V\" height=\"8\" width=\"12\"> ").append(_("They offered to introduce us (help other peers traverse our firewall)")).append("<br>\n" +
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the number of consecutive sends which were blocked due to throws message window size.<br>\n" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
"<b id=\"def.ssthresh\">Sst</b>: the slow start threshold helps make sure the cwnd doesn't grow too fast.<br>\n" + "<img src=\"/themes/console/images/outbound.png\" alt=\"^\" height=\"8\" width=\"12\"> ").append(_("We offered to introduce them (help other peers traverse their firewall)")).append("<br>\n" +
"<b id=\"def.rtt\">Rtt</b>: the round trip time is how long it takes to get an acknowledgement of a packet.<br>\n" + "<b id=\"def.idle\">").append(_("Idle")).append("</b>: ").append(_("How long since a packet has been received / sent")).append("<br>\n" +
"<b id=\"def.dev\">Dev</b>: the standard deviation of the round trip time, to help control the retransmit timeout.<br>\n" + "<b id=\"def.rate\">").append(_("In/Out")).append("</b>: ").append(_("The smoothed inbound / outbound transfer rate (KBytes per second)")).append("<br>\n" +
"<b id=\"def.rto\">Rto</b>: the retransmit timeout controls how frequently an unacknowledged packet will be retransmitted.<br>\n" + "<b id=\"def.up\">").append(_("Up")).append("</b>: ").append(_("How long ago this connection was established")).append("<br>\n" +
"<b id=\"def.mtu\">Mtu</b>: current sending packet size / estimated receiving packet size.<br>\n" + "<b id=\"def.skew\">").append(_("Skew")).append("</b>: ").append(_("The difference between the peer's clock and your own")).append("<br>\n" +
"<b id=\"def.send\">TX</b>: the number of packets sent to the peer.<br>\n" + "<b id=\"def.cwnd\">CWND</b>: ").append(_("The congestion window, which is how many bytes can be sent without an acknowledgement")).append(" / <br>\n" +
"<b id=\"def.recv\">RX</b>: the number of packets received from the peer.<br>\n" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ").append(_("The number of sent messages awaiting acknowledgement")).append(" /<br>\n" +
"<b id=\"def.resent\">ReTX</b>: the number of packets retransmitted to the peer.<br>\n" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ").append(_("The maximum number of concurrent messages to send")).append(" /<br>\n"+
"<b id=\"def.dupRecv\">DupRX</b>: the number of duplicate packets received from the peer.</p>" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ").append(_("The number of pending sends which exceed congestion window")).append("<br>\n" +
"</div>\n"; "<b id=\"def.ssthresh\">SST</b>: ").append(_("The slow start threshold")).append("<br>\n" +
"<b id=\"def.rtt\">RTT</b>: ").append(_("The round trip time in milliseconds")).append("<br>\n" +
"<b id=\"def.dev\">").append(_("Dev")).append("</b>: ").append(_("The standard deviation of the round trip time in milliseconds")).append("<br>\n" +
"<b id=\"def.rto\">RTO</b>: ").append(_("The retransmit timeout in milliseconds")).append("<br>\n" +
"<b id=\"def.mtu\">MTU</b>: ").append(_("Current maximum send packet size / estimated maximum receive packet size (bytes)")).append("<br>\n" +
"<b id=\"def.send\">").append(_("TX")).append("</b>: ").append(_("The total number of packets sent to the peer")).append("<br>\n" +
"<b id=\"def.recv\">").append(_("RX")).append("</b>: ").append(_("The total number of packets received from the peer")).append("<br>\n" +
"<b id=\"def.resent\">").append(_("Dup TX")).append("</b>: ").append(_("The total number of packets retransmitted to the peer")).append("<br>\n" +
"<b id=\"def.dupRecv\">").append(_("Dup RX")).append("</b>: ").append(_("The total number of duplicate packets received from the peer")).append("</p>" +
"</div>\n");
return buf.toString();
}
private static final String BUNDLE_NAME = "net.i2p.router.web.messages";
/**
* Translate
*/
private final String _(String s) {
return Translate.getString(s, _context, BUNDLE_NAME);
}
/* /*
* Cache the bid to reduce object churn * Cache the bid to reduce object churn
@ -2378,6 +2402,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
} }
} }
/*******
private static final String BADIPS[] = new String[] { "192.168.0.1", "127.0.0.1", "10.3.4.5", "172.16.3.4", "224.5.6.7" }; private static final String BADIPS[] = new String[] { "192.168.0.1", "127.0.0.1", "10.3.4.5", "172.16.3.4", "224.5.6.7" };
private static final String GOODIPS[] = new String[] { "192.167.0.1", "126.0.0.1", "11.3.4.5", "172.15.3.4", "223.5.6.7" }; private static final String GOODIPS[] = new String[] { "192.167.0.1", "126.0.0.1", "11.3.4.5", "172.15.3.4", "223.5.6.7" };
public static void main(String args[]) { public static void main(String args[]) {
@ -2396,4 +2421,5 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
} catch (Exception e) { e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); }
} }
} }
*******/
} }