forked from I2P_Developers/i2p.i2p
propagate from branch 'i2p.i2p.zzz.homepage' (head 27c8ea684056ce34ea81acdfd18571776ca63641)
to branch 'i2p.i2p' (head 83f37b19742045fa42ed71a0abd8e90d080c2c05)
This commit is contained in:
@ -52,7 +52,7 @@ public class ConfigClientsHelper extends HelperBase {
|
||||
if ((mode == 0 && disabled) ||
|
||||
(mode == 1 && (!disabled) && (!ssl)) ||
|
||||
(mode == 2 && (!disabled) && ssl))
|
||||
return "checked=\"true\"";
|
||||
return "checked=\"checked\"";
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ public class ConfigClientsHelper extends HelperBase {
|
||||
public String getAuth() {
|
||||
boolean enabled = _context.getBooleanProperty(PROP_AUTH);
|
||||
if (enabled)
|
||||
return "checked=\"true\"";
|
||||
return "checked=\"checked\"";
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -253,9 +253,9 @@ public class ConfigClientsHelper extends HelperBase {
|
||||
}
|
||||
buf.append("</td><td align=\"center\" width=\"10%\"><input type=\"checkbox\" class=\"optbox\" name=\"").append(index).append(".enabled\" value=\"true\" ");
|
||||
if (enabled) {
|
||||
buf.append("checked=\"true\" ");
|
||||
buf.append("checked=\"checked\" ");
|
||||
if (ro)
|
||||
buf.append("disabled=\"true\" ");
|
||||
buf.append("disabled=\"disabled\" ");
|
||||
}
|
||||
buf.append("></td><td align=\"center\" width=\"15%\">");
|
||||
// The icons were way too much, so there's an X in each button class,
|
||||
|
@ -80,7 +80,7 @@ public class ConfigLoggingHelper extends HelperBase {
|
||||
String l = levels[i];
|
||||
buf.append("<option value=\"").append(l).append('\"');
|
||||
if (l.equals(cur))
|
||||
buf.append(" selected=\"true\"");
|
||||
buf.append(" selected=\"selected\"");
|
||||
buf.append('>').append(_(l)).append("</option>\n");
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ public class ConfigLoggingHelper extends HelperBase {
|
||||
|
||||
StringBuilder buf = new StringBuilder(65536);
|
||||
buf.append("<select name=\"newlogclass\">\n" +
|
||||
"<option value=\"\" selected=\"true\">")
|
||||
"<option value=\"\" selected=\"selected\">")
|
||||
.append(_("Select a class to add"))
|
||||
.append("</option>\n");
|
||||
|
||||
|
@ -20,8 +20,8 @@ public class ConfigNetHelper extends HelperBase {
|
||||
public final static String PROP_I2NP_NTCP_PORT = "i2np.ntcp.port";
|
||||
public final static String PROP_I2NP_NTCP_AUTO_PORT = "i2np.ntcp.autoport";
|
||||
public final static String PROP_I2NP_NTCP_AUTO_IP = "i2np.ntcp.autoip";
|
||||
private final static String CHECKED = " checked=\"true\" ";
|
||||
private final static String DISABLED = " disabled=\"true\" ";
|
||||
private final static String CHECKED = " checked=\"checked\" ";
|
||||
private final static String DISABLED = " disabled=\"disabled\" ";
|
||||
|
||||
public String getUdphostname() {
|
||||
return _context.getProperty(UDPTransport.PROP_EXTERNAL_HOST, "");
|
||||
@ -250,7 +250,7 @@ public class ConfigNetHelper extends HelperBase {
|
||||
}
|
||||
buf.append("<option style=\"text-align: right;\" value=\"").append(val).append("\" ");
|
||||
if (pct == val) {
|
||||
buf.append("selected=\"true\" ");
|
||||
buf.append("selected=\"selected\" ");
|
||||
found = true;
|
||||
}
|
||||
buf.append(">").append(val).append("%</option>\n");
|
||||
|
@ -56,7 +56,7 @@ public class ConfigReseedHelper extends HelperBase {
|
||||
if ((mode == 0 && (!disabled) && (!required)) ||
|
||||
(mode == 1 && (!disabled) && required) ||
|
||||
(mode == 2 && disabled))
|
||||
return "checked=\"true\"";
|
||||
return "checked=\"checked\"";
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ public class ConfigReseedHelper extends HelperBase {
|
||||
private String checked(String prop) {
|
||||
boolean enabled = _context.getBooleanProperty(prop);
|
||||
if (enabled)
|
||||
return "checked=\"true\"";
|
||||
return "checked=\"checked\"";
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -59,8 +59,16 @@ public class ConfigStatsHelper extends HelperBase {
|
||||
_filters.add(tok.nextToken().trim());
|
||||
}
|
||||
|
||||
public ConfigStatsHelper() {}
|
||||
|
||||
/**
|
||||
* Just hide for everybody unless already set.
|
||||
* To enable set advanced config stat.logFilters=foo before starting...
|
||||
* it has to be set at startup anyway for logging to be enabled at all
|
||||
* @since 0.9
|
||||
*/
|
||||
public boolean shouldShowLog() {
|
||||
return !_filters.isEmpty();
|
||||
}
|
||||
|
||||
public String getFilename() { return _context.statManager().getStatFile(); }
|
||||
|
||||
/**
|
||||
|
@ -172,7 +172,7 @@ public class ConfigTunnelsHelper extends HelperBase {
|
||||
if (!props.isEmpty()) {
|
||||
buf.append("<tr><td align=\"right\" class=\"mediumtags\">" + _("Inbound options") + ":</td>\n" +
|
||||
"<td colspan=\"2\" align=\"center\"><input name=\"").append(index);
|
||||
buf.append(".inboundOptions\" type=\"text\" size=\"32\" disabled=\"true\" " +
|
||||
buf.append(".inboundOptions\" type=\"text\" size=\"32\" disabled=\"disabled\" " +
|
||||
"value=\"");
|
||||
for (Iterator iter = props.keySet().iterator(); iter.hasNext(); ) {
|
||||
String prop = (String)iter.next();
|
||||
@ -185,7 +185,7 @@ public class ConfigTunnelsHelper extends HelperBase {
|
||||
if (!props.isEmpty()) {
|
||||
buf.append("<tr><td align=\"right\" class=\"mediumtags\">" + _("Outbound options") + ":</td>\n" +
|
||||
"<td colspan=\"2\" align=\"center\"><input name=\"").append(index);
|
||||
buf.append(".outboundOptions\" type=\"text\" size=\"32\" disabled=\"true\" " +
|
||||
buf.append(".outboundOptions\" type=\"text\" size=\"32\" disabled=\"disabled\" " +
|
||||
"value=\"");
|
||||
for (Iterator iter = props.keySet().iterator(); iter.hasNext(); ) {
|
||||
String prop = (String)iter.next();
|
||||
@ -205,7 +205,7 @@ public class ConfigTunnelsHelper extends HelperBase {
|
||||
for (int i = min; i <= max; i++) {
|
||||
buf.append("<option value=\"").append(i).append("\" ");
|
||||
if (i == now)
|
||||
buf.append("selected=\"true\" ");
|
||||
buf.append("selected=\"selected\" ");
|
||||
buf.append(">").append(ngettext(DUMMY1 + name, DUMMY2 + name + 's', i));
|
||||
buf.append("</option>\n");
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ public class ConfigUIHelper extends HelperBase {
|
||||
for (String theme : themes) {
|
||||
buf.append("<input type=\"radio\" class=\"optbox\" name=\"theme\" ");
|
||||
if (theme.equals(current))
|
||||
buf.append("checked=\"true\" ");
|
||||
buf.append("checked=\"checked\" ");
|
||||
buf.append("value=\"").append(theme).append("\">").append(_(theme)).append("<br>\n");
|
||||
}
|
||||
return buf.toString();
|
||||
@ -73,7 +73,7 @@ public class ConfigUIHelper extends HelperBase {
|
||||
// we use "lang" so it is set automagically in CSSHelper
|
||||
buf.append("<input type=\"radio\" class=\"optbox\" name=\"lang\" ");
|
||||
if (langs[i].equals(current))
|
||||
buf.append("checked=\"true\" ");
|
||||
buf.append("checked=\"checked\" ");
|
||||
buf.append("value=\"").append(langs[i]).append("\">")
|
||||
.append("<img height=\"11\" width=\"16\" alt=\"\" src=\"/flags.jsp?c=").append(flags[i]).append("\"> ")
|
||||
.append(_(xlangs[i])).append("<br>\n");
|
||||
|
@ -75,7 +75,7 @@ public class ConfigUpdateHelper extends HelperBase {
|
||||
public String getUpdateThroughProxy() {
|
||||
String proxy = _context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY);
|
||||
if (Boolean.valueOf(proxy).booleanValue())
|
||||
return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"updateThroughProxy\" checked=\"true\" >";
|
||||
return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"updateThroughProxy\" checked=\"checked\" >";
|
||||
else
|
||||
return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"updateThroughProxy\" >";
|
||||
}
|
||||
@ -83,7 +83,7 @@ public class ConfigUpdateHelper extends HelperBase {
|
||||
public String getUpdateUnsigned() {
|
||||
String foo = _context.getProperty(ConfigUpdateHandler.PROP_UPDATE_UNSIGNED);
|
||||
if (Boolean.valueOf(foo).booleanValue())
|
||||
return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"updateUnsigned\" checked=\"true\" >";
|
||||
return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"updateUnsigned\" checked=\"checked\" >";
|
||||
else
|
||||
return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"updateUnsigned\" >";
|
||||
}
|
||||
@ -106,7 +106,7 @@ public class ConfigUpdateHelper extends HelperBase {
|
||||
for (int i = 0; i < PERIODS.length; i++) {
|
||||
buf.append("<option value=\"").append(PERIODS[i]);
|
||||
if (PERIODS[i] == ms)
|
||||
buf.append("\" selected=\"true");
|
||||
buf.append("\" selected=\"selected");
|
||||
|
||||
if (PERIODS[i] == -1)
|
||||
buf.append("\">" + _("Never") + "</option>\n");
|
||||
@ -128,22 +128,22 @@ public class ConfigUpdateHelper extends HelperBase {
|
||||
|
||||
buf.append("<option value=\"notify\"");
|
||||
if ("notify".equals(policy) || _dontInstall)
|
||||
buf.append(" selected=\"true\"");
|
||||
buf.append(" selected=\"selected\"");
|
||||
buf.append('>').append(_("Notify only")).append("</option>");
|
||||
|
||||
buf.append("<option value=\"download\"");
|
||||
if (_dontInstall)
|
||||
buf.append(" disabled=\"true\"");
|
||||
buf.append(" disabled=\"disabled\"");
|
||||
else if ("download".equals(policy))
|
||||
buf.append(" selected=\"true\"");
|
||||
buf.append(" selected=\"selected\"");
|
||||
buf.append('>').append(_("Download and verify only")).append("</option>");
|
||||
|
||||
if (_context.hasWrapper()) {
|
||||
buf.append("<option value=\"install\"");
|
||||
if (_dontInstall)
|
||||
buf.append(" disabled=\"true\"");
|
||||
buf.append(" disabled=\"disabled\"");
|
||||
else if ("install".equals(policy))
|
||||
buf.append(" selected=\"true\"");
|
||||
buf.append(" selected=\"selected\"");
|
||||
buf.append('>').append(_("Download, verify, and restart")).append("</option>");
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ import java.util.jar.Manifest;
|
||||
|
||||
import net.i2p.crypto.SHA256Generator;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.util.FileUtil;
|
||||
|
||||
/**
|
||||
* Dump info on jars and wars
|
||||
@ -29,7 +30,7 @@ public class FileDumpHelper extends HelperBase {
|
||||
public String getFileSummary() {
|
||||
StringBuilder buf = new StringBuilder(16*1024);
|
||||
buf.append("<table><tr><th>File</th><th>Size</th><th>Date</th><th>SHA 256</th><th>Revision</th>" +
|
||||
"<th>JDK</th><th>Built</th><th>Mods</th></tr>");
|
||||
"<th>JDK</th><th>Built</th><th>By</th><th>Mods</th></tr>");
|
||||
|
||||
// jars added in wrapper.config
|
||||
URLClassLoader urlClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
|
||||
@ -95,7 +96,9 @@ public class FileDumpHelper extends HelperBase {
|
||||
buf.append((new Date(mod)).toString());
|
||||
else
|
||||
buf.append("<font color=\"red\">Not found</font>");
|
||||
buf.append("</td><td>");
|
||||
buf.append("</td><td align=\"center\">");
|
||||
if (mod > 0 && !FileUtil.verifyZip(f))
|
||||
buf.append("<font color=\"red\">CORRUPT</font><br>");
|
||||
byte[] hash = sha256(f);
|
||||
if (hash != null) {
|
||||
byte[] hh = new byte[16];
|
||||
@ -132,13 +135,17 @@ public class FileDumpHelper extends HelperBase {
|
||||
buf.append(s);
|
||||
buf.append("</td><td>");
|
||||
s = getAtt(att, "Build-Date");
|
||||
if (s != null)
|
||||
buf.append(s);
|
||||
buf.append("</td><td align=\"center\">");
|
||||
s = getAtt(att, "Built-By");
|
||||
if (s != null)
|
||||
buf.append(s);
|
||||
buf.append("</td><td><font color=\"red\">");
|
||||
s = getAtt(att, "Workspace-Changes");
|
||||
if (s != null)
|
||||
buf.append(s.replace(",", "<br>"));
|
||||
buf.append("</font></td>");
|
||||
buf.append("</font></td></tr>\n");
|
||||
}
|
||||
|
||||
private static byte[] sha256(File f) {
|
||||
|
@ -20,6 +20,8 @@ public class GraphHelper extends FormHandler {
|
||||
private int _height;
|
||||
private int _refreshDelaySeconds;
|
||||
private boolean _persistent;
|
||||
private String _stat;
|
||||
private int _end;
|
||||
|
||||
private static final String PROP_X = "routerconsole.graphX";
|
||||
private static final String PROP_Y = "routerconsole.graphY";
|
||||
@ -32,6 +34,10 @@ public class GraphHelper extends FormHandler {
|
||||
private static final int DEFAULT_PERIODS = 60;
|
||||
static final int MAX_X = 2048;
|
||||
static final int MAX_Y = 1024;
|
||||
private static final int MIN_X = 200;
|
||||
private static final int MIN_Y = 60;
|
||||
private static final int MIN_C = 20;
|
||||
private static final int MAX_C = SummaryListener.MAX_ROWS;
|
||||
private static final int MIN_REFRESH = 15;
|
||||
|
||||
/** set the defaults after we have a context */
|
||||
@ -64,17 +70,45 @@ public class GraphHelper extends FormHandler {
|
||||
public void storeWriter(Writer out) { _out = out; }
|
||||
|
||||
public void setPeriodCount(String str) {
|
||||
try { _periodCount = Integer.parseInt(str); } catch (NumberFormatException nfe) {}
|
||||
setC(str);
|
||||
}
|
||||
|
||||
public void setShowEvents(boolean b) { _showEvents = b; }
|
||||
/** @since 0.9 */
|
||||
public void setE(String str) {
|
||||
try {
|
||||
_end = Math.max(0, Integer.parseInt(str));
|
||||
} catch (NumberFormatException nfe) {}
|
||||
}
|
||||
|
||||
/** @since 0.9 shorter parameter */
|
||||
public void setC(String str) {
|
||||
try {
|
||||
_periodCount = Math.max(MIN_C, Math.min(Integer.parseInt(str), MAX_C));
|
||||
} catch (NumberFormatException nfe) {}
|
||||
}
|
||||
|
||||
public void setShowEvents(String b) { _showEvents = !"false".equals(b); }
|
||||
|
||||
public void setHeight(String str) {
|
||||
try { _height = Math.min(Integer.parseInt(str), MAX_Y); } catch (NumberFormatException nfe) {}
|
||||
setH(str);
|
||||
}
|
||||
|
||||
/** @since 0.9 shorter parameter */
|
||||
public void setH(String str) {
|
||||
try {
|
||||
_height = Math.max(MIN_Y, Math.min(Integer.parseInt(str), MAX_Y));
|
||||
} catch (NumberFormatException nfe) {}
|
||||
}
|
||||
|
||||
public void setWidth(String str) {
|
||||
try { _width = Math.min(Integer.parseInt(str), MAX_X); } catch (NumberFormatException nfe) {}
|
||||
setW(str);
|
||||
}
|
||||
|
||||
/** @since 0.9 shorter parameter */
|
||||
public void setW(String str) {
|
||||
try {
|
||||
_width = Math.max(MIN_X, Math.min(Integer.parseInt(str), MAX_X));
|
||||
} catch (NumberFormatException nfe) {}
|
||||
}
|
||||
|
||||
public void setRefreshDelay(String str) {
|
||||
@ -89,6 +123,14 @@ public class GraphHelper extends FormHandler {
|
||||
|
||||
/** @since 0.8.7 */
|
||||
public void setPersistent(String foo) { _persistent = true; }
|
||||
|
||||
/**
|
||||
* For single stat page
|
||||
* @since 0.9
|
||||
*/
|
||||
public void setStat(String stat) {
|
||||
_stat = stat;
|
||||
}
|
||||
|
||||
public String getImages() {
|
||||
if (StatSummarizer.isDisabled())
|
||||
@ -109,11 +151,11 @@ public class GraphHelper extends FormHandler {
|
||||
}
|
||||
|
||||
if (hasTx && hasRx && !_showEvents) {
|
||||
_out.write("<a href=\"viewstat.jsp?stat=bw.combined"
|
||||
_out.write("<a href=\"viewstat?stat=bw.combined"
|
||||
+ "&periodCount=" + (3 * _periodCount )
|
||||
+ "&width=" + (3 * _width)
|
||||
+ "&height=" + (3 * _height)
|
||||
+ "\" target=\"_blank\">");
|
||||
+ "\">");
|
||||
String title = _("Combined bandwidth graph");
|
||||
_out.write("<img class=\"statimage\""
|
||||
+ " src=\"viewstat.jsp?stat=bw.combined"
|
||||
@ -128,14 +170,14 @@ public class GraphHelper extends FormHandler {
|
||||
Rate r = lsnr.getRate();
|
||||
// e.g. "statname for 60m"
|
||||
String title = _("{0} for {1}", r.getRateStat().getName(), DataHelper.formatDuration2(_periodCount * r.getPeriod()));
|
||||
_out.write("<a href=\"viewstat.jsp?stat="
|
||||
_out.write("<a href=\"graph?stat="
|
||||
+ r.getRateStat().getName()
|
||||
+ "&showEvents=" + _showEvents
|
||||
+ "&period=" + r.getPeriod()
|
||||
+ "&periodCount=" + (3 * _periodCount)
|
||||
+ "&width=" + (3 * _width)
|
||||
+ "&height=" + (3 * _height)
|
||||
+ "\" target=\"_blank\">");
|
||||
+ '.' + r.getPeriod()
|
||||
+ "&c=" + (3 * _periodCount)
|
||||
+ "&w=" + (3 * _width)
|
||||
+ "&h=" + (3 * _height)
|
||||
+ (_showEvents ? "&showEvents=1" : "")
|
||||
+ "\">");
|
||||
_out.write("<img class=\"statimage\" border=\"0\""
|
||||
+ " src=\"viewstat.jsp?stat="
|
||||
+ r.getRateStat().getName()
|
||||
@ -156,6 +198,134 @@ public class GraphHelper extends FormHandler {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* For single stat page
|
||||
* @since 0.9
|
||||
*/
|
||||
public String getSingleStat() {
|
||||
try {
|
||||
if (StatSummarizer.isDisabled())
|
||||
return "";
|
||||
if (_stat == null) {
|
||||
_out.write("No stat");
|
||||
return "";
|
||||
}
|
||||
List<Rate> rates = StatSummarizer.instance().parseSpecs(_stat);
|
||||
if (rates.size() != 1) {
|
||||
_out.write("Graphs not enabled for " + _stat);
|
||||
return "";
|
||||
}
|
||||
Rate r = rates.get(0);
|
||||
_out.write("<h3>");
|
||||
_out.write(_("{0} for {1}", r.getRateStat().getName(), DataHelper.formatDuration2(_periodCount * r.getPeriod())));
|
||||
if (_end > 0)
|
||||
_out.write(' ' + _("ending {0} ago", DataHelper.formatDuration2(_end * r.getPeriod())));
|
||||
|
||||
_out.write("</h3><p><img class=\"statimage\" border=\"0\""
|
||||
+ " src=\"viewstat.jsp?stat="
|
||||
+ r.getRateStat().getName()
|
||||
+ "&showEvents=" + _showEvents
|
||||
+ "&period=" + r.getPeriod()
|
||||
+ "&periodCount=" + _periodCount
|
||||
+ "&end=" + _end
|
||||
+ "&width=" + _width
|
||||
+ "&height=" + _height
|
||||
+ "\"></p><p>\n");
|
||||
|
||||
if (_width < MAX_X && _height < MAX_Y) {
|
||||
_out.write(link(_stat, _showEvents, _periodCount, _end, _width * 3 / 2, _height * 3 / 2));
|
||||
_out.write(_("Larger"));
|
||||
_out.write("</a> - ");
|
||||
}
|
||||
|
||||
if (_width > MIN_X && _height > MIN_Y) {
|
||||
_out.write(link(_stat, _showEvents, _periodCount, _end, _width * 2 / 3, _height * 2 / 3));
|
||||
_out.write(_("Smaller"));
|
||||
_out.write("</a> - ");
|
||||
}
|
||||
|
||||
if (_height < MAX_Y) {
|
||||
_out.write(link(_stat, _showEvents, _periodCount, _end, _width, _height * 3 / 2));
|
||||
_out.write(_("Taller"));
|
||||
_out.write("</a> - ");
|
||||
}
|
||||
|
||||
if (_height > MIN_Y) {
|
||||
_out.write(link(_stat, _showEvents, _periodCount, _end, _width, _height * 2 / 3));
|
||||
_out.write(_("Shorter"));
|
||||
_out.write("</a> - ");
|
||||
}
|
||||
|
||||
if (_width < MAX_X) {
|
||||
_out.write(link(_stat, _showEvents, _periodCount, _end, _width * 3 / 2, _height));
|
||||
_out.write(_("Wider"));
|
||||
_out.write("</a> - ");
|
||||
}
|
||||
|
||||
if (_width > MIN_X) {
|
||||
_out.write(link(_stat, _showEvents, _periodCount, _end, _width * 2 / 3, _height));
|
||||
_out.write(_("Narrower"));
|
||||
_out.write("</a>");
|
||||
}
|
||||
|
||||
_out.write("<br>");
|
||||
if (_periodCount < MAX_C) {
|
||||
_out.write(link(_stat, _showEvents, _periodCount * 2, _end, _width, _height));
|
||||
_out.write(_("Larger interval"));
|
||||
_out.write("</a> - ");
|
||||
}
|
||||
|
||||
if (_periodCount > MIN_C) {
|
||||
_out.write(link(_stat, _showEvents, _periodCount / 2, _end, _width, _height));
|
||||
_out.write(_("Smaller interval"));
|
||||
_out.write("</a>");
|
||||
}
|
||||
|
||||
_out.write("<br>");
|
||||
if (_periodCount < MAX_C) {
|
||||
_out.write(link(_stat, _showEvents, _periodCount, _end + _periodCount, _width, _height));
|
||||
_out.write(_("Previous interval"));
|
||||
_out.write("</a>");
|
||||
}
|
||||
|
||||
if (_end > 0) {
|
||||
int end = _end - _periodCount;
|
||||
if (end <= 0)
|
||||
end = 0;
|
||||
if (_periodCount < MAX_C)
|
||||
_out.write(" - ");
|
||||
_out.write(link(_stat, _showEvents, _periodCount, end, _width, _height));
|
||||
_out.write(_("Next interval"));
|
||||
_out.write("</a> ");
|
||||
}
|
||||
|
||||
_out.write("<br>");
|
||||
_out.write(link(_stat, !_showEvents, _periodCount, _end, _width, _height));
|
||||
_out.write(_showEvents ? _("Plot averages") : _("plot events"));
|
||||
_out.write("</a>");
|
||||
|
||||
_out.write("</p><p><i>" + _("All times are UTC.") + "</i></p>\n");
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/** @since 0.9 */
|
||||
private static String link(String stat, boolean showEvents,
|
||||
int periodCount, int end,
|
||||
int width, int height) {
|
||||
return
|
||||
"<a href=\"graph?stat="
|
||||
+ stat
|
||||
+ "&c=" + periodCount
|
||||
+ "&w=" + width
|
||||
+ "&h=" + height
|
||||
+ (end > 0 ? "&e=" + end : "")
|
||||
+ (showEvents ? "&showEvents=1" : "")
|
||||
+ "\">";
|
||||
}
|
||||
|
||||
private static final int[] times = { 60, 2*60, 5*60, 10*60, 30*60, 60*60, -1 };
|
||||
|
||||
public String getForm() {
|
||||
@ -171,8 +341,8 @@ public class GraphHelper extends FormHandler {
|
||||
"<input type=\"hidden\" name=\"action\" value=\"foo\">\n" +
|
||||
"<input type=\"hidden\" name=\"nonce\" value=\"" + nonce + "\" >\n");
|
||||
_out.write(_("Periods") + ": <input size=\"5\" style=\"text-align: right;\" type=\"text\" name=\"periodCount\" value=\"" + _periodCount + "\"><br>\n");
|
||||
_out.write(_("Plot averages") + ": <input type=\"radio\" class=\"optbox\" name=\"showEvents\" value=\"false\" " + (_showEvents ? "" : "checked=\"true\" ") + "> ");
|
||||
_out.write(_("or")+ " " +_("plot events") + ": <input type=\"radio\" class=\"optbox\" name=\"showEvents\" value=\"true\" "+ (_showEvents ? "checked=\"true\" " : "") + "><br>\n");
|
||||
_out.write(_("Plot averages") + ": <input type=\"radio\" class=\"optbox\" name=\"showEvents\" value=\"false\" " + (_showEvents ? "" : "checked=\"checked\" ") + "> ");
|
||||
_out.write(_("or")+ " " +_("plot events") + ": <input type=\"radio\" class=\"optbox\" name=\"showEvents\" value=\"true\" "+ (_showEvents ? "checked=\"checked\" " : "") + "><br>\n");
|
||||
_out.write(_("Image sizes") + ": " + _("width") + ": <input size=\"4\" style=\"text-align: right;\" type=\"text\" name=\"width\" value=\"" + _width
|
||||
+ "\"> " + _("pixels") + ", " + _("height") + ": <input size=\"4\" style=\"text-align: right;\" type=\"text\" name=\"height\" value=\"" + _height
|
||||
+ "\"> " + _("pixels") + "<br>\n");
|
||||
@ -182,7 +352,7 @@ public class GraphHelper extends FormHandler {
|
||||
_out.write(Integer.toString(times[i]));
|
||||
_out.write("\"");
|
||||
if (times[i] == _refreshDelaySeconds)
|
||||
_out.write(" selected=\"true\"");
|
||||
_out.write(" selected=\"selected\"");
|
||||
_out.write(">");
|
||||
if (times[i] > 0)
|
||||
_out.write(DataHelper.formatDuration2(times[i] * 1000));
|
||||
@ -195,7 +365,7 @@ public class GraphHelper extends FormHandler {
|
||||
" <input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"persistent\"");
|
||||
boolean persistent = _context.getBooleanPropertyDefaultTrue(SummaryListener.PROP_PERSISTENT);
|
||||
if (persistent)
|
||||
_out.write(" checked=\"true\"");
|
||||
_out.write(" checked=\"checked\"");
|
||||
_out.write(">" +
|
||||
"<hr><div class=\"formaction\"><input type=\"submit\" class=\"acceot\" value=\"" + _("Save settings and redraw graphs") + "\"></div></form>");
|
||||
} catch (IOException ioe) {
|
||||
|
@ -33,6 +33,7 @@ import net.i2p.data.RouterInfo;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.router.TunnelPoolSettings;
|
||||
import net.i2p.router.networkdb.kademlia.HashDistance; // debug
|
||||
import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade;
|
||||
import net.i2p.util.HexDump; // debug
|
||||
import net.i2p.util.ObjectCounter;
|
||||
import net.i2p.util.OrderedProperties;
|
||||
@ -105,7 +106,10 @@ public class NetDbRenderer {
|
||||
StringBuilder buf = new StringBuilder(4*1024);
|
||||
buf.append("<h2>" + _("Network Database Contents") + "</h2>\n");
|
||||
buf.append("<a href=\"netdb\">" + _("View RouterInfo") + "</a>");
|
||||
buf.append("<h3>").append(_("LeaseSets")).append("</h3>\n");
|
||||
buf.append("<h3>").append(_("LeaseSets"));
|
||||
if (debug)
|
||||
buf.append(" - Debug mode - Sorted by hash distance, closest first");
|
||||
buf.append("</h3>\n");
|
||||
Hash ourRKey;
|
||||
Set<LeaseSet> leases;
|
||||
DecimalFormat fmt;
|
||||
@ -120,15 +124,16 @@ public class NetDbRenderer {
|
||||
}
|
||||
leases.addAll(_context.netDb().getLeases());
|
||||
int medianCount = 0;
|
||||
int rapCount = 0;
|
||||
BigInteger median = null;
|
||||
int c = 0;
|
||||
if (debug) {
|
||||
// Find the center of the RAP leasesets
|
||||
for (LeaseSet ls : leases) {
|
||||
if (ls.getReceivedAsPublished())
|
||||
medianCount++;
|
||||
rapCount++;
|
||||
}
|
||||
medianCount /= 2;
|
||||
medianCount = rapCount / 2;
|
||||
}
|
||||
long now = _context.clock().now();
|
||||
for (LeaseSet ls : leases) {
|
||||
@ -167,9 +172,10 @@ public class NetDbRenderer {
|
||||
if (c++ == medianCount)
|
||||
median = dist;
|
||||
}
|
||||
buf.append(" Dist: <b>").append(fmt.format(biLog2(dist))).append("</b>");
|
||||
buf.append(" RKey: ").append(ls.getRoutingKey().toBase64());
|
||||
buf.append(" Dist: <b>").append(fmt.format(biLog2(dist))).append("</b><br>");
|
||||
buf.append("Routing Key: ").append(ls.getRoutingKey().toBase64());
|
||||
buf.append("<br>");
|
||||
buf.append("Encryption Key: ").append(ls.getEncryptionKey().toBase64().substring(0, 20)).append("...<br>");
|
||||
}
|
||||
for (int i = 0; i < ls.getLeaseCount(); i++) {
|
||||
buf.append(_("Lease")).append(' ').append(i + 1).append(": " + _("Gateway") + ' ');
|
||||
@ -181,18 +187,23 @@ public class NetDbRenderer {
|
||||
buf.setLength(0);
|
||||
}
|
||||
if (debug) {
|
||||
buf.append("<p><b>Total Leasesets: " + leases.size());
|
||||
buf.append("</b></p><p><b>Published (RAP) Leasesets: " + _context.netDb().getKnownLeaseSets());
|
||||
FloodfillNetworkDatabaseFacade netdb = (FloodfillNetworkDatabaseFacade)_context.netDb();
|
||||
buf.append("<p><b>Total Leasesets: ").append(leases.size());
|
||||
buf.append("</b></p><p><b>Published (RAP) Leasesets: ").append(netdb.getKnownLeaseSets());
|
||||
//buf.append("</b></p><p><b>Mod Data: " + HexDump.dump(_context.routingKeyGenerator().getModData()));
|
||||
int ff = _context.peerManager().getPeersByCapability(FloodfillNetworkDatabaseFacade.CAPABILITY_FLOODFILL).size();
|
||||
buf.append("</b></p><p><b>Known Floodfills: ").append(ff);
|
||||
buf.append("</b></p><p><b>Currently Floodfill? ");
|
||||
buf.append(netdb.floodfillEnabled() ? "yes" : "no");
|
||||
buf.append("</b></p><p><b>Network data (only valid if floodfill):");
|
||||
//buf.append("</b></p><p><b>Center of Key Space (router hash): " + ourRKey.toBase64());
|
||||
if (median != null) {
|
||||
double log2 = biLog2(median);
|
||||
buf.append("</b></p><p><b>Median distance (bits): " + fmt.format(log2));
|
||||
buf.append("</b></p><p><b>Median distance (bits): ").append(fmt.format(log2));
|
||||
// 3 for 8 floodfills... -1 for median
|
||||
int total = (int) Math.round(Math.pow(2, 3 + 256 - 1 - log2));
|
||||
buf.append("</b></p><p><b>Estimated total floodfills: " + total);
|
||||
buf.append("</b></p><p><b>Estimated network total leasesets: " + (total * leases.size() / 8));
|
||||
buf.append("</b></p><p><b>Estimated total floodfills: ").append(total);
|
||||
buf.append("</b></p><p><b>Estimated total leasesets: ").append(total * rapCount / 8);
|
||||
}
|
||||
buf.append("</b></p>");
|
||||
}
|
||||
|
@ -172,32 +172,37 @@ public class StatSummarizer implements Runnable {
|
||||
|
||||
public boolean renderPng(Rate rate, OutputStream out) throws IOException {
|
||||
return renderPng(rate, out, GraphHelper.DEFAULT_X, GraphHelper.DEFAULT_Y,
|
||||
false, false, false, false, -1, true);
|
||||
false, false, false, false, -1, 0, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* This does the single data graphs.
|
||||
* For the two-data bandwidth graph see renderRatePng().
|
||||
* Synchronized to conserve memory.
|
||||
*
|
||||
* @param end number of periods before now
|
||||
* @return success
|
||||
*/
|
||||
public boolean renderPng(Rate rate, OutputStream out, int width, int height, boolean hideLegend,
|
||||
boolean hideGrid, boolean hideTitle, boolean showEvents, int periodCount,
|
||||
boolean showCredit) throws IOException {
|
||||
int end, boolean showCredit) throws IOException {
|
||||
try {
|
||||
try {
|
||||
_sem.acquire();
|
||||
} catch (InterruptedException ie) {}
|
||||
return locked_renderPng(rate, out, width, height, hideLegend, hideGrid, hideTitle, showEvents,
|
||||
periodCount, showCredit);
|
||||
periodCount, end, showCredit);
|
||||
} finally {
|
||||
_sem.release();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param end number of periods before now
|
||||
*/
|
||||
private boolean locked_renderPng(Rate rate, OutputStream out, int width, int height, boolean hideLegend,
|
||||
boolean hideGrid, boolean hideTitle, boolean showEvents, int periodCount,
|
||||
boolean showCredit) throws IOException {
|
||||
int end, boolean showCredit) throws IOException {
|
||||
if (width > GraphHelper.MAX_X)
|
||||
width = GraphHelper.MAX_X;
|
||||
else if (width <= 0)
|
||||
@ -206,9 +211,11 @@ public class StatSummarizer implements Runnable {
|
||||
height = GraphHelper.MAX_Y;
|
||||
else if (height <= 0)
|
||||
height = GraphHelper.DEFAULT_Y;
|
||||
if (end < 0)
|
||||
end = 0;
|
||||
for (SummaryListener lsnr : _listeners) {
|
||||
if (lsnr.getRate().equals(rate)) {
|
||||
lsnr.renderPng(out, width, height, hideLegend, hideGrid, hideTitle, showEvents, periodCount, showCredit);
|
||||
lsnr.renderPng(out, width, height, hideLegend, hideGrid, hideTitle, showEvents, periodCount, end, showCredit);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -368,7 +375,7 @@ public class StatSummarizer implements Runnable {
|
||||
* @param specs statName.period,statName.period,statName.period
|
||||
* @return list of Rate objects
|
||||
*/
|
||||
private List<Rate> parseSpecs(String specs) {
|
||||
List<Rate> parseSpecs(String specs) {
|
||||
StringTokenizer tok = new StringTokenizer(specs, ",");
|
||||
List<Rate> rv = new ArrayList();
|
||||
while (tok.hasMoreTokens()) {
|
||||
|
@ -55,7 +55,7 @@ class SummaryListener implements RateSummaryListener {
|
||||
|
||||
static final int PERIODS = 60 * 24; // 1440
|
||||
private static final int MIN_ROWS = PERIODS;
|
||||
private static final int MAX_ROWS = 91 * MIN_ROWS;
|
||||
static final int MAX_ROWS = 91 * MIN_ROWS;
|
||||
private static final long THREE_MONTHS = 91l * 24 * 60 * 60 * 1000;
|
||||
|
||||
public SummaryListener(Rate r) {
|
||||
@ -191,10 +191,15 @@ class SummaryListener implements RateSummaryListener {
|
||||
_db = null;
|
||||
}
|
||||
|
||||
public void renderPng(OutputStream out, int width, int height, boolean hideLegend, boolean hideGrid, boolean hideTitle, boolean showEvents, int periodCount, boolean showCredit) throws IOException {
|
||||
/**
|
||||
* @param end number of periods before now
|
||||
*/
|
||||
public void renderPng(OutputStream out, int width, int height, boolean hideLegend, boolean hideGrid,
|
||||
boolean hideTitle, boolean showEvents, int periodCount,
|
||||
int end, boolean showCredit) throws IOException {
|
||||
if (_renderer == null || _db == null)
|
||||
throw new IOException("No RRD, check logs for previous errors");
|
||||
_renderer.render(out, width, height, hideLegend, hideGrid, hideTitle, showEvents, periodCount, showCredit);
|
||||
_renderer.render(out, width, height, hideLegend, hideGrid, hideTitle, showEvents, periodCount, end, showCredit);
|
||||
}
|
||||
|
||||
public void renderPng(OutputStream out) throws IOException {
|
||||
|
@ -81,13 +81,21 @@ class SummaryRenderer {
|
||||
}
|
||||
|
||||
public void render(OutputStream out) throws IOException { render(out, GraphHelper.DEFAULT_X, GraphHelper.DEFAULT_Y,
|
||||
false, false, false, false, -1, false); }
|
||||
false, false, false, false, -1, 0, false); }
|
||||
|
||||
public void render(OutputStream out, int width, int height, boolean hideLegend, boolean hideGrid, boolean hideTitle, boolean showEvents, int periodCount, boolean showCredit) throws IOException {
|
||||
/**
|
||||
* @param endp number of periods before now
|
||||
*/
|
||||
public void render(OutputStream out, int width, int height, boolean hideLegend, boolean hideGrid,
|
||||
boolean hideTitle, boolean showEvents, int periodCount,
|
||||
int endp, boolean showCredit) throws IOException {
|
||||
long end = _listener.now() - 75*1000;
|
||||
long period = _listener.getRate().getPeriod();
|
||||
if (endp > 0)
|
||||
end -= period * endp;
|
||||
if (periodCount <= 0 || periodCount > _listener.getRows())
|
||||
periodCount = _listener.getRows();
|
||||
long start = end - _listener.getRate().getPeriod()*periodCount;
|
||||
long start = end - (period * periodCount);
|
||||
//long begin = System.currentTimeMillis();
|
||||
try {
|
||||
RrdGraphDef def = new RrdGraphDef();
|
||||
@ -103,9 +111,9 @@ class SummaryRenderer {
|
||||
String p;
|
||||
// we want the formatting and translation of formatDuration2(), except not zh, and not the
|
||||
if (IS_WIN && "zh".equals(Messages.getLanguage(_context)))
|
||||
p = DataHelper.formatDuration(_listener.getRate().getPeriod());
|
||||
p = DataHelper.formatDuration(period);
|
||||
else
|
||||
p = DataHelper.formatDuration2(_listener.getRate().getPeriod()).replace(" ", " ");
|
||||
p = DataHelper.formatDuration2(period).replace(" ", " ");
|
||||
if (showEvents)
|
||||
title = name + ' ' + _("events in {0}", p);
|
||||
else
|
||||
|
@ -134,6 +134,7 @@ public class TunnelRenderer {
|
||||
out.write("<div class=\"statusnotes\"><b>" + _("Inactive participating tunnels") + ": " + inactive + "</b></div>\n");
|
||||
out.write("<div class=\"statusnotes\"><b>" + _("Lifetime bandwidth usage") + ": " + DataHelper.formatSize2(processed*1024) + "B</b></div>\n");
|
||||
//renderPeers(out);
|
||||
out.write("</div>");
|
||||
}
|
||||
|
||||
private static class TunnelComparator implements Comparator<HopConfig> {
|
||||
@ -222,7 +223,7 @@ public class TunnelRenderer {
|
||||
}
|
||||
}
|
||||
if (live <= 0)
|
||||
out.write("<div class=\"statusnotes\"><center><b>" + _("No tunnels; waiting for the grace period to end.") + "</center></b></div>\n");
|
||||
out.write("<div class=\"statusnotes\"><center><b>" + _("No tunnels; waiting for the grace period to end.") + "</b></center></div>\n");
|
||||
out.write("<div class=\"statusnotes\"><center><b>" + _("Lifetime bandwidth usage") + ": " +
|
||||
DataHelper.formatSize2(processedIn*1024) + "B " + _("in") + ", " +
|
||||
DataHelper.formatSize2(processedOut*1024) + "B " + _("out") + "</b></center></div>");
|
||||
|
Reference in New Issue
Block a user