forked from I2P_Developers/i2p.i2p
propagate from branch 'i2p.i2p.str4d.fux' (head 48cafeb29fb3408078a8b93c0bab0fc9d766a8bc)
to branch 'i2p.i2p' (head 47f04ff21e8edd00134a0fd68219f86fd3caba36)
This commit is contained in:
@ -19,6 +19,8 @@ public class CSSHelper extends HelperBase {
|
||||
private static final String FORCE = "classic";
|
||||
public static final String PROP_REFRESH = "routerconsole.summaryRefresh";
|
||||
public static final String DEFAULT_REFRESH = "60";
|
||||
public static final int MIN_REFRESH = 3;
|
||||
public static final String PROP_DISABLE_REFRESH = "routerconsole.summaryDisableRefresh";
|
||||
private static final String PROP_XFRAME = "routerconsole.disableXFrame";
|
||||
|
||||
public String getTheme(String userAgent) {
|
||||
@ -70,12 +72,42 @@ public class CSSHelper extends HelperBase {
|
||||
|
||||
/** change refresh and save it */
|
||||
public void setRefresh(String r) {
|
||||
try {
|
||||
if (Integer.parseInt(r) < MIN_REFRESH)
|
||||
r = "" + MIN_REFRESH;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
_context.router().saveConfig(PROP_REFRESH, r);
|
||||
}
|
||||
|
||||
/** @return refresh time in seconds, as a string */
|
||||
public String getRefresh() {
|
||||
return _context.getProperty(PROP_REFRESH, DEFAULT_REFRESH);
|
||||
String r = _context.getProperty(PROP_REFRESH, DEFAULT_REFRESH);
|
||||
try {
|
||||
if (Integer.parseInt(r) < MIN_REFRESH)
|
||||
r = "" + MIN_REFRESH;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* change disable refresh boolean and save it
|
||||
* @since 0.9.1
|
||||
*/
|
||||
public void setDisableRefresh(String r) {
|
||||
String disableRefresh = "false";
|
||||
if ("0".equals(r))
|
||||
disableRefresh = "true";
|
||||
_context.router().saveConfig(PROP_DISABLE_REFRESH, disableRefresh);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if refresh is disabled
|
||||
* @since 0.9.1
|
||||
*/
|
||||
public boolean getDisableRefresh() {
|
||||
return _context.getBooleanProperty(PROP_DISABLE_REFRESH);
|
||||
}
|
||||
|
||||
/** translate the title and display consistently */
|
||||
|
@ -11,12 +11,12 @@ public class ConfigNavHelper extends HelperBase {
|
||||
|
||||
/** configX.jsp */
|
||||
private static final String pages[] =
|
||||
{"", "net", "ui", "home", "service", "update", "tunnels",
|
||||
{"", "net", "ui", "sidebar", "home", "service", "update", "tunnels",
|
||||
"clients", "peer", "keyring", "logging", "stats",
|
||||
"reseed", "advanced" };
|
||||
|
||||
private static final String titles[] =
|
||||
{_x("Bandwidth"), _x("Network"), _x("UI"), _x("Home Page"),
|
||||
{_x("Bandwidth"), _x("Network"), _x("UI"), _x("Summary Bar"), _x("Home Page"),
|
||||
_x("Service"), _x("Update"), _x("Tunnels"),
|
||||
_x("Clients"), _x("Peers"), _x("Keyring"), _x("Logging"), _x("Stats"),
|
||||
_x("Reseeding"), _x("Advanced") };
|
||||
|
@ -0,0 +1,168 @@
|
||||
package net.i2p.router.web;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.i2p.data.DataHelper;
|
||||
|
||||
/**
|
||||
* Simple summary bar configuration.
|
||||
*
|
||||
* @since 0.9.1
|
||||
*/
|
||||
public class ConfigSummaryHandler extends FormHandler {
|
||||
|
||||
private Map _settings;
|
||||
|
||||
@Override
|
||||
protected void processForm() {
|
||||
if (_action == null) return;
|
||||
String group = getJettyString("group");
|
||||
boolean deleting = _action.equals(_("Delete selected"));
|
||||
boolean adding = _action.equals(_("Add item"));
|
||||
boolean saving = _action.equals(_("Save order"));
|
||||
boolean moving = _action.startsWith("move_");
|
||||
if (_action.equals(_("Save")) && "0".equals(group)) {
|
||||
try {
|
||||
int refreshInterval = Integer.parseInt(getJettyString("refreshInterval"));
|
||||
if (refreshInterval >= CSSHelper.MIN_REFRESH) {
|
||||
_context.router().saveConfig(CSSHelper.PROP_REFRESH, "" + refreshInterval);
|
||||
addFormNotice(_("Refresh interval changed"));
|
||||
} else
|
||||
addFormError(_("Refresh interval must be at least {0} seconds", CSSHelper.MIN_REFRESH));
|
||||
} catch (java.lang.NumberFormatException e) {
|
||||
addFormError(_("Refresh interval must be a number"));
|
||||
return;
|
||||
}
|
||||
} else if (_action.equals(_("Restore full default"))) {
|
||||
_context.router().saveConfig(SummaryHelper.PROP_SUMMARYBAR + "default", SummaryHelper.DEFAULT_FULL);
|
||||
addFormNotice(_("Full summary bar default restored.") + " " +
|
||||
_("Summary bar will refresh shortly."));
|
||||
} else if (_action.equals(_("Restore minimal default"))) {
|
||||
_context.router().saveConfig(SummaryHelper.PROP_SUMMARYBAR + "default", SummaryHelper.DEFAULT_MINIMAL);
|
||||
addFormNotice(_("Minimal summary bar default restored.") + " " +
|
||||
_("Summary bar will refresh shortly."));
|
||||
} else if (adding || deleting || saving || moving) {
|
||||
Map<Integer, String> sections = new TreeMap<Integer, String>();
|
||||
for (Object o : _settings.keySet()) {
|
||||
if (!(o instanceof String))
|
||||
continue;
|
||||
String k = (String) o;
|
||||
if (!k.startsWith("order_"))
|
||||
continue;
|
||||
String v = getJettyString(k);
|
||||
k = k.substring(6);
|
||||
k = k.substring(k.indexOf('_') + 1);
|
||||
try {
|
||||
int order = Integer.parseInt(v);
|
||||
sections.put(order, k);
|
||||
} catch (java.lang.NumberFormatException e) {
|
||||
addFormError(_("Order must be an integer"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (adding) {
|
||||
String name = getJettyString("name");
|
||||
if (name == null || name.length() <= 0) {
|
||||
addFormError(_("No section selected"));
|
||||
return;
|
||||
}
|
||||
String order = getJettyString("order");
|
||||
if (order == null || order.length() <= 0) {
|
||||
addFormError(_("No order entered"));
|
||||
return;
|
||||
}
|
||||
name = DataHelper.escapeHTML(name).replace(",", ",");
|
||||
order = DataHelper.escapeHTML(order).replace(",", ",");
|
||||
try {
|
||||
int ki = Integer.parseInt(order);
|
||||
sections.put(ki, name);
|
||||
addFormNotice(_("Added") + ": " + name);
|
||||
} catch (java.lang.NumberFormatException e) {
|
||||
addFormError(_("Order must be an integer"));
|
||||
return;
|
||||
}
|
||||
} else if (deleting) {
|
||||
Set<Integer> toDelete = new HashSet();
|
||||
for (Object o : _settings.keySet()) {
|
||||
if (!(o instanceof String))
|
||||
continue;
|
||||
String k = (String) o;
|
||||
if (!k.startsWith("delete_"))
|
||||
continue;
|
||||
k = k.substring(7);
|
||||
try {
|
||||
int ki = Integer.parseInt(k);
|
||||
toDelete.add(ki);
|
||||
} catch (java.lang.NumberFormatException e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
for (Iterator<Integer> iter = sections.keySet().iterator(); iter.hasNext(); ) {
|
||||
int i = iter.next();
|
||||
if (toDelete.contains(i)) {
|
||||
String removedName = sections.get(i);
|
||||
iter.remove();
|
||||
addFormNotice(_("Removed") + ": " + removedName);
|
||||
}
|
||||
}
|
||||
} else if (moving) {
|
||||
String parts[] = _action.split("_");
|
||||
try {
|
||||
int from = Integer.parseInt(parts[1]);
|
||||
int to = 0;
|
||||
if ("up".equals(parts[2]))
|
||||
to = from - 1;
|
||||
if ("down".equals(parts[2]))
|
||||
to = from + 1;
|
||||
if ("bottom".equals(parts[2]))
|
||||
to = sections.size() - 1;
|
||||
int n = -1;
|
||||
if ("down".equals(parts[2]) || "bottom".equals(parts[2]))
|
||||
n = 1;
|
||||
for (int i = from; n * i < n * to; i += n) {
|
||||
String temp = sections.get(i + n);
|
||||
sections.put(i + n, sections.get(i));
|
||||
sections.put(i, temp);
|
||||
}
|
||||
addFormNotice(_("Moved") + ": " + sections.get(to));
|
||||
} catch (java.lang.NumberFormatException e) {
|
||||
addFormError(_("Order must be an integer"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
SummaryHelper.saveSummaryBarSections(_context, "default", sections);
|
||||
addFormNotice(_("Saved order of sections.") + " " +
|
||||
_("Summary bar will refresh shortly."));
|
||||
} else {
|
||||
addFormError(_("Unsupported"));
|
||||
}
|
||||
}
|
||||
|
||||
public void setSettings(Map settings) { _settings = new HashMap(settings); }
|
||||
|
||||
/** curses Jetty for returning arrays */
|
||||
private String getJettyString(String key) {
|
||||
String[] arr = (String[]) _settings.get(key);
|
||||
if (arr == null)
|
||||
return null;
|
||||
return arr[0].trim();
|
||||
}
|
||||
|
||||
public void setMovingAction() {
|
||||
for (Object o : _settings.keySet()) {
|
||||
if (!(o instanceof String))
|
||||
continue;
|
||||
String k = (String) o;
|
||||
if (k.startsWith("move_") && k.endsWith(".x") && _settings.get(k) != null) {
|
||||
_action = k.substring(0, k.length() - 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -191,7 +191,8 @@ public class GraphHelper extends FormHandler {
|
||||
}
|
||||
|
||||
// FIXME jrobin doesn't support setting the timezone, will have to mod TimeAxis.java
|
||||
_out.write("<p><i>" + _("All times are UTC.") + "</i></p>\n");
|
||||
// 0.9.1 - all graphs currently state UTC on them, so this text blurb is unnecessary,
|
||||
//_out.write("<p><i>" + _("All times are UTC.") + "</i></p>\n");
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
|
@ -24,14 +24,14 @@ public class HomeHelper extends HelperBase {
|
||||
private static final String PROP_SEARCH = "routerconsole.showSearch";
|
||||
|
||||
static final String DEFAULT_SERVICES =
|
||||
_x("Addressbook") + S + _x("Manage your I2P hosts file here (I2P domain name resolution)") + S + "/susidns/index" + S + I + "book_addresses.png" + S +
|
||||
_x("Addressbook") + S + _x("Manage your I2P hosts file here (I2P domain name resolution)") + S + "/dns" + S + I + "book_addresses.png" + S +
|
||||
_x("Configure Bandwidth") + S + _x("I2P Bandwidth Configuration") + S + "/config" + S + I + "wrench_orange.png" + S +
|
||||
_x("Configure Language") + S + _x("Console Language Selection") + S + "/configui" + S + I + "wrench_orange.png" + S +
|
||||
_x("Customize Home Page") + S + _x("I2P Home Page Configuration") + S + "/confighome" + S + I + "wrench_orange.png" + S +
|
||||
_x("Email") + S + _x("Anonymous webmail client") + S + "/susimail/susimail" + S + I + "email.png" + S +
|
||||
_x("Email") + S + _x("Anonymous webmail client") + S + "/webmail" + S + I + "email.png" + S +
|
||||
_x("Help") + S + _x("I2P Router Help") + S + "/help" + S + I + "help.png" + S +
|
||||
_x("Router Console") + S + _x("I2P Router Console") + S + "/console" + S + I + "wrench_orange.png" + S +
|
||||
_x("Torrents") + S + _x("Built-in anonymous BitTorrent Client") + S + "/i2psnark/" + S + I + "film.png" + S +
|
||||
_x("Torrents") + S + _x("Built-in anonymous BitTorrent Client") + S + "/torrents" + S + I + "film.png" + S +
|
||||
_x("Website") + S + _x("Local web server") + S + "http://127.0.0.1:7658/" + S + I + "server.png" + S +
|
||||
"";
|
||||
|
||||
|
@ -16,7 +16,7 @@ public class NewsHelper extends ContentHelper {
|
||||
if (!news.exists())
|
||||
_page = (new File(_context.getBaseDir(), "docs/initialNews/initialNews.xml")).getAbsolutePath();
|
||||
return super.getContent();
|
||||
}
|
||||
}
|
||||
|
||||
/** @since 0.8.12 */
|
||||
public boolean shouldShowNews() {
|
||||
|
@ -3,6 +3,10 @@ package net.i2p.router.web;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.router.RouterContext;
|
||||
@ -12,6 +16,36 @@ import net.i2p.router.RouterContext;
|
||||
*
|
||||
*/
|
||||
public class SummaryBarRenderer {
|
||||
// Commented out because broken. Replaced by if-elseif blob below.
|
||||
/*static final Map<String, java.lang.reflect.Method> ALL_SECTIONS;
|
||||
static {
|
||||
Map<String, java.lang.reflect.Method> aMap = new HashMap<String, java.lang.reflect.Method>();;
|
||||
try {
|
||||
aMap.put("HelpAndFAQ", SummaryBarRenderer.class.getMethod("renderHelpAndFAQHTML"));
|
||||
aMap.put("I2PServices", SummaryBarRenderer.class.getMethod("renderI2PServicesHTML"));
|
||||
aMap.put("I2PInternals", SummaryBarRenderer.class.getMethod("renderI2PInternalsHTML"));
|
||||
aMap.put("General", SummaryBarRenderer.class.getMethod("renderGeneralHTML"));
|
||||
aMap.put("ShortGeneral", SummaryBarRenderer.class.getMethod("renderShortGeneralHTML"));
|
||||
aMap.put("NetworkReachability", SummaryBarRenderer.class.getMethod("renderNetworkReachabilityHTML"));
|
||||
aMap.put("UpdateStatus", SummaryBarRenderer.class.getMethod("renderUpdateStatusHTML"));
|
||||
aMap.put("RestartStatus", SummaryBarRenderer.class.getMethod("renderRestartStatusHTMLHTML"));
|
||||
aMap.put("Peers", SummaryBarRenderer.class.getMethod("renderPeersHTML"));
|
||||
aMap.put("FirewallAndReseedStatus", SummaryBarRenderer.class.getMethod("renderFirewallAndReseedStatusHTML"));
|
||||
aMap.put("Bandwidth", SummaryBarRenderer.class.getMethod("renderBandwidthHTML"));
|
||||
aMap.put("Tunnels", SummaryBarRenderer.class.getMethod("renderTunnelsHTML"));
|
||||
aMap.put("Congestion", SummaryBarRenderer.class.getMethod("renderCongestionHTML"));
|
||||
aMap.put("TunnelStatus", SummaryBarRenderer.class.getMethod("renderTunnelStatusHTML"));
|
||||
aMap.put("Destinations", SummaryBarRenderer.class.getMethod("renderDestinationsHTML"));
|
||||
aMap.put("NewsHeadings", SummaryBarRenderer.class.getMethod("renderNewsHeadingsHTML"));
|
||||
} catch (java.lang.NoSuchMethodException e) {
|
||||
}
|
||||
ALL_SECTIONS = Collections.unmodifiableMap(aMap);
|
||||
}*/
|
||||
static final String ALL_SECTIONS[] =
|
||||
{"HelpAndFAQ", "I2PServices", "I2PInternals", "General", "ShortGeneral", "NetworkReachability",
|
||||
"UpdateStatus", "RestartStatus", "Peers", "FirewallAndReseedStatus", "Bandwidth", "Tunnels",
|
||||
"Congestion", "TunnelStatus", "Destinations", "NewsHeadings" };
|
||||
|
||||
private final RouterContext _context;
|
||||
private final SummaryHelper _helper;
|
||||
|
||||
@ -25,155 +59,199 @@ public class SummaryBarRenderer {
|
||||
* on lower-level directory errors.
|
||||
*/
|
||||
public void renderSummaryHTML(Writer out) throws IOException {
|
||||
String requestURI = _helper.getRequestURI();
|
||||
String page = requestURI.replace("/", "").replace(".jsp", "");
|
||||
List<String> sections = _helper.getSummaryBarSections(page);
|
||||
StringBuilder buf = new StringBuilder(8*1024);
|
||||
String theme = _context.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
|
||||
|
||||
// TODO - the bar would render more cleanly if we specified the img height and width here,
|
||||
// but unfortunately the images in the different themes are different sizes.
|
||||
// They range in height from 37 to 43 px. But there's a -2 bottom margin...
|
||||
// So put it in a div.
|
||||
buf.append("<div style=\"height: 36px;\"><a href=\"/\" target=\"_top\"><img src=\"")
|
||||
.append(CSSHelper.BASE_THEME_PATH)
|
||||
.append(theme)
|
||||
.append("/images/i2plogo.png\" alt=\"")
|
||||
.append(_("I2P Router Console"))
|
||||
.append("\" title=\"")
|
||||
.append(_("I2P Router Console"))
|
||||
.append("\"></a></div><hr>")
|
||||
|
||||
.append("<h3><a href=\"/help\" target=\"_top\" title=\"")
|
||||
for (String section : sections) {
|
||||
// Commented out because broken. Replaced by if-elseif blob below.
|
||||
/*try {
|
||||
String section = (String)ALL_SECTIONS.get(sections[i]).invoke(this);
|
||||
if (section != null && section != "") {
|
||||
out.write("<hr>" + i + "<hr>\n" + section);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
out.write("<hr>" +i + " - Exception<hr>\n" + e);
|
||||
}*/
|
||||
buf.setLength(0);
|
||||
|
||||
buf.append("<hr>\n");
|
||||
if ("HelpAndFAQ".equals(section))
|
||||
buf.append(renderHelpAndFAQHTML());
|
||||
else if ("I2PServices".equals(section))
|
||||
buf.append(renderI2PServicesHTML());
|
||||
else if ("I2PInternals".equals(section))
|
||||
buf.append(renderI2PInternalsHTML());
|
||||
else if ("General".equals(section))
|
||||
buf.append(renderGeneralHTML());
|
||||
else if ("ShortGeneral".equals(section))
|
||||
buf.append(renderShortGeneralHTML());
|
||||
else if ("NetworkReachability".equals(section))
|
||||
buf.append(renderNetworkReachabilityHTML());
|
||||
else if ("UpdateStatus".equals(section))
|
||||
buf.append(renderUpdateStatusHTML());
|
||||
else if ("RestartStatus".equals(section))
|
||||
buf.append(renderRestartStatusHTML());
|
||||
else if ("Peers".equals(section))
|
||||
buf.append(renderPeersHTML());
|
||||
else if ("FirewallAndReseedStatus".equals(section))
|
||||
buf.append(renderFirewallAndReseedStatusHTML());
|
||||
else if ("Bandwidth".equals(section))
|
||||
buf.append(renderBandwidthHTML());
|
||||
else if ("Tunnels".equals(section))
|
||||
buf.append(renderTunnelsHTML());
|
||||
else if ("Congestion".equals(section))
|
||||
buf.append(renderCongestionHTML());
|
||||
else if ("TunnelStatus".equals(section))
|
||||
buf.append(renderTunnelStatusHTML());
|
||||
else if ("Destinations".equals(section))
|
||||
buf.append(renderDestinationsHTML());
|
||||
else if ("NewsHeadings".equals(section))
|
||||
buf.append(renderNewsHeadingsHTML());
|
||||
|
||||
// Only output section if there's more than the <hr> to print
|
||||
if (buf.length() > 5)
|
||||
out.write(buf.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public String renderHelpAndFAQHTML() {
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<h3><a href=\"/help\" target=\"_top\" title=\"")
|
||||
.append(_("I2P Router Help & FAQ"))
|
||||
.append("\">")
|
||||
.append(_("Help & FAQ"))
|
||||
.append("</a></h3><hr>");
|
||||
.append("</a></h3>");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
File lpath = new File(_context.getBaseDir(), "docs/toolbar.html");
|
||||
// you better have target="_top" for the links in there...
|
||||
if (lpath.exists()) {
|
||||
ContentHelper linkhelper = new ContentHelper();
|
||||
linkhelper.setPage(lpath.getAbsolutePath());
|
||||
linkhelper.setMaxLines("100");
|
||||
buf.append(linkhelper.getContent());
|
||||
} else {
|
||||
buf.append("<h3><a href=\"/configclients\" target=\"_top\" title=\"")
|
||||
.append(_("Configure startup of clients and webapps (services); manually start dormant services"))
|
||||
.append("\">")
|
||||
.append(_("I2P Services"))
|
||||
.append("</a></h3>\n" +
|
||||
public String renderI2PServicesHTML() {
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<h3><a href=\"/configclients\" target=\"_top\" title=\"")
|
||||
.append(_("Configure startup of clients and webapps (services); manually start dormant services"))
|
||||
.append("\">")
|
||||
.append(_("I2P Services"))
|
||||
.append("</a></h3>\n" +
|
||||
|
||||
"<hr class=\"b\"><table><tr><td>" +
|
||||
"<hr class=\"b\"><table><tr><td>" +
|
||||
|
||||
"<a href=\"/susimail/susimail\" target=\"blank\" title=\"")
|
||||
.append(_("Anonymous webmail client"))
|
||||
.append("\">")
|
||||
.append(_("Email"))
|
||||
.append("</a>\n" +
|
||||
"<a href=\"/webmail\" target=\"_top\" title=\"")
|
||||
.append(_("Anonymous webmail client"))
|
||||
.append("\">")
|
||||
.append(_("Email"))
|
||||
.append("</a>\n" +
|
||||
|
||||
"<a href=\"/i2psnark/\" target=\"_blank\" title=\"")
|
||||
.append(_("Built-in anonymous BitTorrent Client"))
|
||||
.append("\">")
|
||||
.append(_("Torrents"))
|
||||
.append("</a>\n" +
|
||||
"<a href=\"/torrents\" target=\"_top\" title=\"")
|
||||
.append(_("Built-in anonymous BitTorrent Client"))
|
||||
.append("\">")
|
||||
.append(_("Torrents"))
|
||||
.append("</a>\n" +
|
||||
|
||||
"<a href=\"http://127.0.0.1:7658/\" target=\"_blank\" title=\"")
|
||||
.append(_("Local web server"))
|
||||
.append("\">")
|
||||
.append(_("Website"))
|
||||
.append("</a>\n")
|
||||
"<a href=\"http://127.0.0.1:7658/\" target=\"_blank\" title=\"")
|
||||
.append(_("Local web server"))
|
||||
.append("\">")
|
||||
.append(_("Website"))
|
||||
.append("</a>\n")
|
||||
|
||||
.append(NavHelper.getClientAppLinks(_context))
|
||||
.append(NavHelper.getClientAppLinks(_context))
|
||||
|
||||
.append("</td></tr></table>\n" +
|
||||
.append("</td></tr></table>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
"<hr><h3><a href=\"/config\" target=\"_top\" title=\"")
|
||||
.append(_("Configure I2P Router"))
|
||||
.append("\">")
|
||||
.append(_("I2P Internals"))
|
||||
.append("</a></h3><hr class=\"b\">\n" +
|
||||
public String renderI2PInternalsHTML() {
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<h3><a href=\"/config\" target=\"_top\" title=\"")
|
||||
.append(_("Configure I2P Router"))
|
||||
.append("\">")
|
||||
.append(_("I2P Internals"))
|
||||
.append("</a></h3><hr class=\"b\">\n" +
|
||||
|
||||
"<table><tr><td>\n" +
|
||||
"<table><tr><td>\n" +
|
||||
|
||||
"<a href=\"/tunnels\" target=\"_top\" title=\"")
|
||||
.append(_("View existing tunnels and tunnel build status"))
|
||||
.append("\">")
|
||||
.append(_("Tunnels"))
|
||||
.append("</a>\n" +
|
||||
"<a href=\"/tunnels\" target=\"_top\" title=\"")
|
||||
.append(_("View existing tunnels and tunnel build status"))
|
||||
.append("\">")
|
||||
.append(_("Tunnels"))
|
||||
.append("</a>\n" +
|
||||
|
||||
"<a href=\"/peers\" target=\"_top\" title=\"")
|
||||
.append(_("Show all current peer connections"))
|
||||
.append("\">")
|
||||
.append(_("Peers"))
|
||||
.append("</a>\n" +
|
||||
"<a href=\"/peers\" target=\"_top\" title=\"")
|
||||
.append(_("Show all current peer connections"))
|
||||
.append("\">")
|
||||
.append(_("Peers"))
|
||||
.append("</a>\n" +
|
||||
|
||||
"<a href=\"/profiles\" target=\"_top\" title=\"")
|
||||
.append(_("Show recent peer performance profiles"))
|
||||
.append("\">")
|
||||
.append(_("Profiles"))
|
||||
.append("</a>\n" +
|
||||
"<a href=\"/profiles\" target=\"_top\" title=\"")
|
||||
.append(_("Show recent peer performance profiles"))
|
||||
.append("\">")
|
||||
.append(_("Profiles"))
|
||||
.append("</a>\n" +
|
||||
|
||||
"<a href=\"/netdb\" target=\"_top\" title=\"")
|
||||
.append(_("Show list of all known I2P routers"))
|
||||
.append("\">")
|
||||
.append(_("NetDB"))
|
||||
.append("</a>\n" +
|
||||
"<a href=\"/netdb\" target=\"_top\" title=\"")
|
||||
.append(_("Show list of all known I2P routers"))
|
||||
.append("\">")
|
||||
.append(_("NetDB"))
|
||||
.append("</a>\n" +
|
||||
|
||||
"<a href=\"/logs\" target=\"_top\" title=\"")
|
||||
.append(_("Health Report"))
|
||||
.append("\">")
|
||||
.append(_("Logs"))
|
||||
.append("</a>\n");
|
||||
"<a href=\"/logs\" target=\"_top\" title=\"")
|
||||
.append(_("Health Report"))
|
||||
.append("\">")
|
||||
.append(_("Logs"))
|
||||
.append("</a>\n");
|
||||
|
||||
// "<a href=\"/jobs.jsp\" target=\"_top\" title=\"")
|
||||
// .append(_("Show the router's workload, and how it's performing"))
|
||||
// .append("\">")
|
||||
// .append(_("Jobs"))
|
||||
// .append("</a>\n" +
|
||||
// "<a href=\"/jobs.jsp\" target=\"_top\" title=\"")
|
||||
// .append(_("Show the router's workload, and how it's performing"))
|
||||
// .append("\">")
|
||||
// .append(_("Jobs"))
|
||||
// .append("</a>\n" +
|
||||
|
||||
if (!StatSummarizer.isDisabled()) {
|
||||
buf.append("<a href=\"/graphs\" target=\"_top\" title=\"")
|
||||
if (!StatSummarizer.isDisabled()) {
|
||||
buf.append("<a href=\"/graphs\" target=\"_top\" title=\"")
|
||||
.append(_("Graph router performance"))
|
||||
.append("\">")
|
||||
.append(_("Graphs"))
|
||||
.append("</a>\n");
|
||||
}
|
||||
|
||||
buf.append("<a href=\"/stats\" target=\"_top\" title=\"")
|
||||
.append(_("Textual router performance statistics"))
|
||||
.append("\">")
|
||||
.append(_("Stats"))
|
||||
.append("</a>\n" +
|
||||
|
||||
"<a href=\"/i2ptunnel/\" target=\"_blank\" title=\"")
|
||||
.append(_("Local Destinations"))
|
||||
.append("\">")
|
||||
.append(_("I2PTunnel"))
|
||||
.append("</a>\n" +
|
||||
|
||||
"<a href=\"/susidns/index\" target=\"_blank\" title=\"")
|
||||
.append(_("Manage your I2P hosts file here (I2P domain name resolution)"))
|
||||
.append("\">")
|
||||
.append(_("Addressbook"))
|
||||
.append("</a>\n");
|
||||
|
||||
File javadoc = new File(_context.getBaseDir(), "docs/javadoc/index.html");
|
||||
if (javadoc.exists())
|
||||
buf.append("<a href=\"/javadoc/index.html\" target=\"_blank\">Javadoc</a>\n");
|
||||
buf.append("</td></tr></table>\n");
|
||||
|
||||
out.write(buf.toString());
|
||||
buf.setLength(0);
|
||||
}
|
||||
|
||||
buf.append("<a href=\"/stats\" target=\"_top\" title=\"")
|
||||
.append(_("Textual router performance statistics"))
|
||||
.append("\">")
|
||||
.append(_("Stats"))
|
||||
.append("</a>\n" +
|
||||
|
||||
"<a href=\"/i2ptunnelmgr\" target=\"_top\" title=\"")
|
||||
.append(_("Local Destinations"))
|
||||
.append("\">")
|
||||
.append(_("I2PTunnel"))
|
||||
.append("</a>\n" +
|
||||
|
||||
buf.append("<hr><h3><a href=\"/help\" target=\"_top\" title=\"")
|
||||
"<a href=\"/dns\" target=\"_top\" title=\"")
|
||||
.append(_("Manage your I2P hosts file here (I2P domain name resolution)"))
|
||||
.append("\">")
|
||||
.append(_("Addressbook"))
|
||||
.append("</a>\n");
|
||||
|
||||
File javadoc = new File(_context.getBaseDir(), "docs/javadoc/index.html");
|
||||
if (javadoc.exists())
|
||||
buf.append("<a href=\"/javadoc/index.html\" target=\"_blank\">Javadoc</a>\n");
|
||||
buf.append("</td></tr></table>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String renderGeneralHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<h3><a href=\"/help\" target=\"_top\" title=\"")
|
||||
.append(_("I2P Router Help"))
|
||||
.append("\">")
|
||||
.append(_("General"))
|
||||
.append("</a></h3><hr class=\"b\">\n" +
|
||||
|
||||
"<table><tr>" +
|
||||
"<td align=\"left\"><b>")
|
||||
"<td align=\"left\"><b title=\"")
|
||||
.append(_("Your Local Identity is your unique I2P router identity, similar to an ip address but tailored to I2P. "))
|
||||
.append(_("Never disclose this to anyone, as it can reveal your real world ip."))
|
||||
.append("\">")
|
||||
.append(_("Local Identity"))
|
||||
.append(":</b></td>" +
|
||||
"<td align=\"right\">" +
|
||||
@ -187,7 +265,10 @@ public class SummaryBarRenderer {
|
||||
.append(_("show"))
|
||||
.append("</a></td></tr>\n" +
|
||||
|
||||
"<tr><td align=\"left\"><b>")
|
||||
"<tr title=\"")
|
||||
.append(_("The version of the I2P software we are running"))
|
||||
.append("\">" +
|
||||
"<td align=\"left\"><b>")
|
||||
.append(_("Version"))
|
||||
.append(":</b></td>" +
|
||||
"<td align=\"right\">")
|
||||
@ -202,24 +283,74 @@ public class SummaryBarRenderer {
|
||||
.append(":</b></td>" +
|
||||
"<td align=\"right\">")
|
||||
.append(_helper.getUptime())
|
||||
.append("</td></tr></table>\n" +
|
||||
.append("</td></tr></table>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
"<hr><h4><a href=\"/confignet#help\" target=\"_top\" title=\"")
|
||||
public String renderShortGeneralHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<table>" +
|
||||
"<tr title=\"")
|
||||
.append(_("The version of the I2P software we are running"))
|
||||
.append("\">" +
|
||||
"<td align=\"left\"><b>")
|
||||
.append(_("Version"))
|
||||
.append(":</b></td>" +
|
||||
"<td align=\"right\">")
|
||||
.append(_helper.getVersion())
|
||||
.append("</td></tr>\n" +
|
||||
|
||||
"<tr title=\"")
|
||||
.append(_("How long we've been running for this session"))
|
||||
.append("\">" +
|
||||
"<td align=\"left\"><b>")
|
||||
.append(_("Uptime"))
|
||||
.append(":</b></td>" +
|
||||
"<td align=\"right\">")
|
||||
.append(_helper.getUptime())
|
||||
.append("</td></tr></table>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String renderNetworkReachabilityHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<h4><a href=\"/confignet#help\" target=\"_top\" title=\"")
|
||||
.append(_("Help with configuring your firewall and router for optimal I2P performance"))
|
||||
.append("\">")
|
||||
.append(_("Network"))
|
||||
.append(": ")
|
||||
.append(_helper.getReachability())
|
||||
.append("</a></h4><hr>\n")
|
||||
.append("</a></h4>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String renderUpdateStatusHTML() {
|
||||
if (_helper == null) return "";
|
||||
String updateStatus = _helper.getUpdateStatus();
|
||||
if ("".equals(updateStatus)) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<h3><a href=\"/configupdate\" target=\"_top\" title=\"")
|
||||
.append(_("Configure I2P Updates"))
|
||||
.append("\">")
|
||||
.append(_("I2P Update"))
|
||||
.append("</a></h3><hr class=\"b\">\n");
|
||||
buf.append(updateStatus);
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
.append(_helper.getUpdateStatus())
|
||||
public String renderRestartStatusHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append(_helper.getRestartStatus());
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
||||
.append(_helper.getRestartStatus())
|
||||
|
||||
|
||||
.append("<hr><h3><a href=\"/peers\" target=\"_top\" title=\"")
|
||||
public String renderPeersHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<h3><a href=\"/peers\" target=\"_top\" title=\"")
|
||||
.append(_("Show all current peer connections"))
|
||||
.append("\">")
|
||||
.append(_("Peers"))
|
||||
@ -227,7 +358,10 @@ public class SummaryBarRenderer {
|
||||
|
||||
"<table>\n" +
|
||||
|
||||
"<tr><td align=\"left\"><b>")
|
||||
"<tr title=\"")
|
||||
.append(_("Peers we've been talking to in the last few minutes/last hour"))
|
||||
.append("\">" +
|
||||
"<td align=\"left\"><b>")
|
||||
.append(_("Active"))
|
||||
.append(":</b></td><td align=\"right\">");
|
||||
int active = _helper.getActivePeers();
|
||||
@ -236,38 +370,56 @@ public class SummaryBarRenderer {
|
||||
.append(Math.max(active, _helper.getActiveProfiles()))
|
||||
.append("</td></tr>\n" +
|
||||
|
||||
"<tr><td align=\"left\"><b>")
|
||||
"<tr title=\"")
|
||||
.append(_("The number of peers available for building client tunnels"))
|
||||
.append("\">" +
|
||||
"<td align=\"left\"><b>")
|
||||
.append(_("Fast"))
|
||||
.append(":</b></td><td align=\"right\">")
|
||||
.append(_helper.getFastPeers())
|
||||
.append("</td></tr>\n" +
|
||||
|
||||
"<tr><td align=\"left\"><b>")
|
||||
"<tr title=\"")
|
||||
.append(_("The number of peers available for building exploratory tunnels"))
|
||||
.append("\">" +
|
||||
"<td align=\"left\"><b>")
|
||||
.append(_("High capacity"))
|
||||
.append(":</b></td><td align=\"right\">")
|
||||
.append(_helper.getHighCapacityPeers())
|
||||
.append("</td></tr>\n" +
|
||||
|
||||
"<tr><td align=\"left\"><b>")
|
||||
"<tr title=\"")
|
||||
.append(_("The number of peers available for network database inquries"))
|
||||
.append("\">" +
|
||||
"<td align=\"left\"><b>")
|
||||
.append(_("Integrated"))
|
||||
.append(":</b></td><td align=\"right\">")
|
||||
.append(_helper.getWellIntegratedPeers())
|
||||
.append("</td></tr>\n" +
|
||||
|
||||
"<tr><td align=\"left\"><b>")
|
||||
"<tr title=\"")
|
||||
.append(_("The total number of peers in our network database"))
|
||||
.append("\">" +
|
||||
"<td align=\"left\"><b>")
|
||||
.append(_("Known"))
|
||||
.append(":</b></td><td align=\"right\">")
|
||||
.append(_helper.getAllPeers())
|
||||
.append("</td></tr>\n" +
|
||||
|
||||
"</table><hr>\n");
|
||||
|
||||
|
||||
out.write(buf.toString());
|
||||
buf.setLength(0);
|
||||
"</table>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String renderFirewallAndReseedStatusHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append(_helper.getFirewallAndReseedStatus());
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String renderBandwidthHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<h3><a href=\"/config\" title=\"")
|
||||
.append(_("Configure router bandwidth allocation"))
|
||||
.append("\" target=\"_top\">")
|
||||
@ -303,82 +455,181 @@ public class SummaryBarRenderer {
|
||||
.append(_helper.getInboundTransferred())
|
||||
.append(SummaryHelper.THINSP)
|
||||
.append(_helper.getOutboundTransferred())
|
||||
.append("</td></tr></table>\n" +
|
||||
.append("</td></tr>\n" +
|
||||
|
||||
"<hr><h3><a href=\"/tunnels\" target=\"_top\" title=\"")
|
||||
"</table>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String renderTunnelsHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<h3><a href=\"/tunnels\" target=\"_top\" title=\"")
|
||||
.append(_("View existing tunnels and tunnel build status"))
|
||||
.append("\">")
|
||||
.append(_("Tunnels"))
|
||||
.append("</a></h3><hr class=\"b\">" +
|
||||
"<table>\n" +
|
||||
|
||||
"<tr><td align=\"left\"><b>")
|
||||
"<tr title=\"")
|
||||
.append(_("Used for building and testing tunnels, and communicating with floodfill peers"))
|
||||
.append("\">" +
|
||||
"<td align=\"left\"><b>")
|
||||
.append(_("Exploratory"))
|
||||
.append(":</b></td><td align=\"right\">")
|
||||
.append(_helper.getInboundTunnels() + _helper.getOutboundTunnels())
|
||||
.append("</td></tr>\n" +
|
||||
|
||||
"<tr><td align=\"left\"><b>")
|
||||
"<tr title=\"")
|
||||
.append(_("Tunnels we are using to provide or access services on the network"))
|
||||
.append("\">" +
|
||||
"<td align=\"left\"><b>")
|
||||
.append(_("Client"))
|
||||
.append(":</b></td><td align=\"right\">")
|
||||
.append(_helper.getInboundClientTunnels() + _helper.getOutboundClientTunnels())
|
||||
.append("</td></tr>\n" +
|
||||
|
||||
"<tr><td align=\"left\"><b>")
|
||||
"<tr title=\"")
|
||||
.append(_("Tunnels we are participating in, directly contributing bandwith to the network"))
|
||||
.append("\">" +
|
||||
"<td align=\"left\"><b>")
|
||||
.append(_("Participating"))
|
||||
.append(":</b></td><td align=\"right\">")
|
||||
.append(_helper.getParticipatingTunnels())
|
||||
.append("</td></tr>\n" +
|
||||
|
||||
"<tr><td align=\"left\"><b>")
|
||||
"<tr title=\"")
|
||||
.append(_("The ratio of tunnel hops we provide to tunnel hops we use - a value greater than 1.00 indicates a positive contribution to the network"))
|
||||
.append("\">" +
|
||||
"<td align=\"left\"><b>")
|
||||
.append(_("Share ratio"))
|
||||
.append(":</b></td><td align=\"right\">")
|
||||
.append(_helper.getShareRatio())
|
||||
.append("</td></tr>\n" +
|
||||
|
||||
"</table><hr><h3><a href=\"/jobs\" target=\"_top\" title=\"")
|
||||
"</table>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String renderCongestionHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<h3><a href=\"/jobs\" target=\"_top\" title=\"")
|
||||
.append(_("What's in the router's job queue?"))
|
||||
.append("\">")
|
||||
.append(_("Congestion"))
|
||||
.append("</a></h3><hr class=\"b\">" +
|
||||
"<table>\n" +
|
||||
|
||||
"<tr><td align=\"left\"><b>")
|
||||
"<tr title=\"")
|
||||
.append(_("Indicates router performance"))
|
||||
.append("\">" +
|
||||
"<td align=\"left\"><b>")
|
||||
.append(_("Job lag"))
|
||||
.append(":</b></td><td align=\"right\">")
|
||||
.append(_helper.getJobLag())
|
||||
.append("</td></tr>\n" +
|
||||
|
||||
"<tr><td align=\"left\"><b>")
|
||||
"<tr title=\"")
|
||||
.append(_("Indicates how quickly outbound messages to other I2P routers are sent"))
|
||||
.append("\">" +
|
||||
"<td align=\"left\"><b>")
|
||||
.append(_("Message delay"))
|
||||
.append(":</b></td><td align=\"right\">")
|
||||
.append(_helper.getMessageDelay())
|
||||
.append("</td></tr>\n");
|
||||
|
||||
if (!_context.getBooleanPropertyDefaultTrue("router.disableTunnelTesting")) {
|
||||
buf.append("<tr><td align=\"left\"><b>")
|
||||
buf.append("<tr title=\"")
|
||||
.append(_("Round trip time for a tunnel test"))
|
||||
.append("\">" +
|
||||
"<td align=\"left\"><b>")
|
||||
.append(_("Tunnel lag"))
|
||||
.append(":</b></td><td align=\"right\">")
|
||||
.append(_helper.getTunnelLag())
|
||||
.append("</td></tr>\n");
|
||||
}
|
||||
|
||||
buf.append("<tr><td align=\"left\"><b>")
|
||||
buf.append("<tr title=\"")
|
||||
.append(_("Queued requests from other routers to participate in tunnels"))
|
||||
.append("\">" +
|
||||
"<td align=\"left\"><b>")
|
||||
.append(_("Backlog"))
|
||||
.append(":</b></td><td align=\"right\">")
|
||||
.append(_helper.getInboundBacklog())
|
||||
.append("</td></tr>\n" +
|
||||
|
||||
"</table><hr><h4>")
|
||||
"</table>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String renderTunnelStatusHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(50);
|
||||
buf.append("<h4>")
|
||||
.append(_(_helper.getTunnelStatus()))
|
||||
.append("</h4><hr>\n")
|
||||
.append("</h4>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
.append(_helper.getDestinations())
|
||||
.append("<hr>\n");
|
||||
public String renderDestinationsHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append(_helper.getDestinations());
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
out.write(buf.toString());
|
||||
/** @since 0.9.1 */
|
||||
public String renderNewsHeadingsHTML() {
|
||||
if (_helper == null) return "";
|
||||
NewsHelper newshelper = _helper.getNewsHelper();
|
||||
if (newshelper == null || newshelper.shouldShowNews()) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
String consoleNonce = System.getProperty("router.consoleNonce");
|
||||
if (consoleNonce != null) {
|
||||
// Set up title and pre-headings stuff.
|
||||
buf.append("<h3><a href=\"/configupdate\">")
|
||||
.append(_("News & Updates"))
|
||||
.append("</a></h3><hr class=\"b\"><div class=\"newsheadings\">\n");
|
||||
// Get news content.
|
||||
String newsContent = newshelper.getContent();
|
||||
if (newsContent != "") {
|
||||
buf.append("<ul>\n");
|
||||
// Parse news content for headings.
|
||||
int start = newsContent.indexOf("<h3>");
|
||||
while (start >= 0) {
|
||||
// Add offset to start:
|
||||
// 4 - gets rid of <h3>
|
||||
// 16 - gets rid of the date as well (assuming form "<h3>yyyy-mm-dd: Foobarbaz...")
|
||||
newsContent = newsContent.substring(start+16, newsContent.length());
|
||||
int end = newsContent.indexOf("</h3>");
|
||||
if (end >= 0) {
|
||||
String heading = newsContent.substring(0, end);
|
||||
buf.append("<li>")
|
||||
.append(heading)
|
||||
.append("</li>\n");
|
||||
}
|
||||
start = newsContent.indexOf("<h3>");
|
||||
}
|
||||
buf.append("</ul>\n");
|
||||
// Set up string containing <a> to show news.
|
||||
String requestURI = _helper.getRequestURI();
|
||||
if (requestURI.contains("/home")) {
|
||||
buf.append("<a href=\"/?news=1&consoleNonce=")
|
||||
.append(consoleNonce)
|
||||
.append("\">")
|
||||
.append(_("Show news"))
|
||||
.append("</a>\n");
|
||||
}
|
||||
} else {
|
||||
buf.append("<center><i>")
|
||||
.append(_("none"))
|
||||
.append("</i></center>");
|
||||
}
|
||||
// Add post-headings stuff.
|
||||
buf.append("</div>\n");
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/** translate a string */
|
||||
|
@ -4,10 +4,13 @@ import java.io.IOException;
|
||||
import java.text.Collator;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.data.Destination;
|
||||
@ -17,6 +20,7 @@ import net.i2p.data.RouterAddress;
|
||||
import net.i2p.data.RouterInfo;
|
||||
import net.i2p.router.CommSystemFacade;
|
||||
import net.i2p.router.Router;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.router.RouterVersion;
|
||||
import net.i2p.router.TunnelPoolSettings;
|
||||
import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade;
|
||||
@ -35,6 +39,35 @@ public class SummaryHelper extends HelperBase {
|
||||
// Opera 10.63 doesn't have the char, TODO check UA
|
||||
//static final String THINSP = " / ";
|
||||
static final String THINSP = " / ";
|
||||
private static final char S = ',';
|
||||
static final String PROP_SUMMARYBAR = "routerconsole.summaryBar.";
|
||||
|
||||
static final String DEFAULT_FULL =
|
||||
"HelpAndFAQ" + S +
|
||||
"I2PServices" + S +
|
||||
"I2PInternals" + S +
|
||||
"General" + S +
|
||||
"NetworkReachability" + S +
|
||||
"UpdateStatus" + S +
|
||||
"RestartStatus" + S +
|
||||
"Peers" + S +
|
||||
"FirewallAndReseedStatus" + S +
|
||||
"Bandwidth" + S +
|
||||
"Tunnels" + S +
|
||||
"Congestion" + S +
|
||||
"TunnelStatus" + S +
|
||||
"Destinations" + S +
|
||||
"";
|
||||
|
||||
static final String DEFAULT_MINIMAL =
|
||||
"ShortGeneral" + S +
|
||||
"NewsHeadings" + S +
|
||||
"UpdateStatus" + S +
|
||||
"NetworkReachability" + S +
|
||||
"FirewallAndReseedStatus" + S +
|
||||
"Destinations" + S +
|
||||
"RestartStatus" + S +
|
||||
"";
|
||||
|
||||
/**
|
||||
* Retrieve the shortened 4 character ident for the router located within
|
||||
@ -375,7 +408,7 @@ public class SummaryHelper extends HelperBase {
|
||||
List<Destination> clients = new ArrayList(_context.clientManager().listClients());
|
||||
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<h3><a href=\"/i2ptunnel/\" target=\"_blank\" title=\"").append(_("Add/remove/edit & control your client and server tunnels")).append("\">").append(_("Local Destinations")).append("</a></h3><hr class=\"b\"><div class=\"tunnels\">");
|
||||
buf.append("<h3><a href=\"/i2ptunnelmgr\" target=\"_top\" title=\"").append(_("Add/remove/edit & control your client and server tunnels")).append("\">").append(_("Local Destinations")).append("</a></h3><hr class=\"b\"><div class=\"tunnels\">");
|
||||
if (!clients.isEmpty()) {
|
||||
Collections.sort(clients, new AlphaComparator());
|
||||
buf.append("<table>");
|
||||
@ -618,7 +651,7 @@ public class SummaryHelper extends HelperBase {
|
||||
// display all the time so we display the final failure message, and plugin update messages too
|
||||
String status = UpdateHandler.getStatus();
|
||||
if (status.length() > 0) {
|
||||
buf.append("<h4>").append(status).append("</h4><hr>\n");
|
||||
buf.append("<h4>").append(status).append("</h4>\n");
|
||||
}
|
||||
if (updateAvailable() || unsignedUpdateAvailable()) {
|
||||
if ("true".equals(System.getProperty(UpdateHandler.PROP_UPDATE_IN_PROGRESS))) {
|
||||
@ -706,10 +739,31 @@ public class SummaryHelper extends HelperBase {
|
||||
}
|
||||
if (buf.length() <= 0)
|
||||
return "";
|
||||
buf.append("<hr>");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
private NewsHelper _newshelper;
|
||||
public void storeNewsHelper(NewsHelper n) { _newshelper = n; }
|
||||
public NewsHelper getNewsHelper() { return _newshelper; }
|
||||
|
||||
public List<String> getSummaryBarSections(String page) {
|
||||
String config = "";
|
||||
if ("home".equals(page))
|
||||
config = _context.getProperty(PROP_SUMMARYBAR + page, DEFAULT_MINIMAL);
|
||||
else
|
||||
config = _context.getProperty(PROP_SUMMARYBAR + page, null);
|
||||
if (config == null)
|
||||
config = _context.getProperty(PROP_SUMMARYBAR + "default", DEFAULT_FULL);
|
||||
return Arrays.asList(config.split("" + S));
|
||||
}
|
||||
|
||||
static void saveSummaryBarSections(RouterContext ctx, String page, Map<Integer, String> sections) {
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
for(String section : sections.values())
|
||||
buf.append(section).append(S);
|
||||
ctx.router().saveConfig(PROP_SUMMARYBAR + page, buf.toString());
|
||||
}
|
||||
|
||||
/** output the summary bar to _out */
|
||||
public void renderSummaryBar() throws IOException {
|
||||
SummaryBarRenderer renderer = new SummaryBarRenderer(_context, this);
|
||||
@ -733,4 +787,91 @@ public class SummaryHelper extends HelperBase {
|
||||
private String _requestURI;
|
||||
public void setRequestURI(String s) { _requestURI = s; }
|
||||
public String getRequestURI() { return _requestURI; }
|
||||
|
||||
public String getConfigTable() {
|
||||
String[] allSections = SummaryBarRenderer.ALL_SECTIONS;
|
||||
List<String> sections = getSummaryBarSections("default");
|
||||
TreeSet<String> sortedSections = new TreeSet();
|
||||
|
||||
for (int i = 0; i < allSections.length; i++) {
|
||||
String section = allSections[i];
|
||||
if (!sections.contains(section))
|
||||
sortedSections.add(section);
|
||||
}
|
||||
|
||||
String theme = _context.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
|
||||
String imgPath = CSSHelper.BASE_THEME_PATH + theme + "/images/";
|
||||
|
||||
StringBuilder buf = new StringBuilder(2048);
|
||||
buf.append("<table class=\"sidebarconf\"><tr><th>")
|
||||
.append(_("Remove"))
|
||||
.append("</th><th>")
|
||||
.append(_("Name"))
|
||||
.append("</th><th colspan=\"2\">")
|
||||
.append(_("Order"))
|
||||
.append("</th></tr>\n");
|
||||
for (String section : sections) {
|
||||
int i = sections.indexOf(section);
|
||||
buf.append("<tr><td align=\"center\"><input type=\"checkbox\" class=\"optbox\" name=\"delete_")
|
||||
.append(i)
|
||||
.append("\"></td><td align=\"left\">")
|
||||
.append(section)
|
||||
.append("</td><td align=\"right\"><input type=\"hidden\" name=\"order_")
|
||||
.append(i + "_" + section)
|
||||
.append("\" value=\"")
|
||||
.append(i)
|
||||
.append("\">");
|
||||
if (i > 0) {
|
||||
buf.append("<input type=\"image\" class=\"buttonTop\" name=\"move_")
|
||||
.append(i)
|
||||
.append("_top\" alt=\"")
|
||||
.append(_("Top"))
|
||||
.append("\" src=\"" + imgPath + "move_top.png\">");
|
||||
buf.append("<input type=\"image\" class=\"buttonUp\" name=\"move_")
|
||||
.append(i)
|
||||
.append("_up\" alt=\"")
|
||||
.append(_("Up"))
|
||||
.append("\" src=\"" + imgPath + "move_up.png\">");
|
||||
}
|
||||
buf.append("</td><td align=\"left\">");
|
||||
if (i < sections.size() - 1) {
|
||||
buf.append("<input type=\"image\" class=\"buttonDown\" name=\"move_")
|
||||
.append(i)
|
||||
.append("_down\" alt=\"")
|
||||
.append(_("Down"))
|
||||
.append("\" src=\"" + imgPath + "move_down.png\">");
|
||||
buf.append("<input type=\"image\" class=\"buttonBottom\" name=\"move_")
|
||||
.append(i)
|
||||
.append("_bottom\" alt=\"")
|
||||
.append(_("Bottom"))
|
||||
.append("\" src=\"" + imgPath + "move_bottom.png\">");
|
||||
}
|
||||
buf.append("</td></tr>\n");
|
||||
}
|
||||
buf.append("<tr><td align=\"center\">" +
|
||||
"<input type=\"submit\" name=\"action\" class=\"delete\" value=\"")
|
||||
.append(_("Delete selected"))
|
||||
.append("\"></td><td align=\"left\"><b>")
|
||||
.append(_("Add")).append(":</b> " +
|
||||
"<select name=\"name\">\n" +
|
||||
"<option value=\"\" selected=\"selected\">")
|
||||
.append(_("Select a section to add"))
|
||||
.append("</option>\n");
|
||||
|
||||
for (String s : sortedSections) {
|
||||
buf.append("<option value=\"").append(s).append("\">")
|
||||
.append(s).append("</option>\n");
|
||||
}
|
||||
|
||||
buf.append("</select>\n" +
|
||||
"<input type=\"hidden\" name=\"order\" value=\"")
|
||||
.append(sections.size())
|
||||
.append("\"></td>" +
|
||||
"<td align=\"center\" colspan=\"2\">" +
|
||||
"<input type=\"submit\" name=\"action\" class=\"add\" value=\"")
|
||||
.append(_("Add item"))
|
||||
.append("\"></td></tr>")
|
||||
.append("</table>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
@ -237,14 +237,16 @@ public class UpdateHandler {
|
||||
if (_isPartial)
|
||||
return;
|
||||
StringBuilder buf = new StringBuilder(64);
|
||||
buf.append("<b>").append(_("Updating")).append("</b> ");
|
||||
double pct = ((double)alreadyTransferred + (double)currentWrite) /
|
||||
((double)alreadyTransferred + (double)currentWrite + bytesRemaining);
|
||||
synchronized (_pct) {
|
||||
buf.append(_pct.format(pct));
|
||||
buf.append(_("{0} downloaded", _pct.format(pct)));
|
||||
}
|
||||
buf.append(":<br>\n");
|
||||
buf.append(_("{0}B transferred", DataHelper.formatSize2(currentWrite + alreadyTransferred)));
|
||||
buf.append("<br>\n");
|
||||
buf.append(DataHelper.formatSize2(currentWrite + alreadyTransferred))
|
||||
.append("B / ")
|
||||
.append(DataHelper.formatSize2(currentWrite + alreadyTransferred + bytesRemaining))
|
||||
.append("B");
|
||||
updateStatus(buf.toString());
|
||||
}
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) {
|
||||
|
Reference in New Issue
Block a user