* Console:

- countries.txt: Convert to mixed case, include in update
      - netdb.jsp: Hide all routers by default, sort and tag country names
      - oldstats.jsp: Move to stats.jsp
      - profiles.jsp: Show new DBH times instead of counts
    * Profiles:
      - Track last good and bad lookup times
        and last good and bad store times,
        to prep for floodfill changes
      - Don't reset last-heard-about at router startup
    * Checklist and Android readme fixups
This commit is contained in:
zzz
2009-11-07 19:32:00 +00:00
parent 827a92ef2f
commit a0b4b7db86
18 changed files with 442 additions and 312 deletions

View File

@ -19,6 +19,20 @@ CLASS=net.i2p.router.web.messages
TMPFILE=build/javafiles.txt
export TZ=UTC
#
# generate strings/Countries.java from ../../../installer/resources/countries.txt
#
CFILE=../../../installer/resources/countries.txt
JFILE=build/Countries.java
if [ $CFILE -nt $JFILE -o ! -s $JFILE ]
then
mkdir -p build
echo '// Automatically generated pseudo-java for xgettext - do not edit' > $JFILE
echo '// Translators may wish to translate a few of these, do not bother to translate all of them!!' >> $JFILE
sed 's/..,\(..*\)/_("\1");/' $CFILE >> $JFILE
fi
JPATHS="src ../jsp/WEB-INF strings $JFILE"
for i in ../locale/messages_*.po
do
# get language
@ -26,7 +40,7 @@ do
LG=${LG%.po}
# make list of java files newer than the .po file
find src ../jsp/WEB-INF strings -name *.java -newer $i > $TMPFILE
find $JPATHS -name *.java -newer $i > $TMPFILE
if [ -s build/obj/net/i2p/router/web/messages_$LG.class -a \
build/obj/net/i2p/router/web/messages_$LG.class -nt $i -a \
! -s $TMPFILE ]
@ -48,7 +62,7 @@ do
# In a jsp, you must use a helper or handler that has the context set.
# To start a new translation, copy the header from an old translation to the new .po file,
# then ant distclean updater.
find src ../jsp/WEB-INF strings -name *.java > $TMPFILE
find $JPATHS -name *.java > $TMPFILE
xgettext -f $TMPFILE -F -L java --from-code=UTF-8 \
--keyword=_ --keyword=_x --keyword=intl._ --keyword=intl.title \
--keyword=handler._ --keyword=formhandler._ \

View File

@ -8,6 +8,20 @@ CLASS=net.i2p.router.web.messages
TMPFILE=build/javafiles.txt
export TZ=UTC
#
# generate strings/Countries.java from ../../../installer/resources/countries.txt
#
CFILE=../../../installer/resources/countries.txt
JFILE=build/Countries.java
if [ $CFILE -nt $JFILE -o ! -s $JFILE ]
then
mkdir -p build
echo '// Automatically generated pseudo-java for xgettext - do not edit' > $JFILE
echo '// Translators may wish to translate a few of these, do not bother to translate all of them!!' >> $JFILE
sed 's/..,\(..*\)/_("\1");/' $CFILE >> $JFILE
fi
JPATHS="src ../jsp/WEB-INF strings $JFILE"
for i in ../locale/messages_*.po
do
# get language
@ -15,7 +29,7 @@ do
LG=${LG%.po}
# make list of java files newer than the .po file
find src ../jsp/WEB-INF strings -name *.java -newer $i > $TMPFILE
find $JPATHS -name *.java -newer $i > $TMPFILE
if [ -s build/obj/net/i2p/router/web/messages_$LG.class -a \
build/obj/net/i2p/router/web/messages_$LG.class -nt $i -a \
! -s $TMPFILE ]
@ -37,7 +51,7 @@ do
# In a jsp, you must use a helper or handler that has the context set.
# To start a new translation, copy the header from an old translation to the new .po file,
# then ant distclean updater.
find src ../jsp/WEB-INF strings -name *.java > $TMPFILE
find $JPATHS -name *.java > $TMPFILE
xgettext -f $TMPFILE -F -L java --from-code=UTF-8 \
--keyword=_ --keyword=_x --keyword=intl._ --keyword=intl.title \
--keyword=handler._ --keyword=formhandler._ \

