* Routerconsole:

- Move common methods to new HelperBase class
      - Make reseed link a button
This commit is contained in:
zzz
2009-01-29 02:16:18 +00:00
parent 9d9d4093bc
commit 69e6393442
27 changed files with 63 additions and 351 deletions

View File

@@ -6,22 +6,7 @@ import java.util.TreeSet;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
public class ConfigAdvancedHelper { public class ConfigAdvancedHelper extends HelperBase {
private RouterContext _context;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public ConfigAdvancedHelper() {} public ConfigAdvancedHelper() {}
public String getSettings() { public String getSettings() {

View File

@@ -9,22 +9,7 @@ import java.util.TreeSet;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
import net.i2p.router.startup.ClientAppConfig; import net.i2p.router.startup.ClientAppConfig;
public class ConfigClientsHelper { public class ConfigClientsHelper extends HelperBase {
private RouterContext _context;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public ConfigClientsHelper() {} public ConfigClientsHelper() {}
public String getForm1() { public String getForm1() {

View File

@@ -6,22 +6,7 @@ import java.io.OutputStreamWriter;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
public class ConfigKeyringHelper { public class ConfigKeyringHelper extends HelperBase {
private RouterContext _context;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public ConfigKeyringHelper() {} public ConfigKeyringHelper() {}
public String getSummary() { public String getSummary() {

View File

@@ -6,22 +6,7 @@ import java.util.TreeSet;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
public class ConfigLoggingHelper { public class ConfigLoggingHelper extends HelperBase {
private RouterContext _context;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public ConfigLoggingHelper() {} public ConfigLoggingHelper() {}
public String getLogFilePattern() { public String getLogFilePattern() {

View File

@@ -10,22 +10,7 @@ import net.i2p.router.transport.udp.UDPAddress;
import net.i2p.router.transport.udp.UDPTransport; import net.i2p.router.transport.udp.UDPTransport;
import net.i2p.time.Timestamper; import net.i2p.time.Timestamper;
public class ConfigNetHelper { public class ConfigNetHelper extends HelperBase {
private RouterContext _context;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public ConfigNetHelper() {} public ConfigNetHelper() {}
/** copied from various private components */ /** copied from various private components */

View File

@@ -4,25 +4,9 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import net.i2p.data.DataHelper;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
public class ConfigPeerHelper { public class ConfigPeerHelper extends HelperBase {
private RouterContext _context;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public ConfigPeerHelper() {} public ConfigPeerHelper() {}
public String getBlocklistSummary() { public String getBlocklistSummary() {

View File

@@ -15,8 +15,7 @@ import net.i2p.stat.RateStat;
import net.i2p.stat.StatManager; import net.i2p.stat.StatManager;
import net.i2p.util.Log; import net.i2p.util.Log;
public class ConfigStatsHelper { public class ConfigStatsHelper extends HelperBase {
private RouterContext _context;
private Log _log; private Log _log;
private String _filter; private String _filter;
private Set _filters; private Set _filters;

View File

@@ -8,22 +8,7 @@ import net.i2p.data.Destination;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
import net.i2p.router.TunnelPoolSettings; import net.i2p.router.TunnelPoolSettings;
public class ConfigTunnelsHelper { public class ConfigTunnelsHelper extends HelperBase {
private RouterContext _context;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public ConfigTunnelsHelper() {} public ConfigTunnelsHelper() {}

View File

@@ -51,7 +51,7 @@ public class ConfigUpdateHandler extends FormHandler {
if ( (_updatePolicy == null) || (!_updatePolicy.equals("notify")) ) if ( (_updatePolicy == null) || (!_updatePolicy.equals("notify")) )
addFormNotice("Update available, attempting to download now"); addFormNotice("Update available, attempting to download now");
else else
addFormNotice("Update available, click link on left to download"); addFormNotice("Update available, click button on left to download");
} else } else
addFormNotice("No update available"); addFormNotice("No update available");
} }

View File

@@ -4,22 +4,7 @@ import net.i2p.crypto.TrustedUpdate;
import net.i2p.data.DataHelper; import net.i2p.data.DataHelper;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
public class ConfigUpdateHelper { public class ConfigUpdateHelper extends HelperBase {
private RouterContext _context;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public ConfigUpdateHelper() {} public ConfigUpdateHelper() {}
public boolean updateAvailable() { public boolean updateAvailable() {

View File

@@ -6,25 +6,11 @@ import java.util.Locale;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
import net.i2p.util.FileUtil; import net.i2p.util.FileUtil;
public class ContentHelper { public class ContentHelper extends HelperBase {
private String _page; private String _page;
private int _maxLines; private int _maxLines;
private boolean _startAtBeginning; private boolean _startAtBeginning;
private String _lang; private String _lang;
private RouterContext _context;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public ContentHelper() {} public ContentHelper() {}

View File

@@ -11,27 +11,12 @@ import net.i2p.data.DataHelper;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
import net.i2p.stat.Rate; import net.i2p.stat.Rate;
public class GraphHelper { public class GraphHelper extends HelperBase {
private RouterContext _context;
private Writer _out;
private int _periodCount; private int _periodCount;
private boolean _showEvents; private boolean _showEvents;
private int _width; private int _width;
private int _height; private int _height;
private int _refreshDelaySeconds; private int _refreshDelaySeconds;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public GraphHelper() { public GraphHelper() {
_periodCount = 60; // SummaryListener.PERIODS; _periodCount = 60; // SummaryListener.PERIODS;
@@ -41,7 +26,6 @@ public class GraphHelper {
_refreshDelaySeconds = 60; _refreshDelaySeconds = 60;
} }
public void setOut(Writer out) { _out = out; }
public void setPeriodCount(String str) { public void setPeriodCount(String str) {
try { _periodCount = Integer.parseInt(str); } catch (NumberFormatException nfe) {} try { _periodCount = Integer.parseInt(str); } catch (NumberFormatException nfe) {}
} }

View File

@@ -0,0 +1,29 @@
package net.i2p.router.web;
import java.io.Writer;
import net.i2p.router.RouterContext;
/**
* Base helper
*/
public abstract class HelperBase {
protected RouterContext _context;
protected Writer _out;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public void setWriter(Writer out) { _out = out; }
}

View File

@@ -7,27 +7,9 @@ import java.io.Writer;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
public class JobQueueHelper { public class JobQueueHelper extends HelperBase {
private RouterContext _context;
private Writer _out;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public JobQueueHelper() {} public JobQueueHelper() {}
public void setWriter(Writer writer) { _out = writer; }
public String getJobQueueSummary() { public String getJobQueueSummary() {
try { try {
if (_out != null) { if (_out != null) {

View File

@@ -5,22 +5,7 @@ import java.util.List;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
import net.i2p.util.FileUtil; import net.i2p.util.FileUtil;
public class LogsHelper { public class LogsHelper extends HelperBase {
private RouterContext _context;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public LogsHelper() {} public LogsHelper() {}
public String getLogs() { public String getLogs() {

View File

@@ -6,22 +6,8 @@ import java.util.Map;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
public class NavHelper { public class NavHelper extends HelperBase {
private static Map _apps = new HashMap(); private static Map _apps = new HashMap();
private RouterContext _context;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public NavHelper() {} public NavHelper() {}

View File

@@ -7,29 +7,12 @@ import java.io.Writer;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
public class NetDbHelper { public class NetDbHelper extends HelperBase {
private RouterContext _context;
private Writer _out;
private String _routerPrefix; private String _routerPrefix;
private boolean _full = false; private boolean _full = false;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public NetDbHelper() {} public NetDbHelper() {}
public void setWriter(Writer writer) { _out = writer; }
public void setRouter(String r) { _routerPrefix = r; } public void setRouter(String r) { _routerPrefix = r; }
public void setFull(String f) { _full = "1".equals(f); }; public void setFull(String f) { _full = "1".equals(f); };

View File

@@ -7,22 +7,7 @@ import net.i2p.router.RouterContext;
* Simple helper to query the appropriate router for data necessary to render * Simple helper to query the appropriate router for data necessary to render
* any emergency notices * any emergency notices
*/ */
public class NoticeHelper { public class NoticeHelper extends HelperBase {
private RouterContext _context;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public String getSystemNotice() { public String getSystemNotice() {
if (true) return ""; // moved to the left hand nav if (true) return ""; // moved to the left hand nav
if (_context.router().gracefulShutdownInProgress()) { if (_context.router().gracefulShutdownInProgress()) {
@@ -35,4 +20,4 @@ public class NoticeHelper {
return ""; return "";
} }
} }
} }

View File

@@ -8,29 +8,9 @@ import java.io.Writer;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
import net.i2p.router.admin.StatsGenerator; import net.i2p.router.admin.StatsGenerator;
public class OldConsoleHelper { public class OldConsoleHelper extends HelperBase {
private RouterContext _context;
private Writer _out;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public OldConsoleHelper() {} public OldConsoleHelper() {}
public void setWriter(Writer writer) {
_out = writer;
}
public String getConsole() { public String getConsole() {
try { try {
if (_out != null) { if (_out != null) {

View File

@@ -5,28 +5,12 @@ import java.io.Writer;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
public class PeerHelper { public class PeerHelper extends HelperBase {
private RouterContext _context;
private Writer _out;
private int _sortFlags; private int _sortFlags;
private String _urlBase; private String _urlBase;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public PeerHelper() {} public PeerHelper() {}
public void setOut(Writer out) { _out = out; }
public void setSort(String flags) { public void setSort(String flags) {
if (flags != null) { if (flags != null) {
try { try {

View File

@@ -6,22 +6,7 @@ import java.io.OutputStreamWriter;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
public class ProfilesHelper { public class ProfilesHelper extends HelperBase {
private RouterContext _context;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public ProfilesHelper() {} public ProfilesHelper() {}
public String getProfileSummary() { public String getProfileSummary() {

View File

@@ -11,12 +11,10 @@ import net.i2p.router.RouterContext;
* uuuugly. dump the peer profile data if given a peer. * uuuugly. dump the peer profile data if given a peer.
* *
*/ */
public class StatHelper { public class StatHelper extends HelperBase {
private String _peer; private String _peer;
private Writer _writer;
public void setPeer(String peer) { _peer = peer; } public void setPeer(String peer) { _peer = peer; }
public void setWriter(Writer writer) { _writer = writer; }
public String getProfile() { public String getProfile() {
RouterContext ctx = (RouterContext)net.i2p.router.RouterContext.listContexts().get(0); RouterContext ctx = (RouterContext)net.i2p.router.RouterContext.listContexts().get(0);
@@ -25,10 +23,10 @@ public class StatHelper {
Hash peer = (Hash)iter.next(); Hash peer = (Hash)iter.next();
if (peer.toBase64().startsWith(_peer)) { if (peer.toBase64().startsWith(_peer)) {
try { try {
WriterOutputStream wos = new WriterOutputStream(_writer); WriterOutputStream wos = new WriterOutputStream(_out);
ctx.profileOrganizer().exportProfile(peer, wos); ctx.profileOrganizer().exportProfile(peer, wos);
wos.flush(); wos.flush();
_writer.flush(); _out.flush();
return ""; return "";
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@@ -25,22 +25,7 @@ import net.i2p.stat.RateStat;
* Simple helper to query the appropriate router for data necessary to render * Simple helper to query the appropriate router for data necessary to render
* the summary sections on the router console. * the summary sections on the router console.
*/ */
public class SummaryHelper { public class SummaryHelper extends HelperBase {
private RouterContext _context;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
/** /**
* Retrieve the shortened 4 character ident for the router located within * Retrieve the shortened 4 character ident for the router located within
* the current JVM at the given context. * the current JVM at the given context.

View File

@@ -7,27 +7,9 @@ import java.io.Writer;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
public class TunnelHelper { public class TunnelHelper extends HelperBase {
private RouterContext _context;
private Writer _out;
/**
* Configure this bean to query a particular router context
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
} catch (Throwable t) {
t.printStackTrace();
}
}
public TunnelHelper() {} public TunnelHelper() {}
public void setWriter(Writer writer) { _out = writer; }
public String getTunnelSummary() { public String getTunnelSummary() {
try { try {
if (_out != null) { if (_out != null) {

View File

@@ -14,7 +14,7 @@
<jsp:useBean class="net.i2p.router.web.GraphHelper" id="graphHelper" scope="request" /> <jsp:useBean class="net.i2p.router.web.GraphHelper" id="graphHelper" scope="request" />
<jsp:setProperty name="graphHelper" property="*" /> <jsp:setProperty name="graphHelper" property="*" />
<jsp:setProperty name="graphHelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" /> <jsp:setProperty name="graphHelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
<jsp:setProperty name="graphHelper" property="out" value="<%=out%>" /> <jsp:setProperty name="graphHelper" property="writer" value="<%=out%>" />
<jsp:getProperty name="graphHelper" property="images" /> <jsp:getProperty name="graphHelper" property="images" />
<jsp:getProperty name="graphHelper" property="form" /> <jsp:getProperty name="graphHelper" property="form" />
</div> </div>

View File

@@ -13,7 +13,7 @@
<div class="main" id="main"> <div class="main" id="main">
<jsp:useBean class="net.i2p.router.web.PeerHelper" id="peerHelper" scope="request" /> <jsp:useBean class="net.i2p.router.web.PeerHelper" id="peerHelper" scope="request" />
<jsp:setProperty name="peerHelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" /> <jsp:setProperty name="peerHelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
<jsp:setProperty name="peerHelper" property="out" value="<%=out%>" /> <jsp:setProperty name="peerHelper" property="writer" value="<%=out%>" />
<jsp:setProperty name="peerHelper" property="urlBase" value="peers.jsp" /> <jsp:setProperty name="peerHelper" property="urlBase" value="peers.jsp" />
<jsp:setProperty name="peerHelper" property="sort" value="<%=request.getParameter("sort") != null ? request.getParameter("sort") : ""%>" /> <jsp:setProperty name="peerHelper" property="sort" value="<%=request.getParameter("sort") != null ? request.getParameter("sort") : ""%>" />
<jsp:getProperty name="peerHelper" property="peerSummary" /> <jsp:getProperty name="peerHelper" property="peerSummary" />

View File

@@ -12,6 +12,9 @@
<jsp:setProperty name="uhelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" /> <jsp:setProperty name="uhelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
<div class="routersummary"> <div class="routersummary">
<center><b><a href="config.jsp">Configuration</a>&nbsp;&nbsp;<a href="help.jsp">Help</a></b></center>
<hr />
<u><b>General</b></u><br /> <u><b>General</b></u><br />
<b>Ident:</b> (<a title="Your router identity is <jsp:getProperty name="helper" property="ident" />, never reveal it to anyone" href="netdb.jsp?r=.">view</a>)<br /> <b>Ident:</b> (<a title="Your router identity is <jsp:getProperty name="helper" property="ident" />, never reveal it to anyone" href="netdb.jsp?r=.">view</a>)<br />
<b>Version:</b> <jsp:getProperty name="helper" property="version" /><br /> <b>Version:</b> <jsp:getProperty name="helper" property="version" /><br />
@@ -60,11 +63,9 @@
if (prev != null) System.setProperty("net.i2p.router.web.ReseedHandler.noncePrev", prev); if (prev != null) System.setProperty("net.i2p.router.web.ReseedHandler.noncePrev", prev);
System.setProperty("net.i2p.router.web.ReseedHandler.nonce", nonce+""); System.setProperty("net.i2p.router.web.ReseedHandler.nonce", nonce+"");
String uri = request.getRequestURI(); String uri = request.getRequestURI();
if (uri.indexOf('?') > 0) out.print("<p><form action=\"" + uri + "\" method=\"GET\">\n");
uri = uri + "&reseedNonce=" + nonce; out.print("<input type=\"hidden\" name=\"reseedNonce\" value=\"" + nonce + "\" >\n");
else out.print("<button type=\"submit\" >Reseed</button></form></p>\n");
uri = uri + "?reseedNonce=" + nonce;
out.print(" <a href=\"" + uri + "\">reseed</a><br />");
} }
} }
// If a new reseed ain't running, and the last reseed had errors, show error message // If a new reseed ain't running, and the last reseed had errors, show error message
@@ -97,6 +98,5 @@
<b>Tunnel lag:</b> <jsp:getProperty name="helper" property="tunnelLag" /><br /> <b>Tunnel lag:</b> <jsp:getProperty name="helper" property="tunnelLag" /><br />
<b>Handle backlog:</b> <jsp:getProperty name="helper" property="inboundBacklog" /><br /> <b>Handle backlog:</b> <jsp:getProperty name="helper" property="inboundBacklog" /><br />
<b><jsp:getProperty name="helper" property="tunnelStatus" /></b><br /> <b><jsp:getProperty name="helper" property="tunnelStatus" /></b><br />
<hr />
</div> </div>