View File

@ -7,13 +7,17 @@ import java.io.OutputStreamWriter;
public class NetDbHelper extends HelperBase {
private String _routerPrefix;
private boolean _full = false;
private int _full;
private boolean _lease = false;
public NetDbHelper() {}
public void setRouter(String r) { _routerPrefix = r; }
public void setFull(String f) { _full = "1".equals(f); }
public void setFull(String f) {
try {
_full = Integer.parseInt(f);
} catch (NumberFormatException nfe) {}
}
public void setLease(String l) { _lease = "1".equals(l); }
public String getNetDbSummary() {

View File

@ -77,10 +77,6 @@ public class NetDbRenderer {
out.flush();
}
public void renderStatusHTML(Writer out) throws IOException {
renderStatusHTML(out, true);
}
public void renderLeaseSetHTML(Writer out) throws IOException {
StringBuilder buf = new StringBuilder(4*1024);
buf.append("<h2>" + _("Network Database Contents") + "</h2>\n");
@ -131,7 +127,10 @@ public class NetDbRenderer {
out.flush();
}
public void renderStatusHTML(Writer out, boolean full) throws IOException {
/**
* @param mode 0: our info and charts only; 1: full routerinfos and charts; 2: abbreviated routerinfos and charts
*/
public void renderStatusHTML(Writer out, int mode) throws IOException {
out.write("<h2>" + _("Network Database Contents") + " (<a href=\"netdb.jsp?l=1\">" + _("View LeaseSets") + "</a>)</h2>\n");
if (!_context.netDb().isInitialized()) {
out.write(_("Not initialized"));
@ -139,13 +138,16 @@ public class NetDbRenderer {
return;
}
boolean full = mode == 1;
boolean shortStats = mode == 2;
boolean showStats = full || shortStats;
Hash us = _context.routerHash();
out.write("<a name=\"routers\" ></a><h3>" + _("Routers") + " (<a href=\"netdb.jsp");
if (full)
out.write("#routers\" >" + _("view without"));
if (full || !showStats)
out.write("?f=2#routers\" >" + _("Show all routers"));
else
out.write("?f=1#routers\" >" + _("view with"));
out.write(' ' + _("stats") + "</a>)</h3>\n");
out.write("?f=1#routers\" >" + _("Show all routers with full stats"));
out.write("</a>)</h3>\n");
StringBuilder buf = new StringBuilder(8192);
RouterInfo ourInfo = _context.router().getRouterInfo();
@ -163,9 +165,11 @@ public class NetDbRenderer {
Hash key = ri.getIdentity().getHash();
boolean isUs = key.equals(us);
if (!isUs) {
renderRouterInfo(buf, ri, false, full);
out.write(buf.toString());
buf.setLength(0);
if (showStats) {
renderRouterInfo(buf, ri, false, full);
out.write(buf.toString());
buf.setLength(0);
}
String routerVersion = ri.getOption("router.version");
if (routerVersion != null)
versions.increment(routerVersion);
@ -194,14 +198,14 @@ public class NetDbRenderer {
List<String> countryList = new ArrayList(countries.objects());
if (countryList.size() > 0) {
Collections.sort(countryList);
Collections.sort(countryList, new CountryComparator());
buf.append("<table>\n");
buf.append("<tr><th align=\"left\">" + _("Country") + "</th><th>" + _("Count") + "</th></tr>\n");
for (String country : countryList) {
int num = countries.count(country);
buf.append("<tr><td><img height=\"11\" width=\"16\" alt=\"").append(country.toUpperCase()).append("\"");
buf.append(" src=\"/flags.jsp?c=").append(country).append("\"> ");
buf.append(_context.commSystem().getCountryName(country));
buf.append(_(_context.commSystem().getCountryName(country)));
buf.append("</td><td align=\"center\">").append(num).append("</td></tr>\n");
}
buf.append("</table>\n");
@ -211,6 +215,14 @@ public class NetDbRenderer {
out.flush();
}
/** sort by translated country name */
private class CountryComparator implements Comparator {
public int compare(Object l, Object r) {
return _(_context.commSystem().getCountryName((String)l))
.compareTo(_(_context.commSystem().getCountryName((String)r)));
}
}
/**
* Be careful to use stripHTML for any displayed routerInfo data
* to prevent vulnerabilities

View File

@ -171,28 +171,24 @@ class ProfileOrganizerRenderer {
buf.append("<h2>").append(_("Floodfill and Integrated Peers")).append("</h2>\n");
buf.append("<table>");
buf.append("<tr>");
buf.append("<th class=\"smallhead\">Peer</th>");
buf.append("<th class=\"smallhead\">Caps</th>");
buf.append("<th class=\"smallhead\">Integ. Value</th>");
buf.append("<th class=\"smallhead\">Last Heard About</th>");
buf.append("<th class=\"smallhead\">Last Heard From</th>");
// "<th class=\"smallhead\">Last Successful Send</th>" +
buf.append("<th class=\"smallhead\">Last Good Send</th>");
// "<th class=\"smallhead\">Last Failed Send</th>" +
buf.append("<th class=\"smallhead\">Last Bad Send</th>");
buf.append("<th class=\"smallhead\">10m Resp. Time</th>");
buf.append("<th class=\"smallhead\">1h Resp. Time</th>");
buf.append("<th class=\"smallhead\">1d Resp. Time</th>");
// "<th class=\"smallhead\">Successful Lookups</th>" +
buf.append("<th class=\"smallhead\">Good Lookups</th>");
// "<th>Failed Lookups</th>" +
buf.append("<th class=\"smallhead\">Bad Lookups</th>");
buf.append("<th class=\"smallhead\">New Stores</th>");
buf.append("<th class=\"smallhead\">Old Stores</th>");
buf.append("<th class=\"smallhead\">1h Fail Rate</th>");
buf.append("<th class=\"smallhead\">1d Fail Rate</th>");
buf.append("</tr>");
buf.append("<tr>");
buf.append("<th class=\"smallhead\">").append(_("Peer")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("Caps")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("Integ. Value")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("Last Heard About")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("Last Heard From")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("Last Good Send")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("Last Bad Send")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("10m Resp. Time")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("1h Resp. Time")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("1d Resp. Time")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("Last Good Lookup")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("Last Bad Lookup")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("Last Good Store")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("Last Bad Store")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("1h Fail Rate")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("1d Fail Rate")).append("</th>");
buf.append("</tr>");
for (Iterator iter = integratedPeers.iterator(); iter.hasNext();) {
PeerProfile prof = (PeerProfile)iter.next();
Hash peer = prof.getPeer();
@ -221,10 +217,14 @@ class ProfileOrganizerRenderer {
buf.append("<td align=\"right\">").append(avg(prof, 24*60*60*1000l)).append("</td>");
DBHistory dbh = prof.getDBHistory();
if (dbh != null) {
buf.append("<td align=\"right\">").append(dbh.getSuccessfulLookups()).append("</td>");
buf.append("<td align=\"right\">").append(dbh.getFailedLookups()).append("</td>");
buf.append("<td align=\"right\">").append(dbh.getUnpromptedDbStoreNew()).append("</td>");
buf.append("<td align=\"right\">").append(dbh.getUnpromptedDbStoreOld()).append("</td>");
time = now - dbh.getLastLookupSuccessful();
buf.append("<td align=\"right\">").append(DataHelper.formatDuration(time)).append("</td>");
time = now - dbh.getLastLookupFailed();
buf.append("<td align=\"right\">").append(DataHelper.formatDuration(time)).append("</td>");
time = now - dbh.getLastStoreSuccessful();
buf.append("<td align=\"right\">").append(DataHelper.formatDuration(time)).append("</td>");
time = now - dbh.getLastStoreFailed();
buf.append("<td align=\"right\">").append(DataHelper.formatDuration(time)).append("</td>");
buf.append("<td align=\"right\">").append(davg(dbh, 60*60*1000l)).append("</td>");
buf.append("<td align=\"right\">").append(davg(dbh, 24*60*60*1000l)).append("</td>");
} else {
@ -242,13 +242,13 @@ class ProfileOrganizerRenderer {
buf.append("<b>").append(_("Integration")).append(":</b> ").append(num(_organizer.getIntegrationThreshold()))
.append(" (").append(integrated).append(' ').append(_(" well integrated peers")).append(")</p>");
buf.append("<h3>").append(_("Definitions")).append(":</h3><ul>");
buf.append("<li><b>").append(_("groups")).append("</b>: ").append(_("as determined by the profile organizer")).append("</li>");
buf.append("<li><b>").append(_("caps")).append("</b>: ").append(_("capabilities in the netDb, not used to determine profiles")).append("</li>");
buf.append("<li><b>").append(_("speed")).append("</b>: ").append(_("peak throughput (bytes per second) over a 1 minute period that the peer has sustained in a single tunnel")).append("</li>");
buf.append("<li><b>").append(_("capacity")).append("</b>: ").append(_("how many tunnels can we ask them to join in an hour?")).append("</li>");
buf.append("<li><b>").append(_("integration")).append("</b>: ").append(_("how many new peers have they told us about lately?")).append("</li>");
buf.append("<li><b>").append(_("status")).append("</b>: ").append(_("is the peer banned, or unreachable, or failing tunnel tests?")).append("</li>");
buf.append("</ul></i>");
buf.append("<li><b>").append(_("groups")).append("</b>: ").append(_("as determined by the profile organizer")).append("</li>");
buf.append("<li><b>").append(_("caps")).append("</b>: ").append(_("capabilities in the netDb, not used to determine profiles")).append("</li>");
buf.append("<li><b>").append(_("speed")).append("</b>: ").append(_("peak throughput (bytes per second) over a 1 minute period that the peer has sustained in a single tunnel")).append("</li>");
buf.append("<li><b>").append(_("capacity")).append("</b>: ").append(_("how many tunnels can we ask them to join in an hour?")).append("</li>");
buf.append("<li><b>").append(_("integration")).append("</b>: ").append(_("how many new peers have they told us about lately?")).append("</li>");
buf.append("<li><b>").append(_("status")).append("</b>: ").append(_("is the peer banned, or unreachable, or failing tunnel tests?")).append("</li>");
buf.append("</ul></i>");
out.write(buf.toString());
out.flush();
}

View File

@ -29,7 +29,7 @@ public class StatsGenerator {
public void generateStatsPage(Writer out) throws IOException {
StringBuilder buf = new StringBuilder(16*1024);
buf.append("<div class=\"joblog\"><form action=\"/oldstats.jsp\">");
buf.append("<div class=\"joblog\"><form action=\"/stats.jsp\">");
buf.append("<select name=\"go\" onChange='location.href=this.value'>");
out.write(buf.toString());
buf.setLength(0);
@ -39,11 +39,11 @@ public class StatsGenerator {
Map.Entry entry = (Map.Entry)iter.next();
String group = (String)entry.getKey();
Set stats = (Set)entry.getValue();
buf.append("<option value=\"/oldstats.jsp#").append(group).append("\">");
buf.append("<option value=\"/stats.jsp#").append(group).append("\">");
buf.append(group).append("</option>\n");
for (Iterator statIter = stats.iterator(); statIter.hasNext(); ) {
String stat = (String)statIter.next();
buf.append("<option value=\"/oldstats.jsp#");
buf.append("<option value=\"/stats.jsp#");
buf.append(stat);
buf.append("\">...");
buf.append(stat);

View File

@ -118,7 +118,7 @@ public class SummaryBarRenderer {
.append(_("Graphs"))
.append("</a>\n" +
"<a href=\"oldstats.jsp\" target=\"_top\" title=\"")
"<a href=\"stats.jsp\" target=\"_top\" title=\"")
.append(_("Textual router performance statistics"))
.append("\">")
.append(_("Stats"))