* Routerconsole:
- Move common methods to new HelperBase class - Make reseed link a button
This commit is contained in:
@ -6,22 +6,7 @@ import java.util.TreeSet;
|
||||
|
||||
import net.i2p.router.RouterContext;
|
||||
|
||||
public class ConfigAdvancedHelper {
|
||||
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 class ConfigAdvancedHelper extends HelperBase {
|
||||
public ConfigAdvancedHelper() {}
|
||||
|
||||
public String getSettings() {
|
||||
|
@ -9,22 +9,7 @@ import java.util.TreeSet;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.router.startup.ClientAppConfig;
|
||||
|
||||
public class ConfigClientsHelper {
|
||||
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 class ConfigClientsHelper extends HelperBase {
|
||||
public ConfigClientsHelper() {}
|
||||
|
||||
public String getForm1() {
|
||||
|
@ -6,22 +6,7 @@ import java.io.OutputStreamWriter;
|
||||
|
||||
import net.i2p.router.RouterContext;
|
||||
|
||||
public class ConfigKeyringHelper {
|
||||
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 class ConfigKeyringHelper extends HelperBase {
|
||||
public ConfigKeyringHelper() {}
|
||||
|
||||
public String getSummary() {
|
||||
|
@ -6,22 +6,7 @@ import java.util.TreeSet;
|
||||
|
||||
import net.i2p.router.RouterContext;
|
||||
|
||||
public class ConfigLoggingHelper {
|
||||
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 class ConfigLoggingHelper extends HelperBase {
|
||||
public ConfigLoggingHelper() {}
|
||||
|
||||
public String getLogFilePattern() {
|
||||
|
@ -10,22 +10,7 @@ import net.i2p.router.transport.udp.UDPAddress;
|
||||
import net.i2p.router.transport.udp.UDPTransport;
|
||||
import net.i2p.time.Timestamper;
|
||||
|
||||
public class ConfigNetHelper {
|
||||
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 class ConfigNetHelper extends HelperBase {
|
||||
public ConfigNetHelper() {}
|
||||
|
||||
/** copied from various private components */
|
||||
|
@ -4,25 +4,9 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.router.RouterContext;
|
||||
|
||||
public class ConfigPeerHelper {
|
||||
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 class ConfigPeerHelper extends HelperBase {
|
||||
public ConfigPeerHelper() {}
|
||||
|
||||
public String getBlocklistSummary() {
|
||||
|
@ -15,8 +15,7 @@ import net.i2p.stat.RateStat;
|
||||
import net.i2p.stat.StatManager;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
public class ConfigStatsHelper {
|
||||
private RouterContext _context;
|
||||
public class ConfigStatsHelper extends HelperBase {
|
||||
private Log _log;
|
||||
private String _filter;
|
||||
private Set _filters;
|
||||
|
@ -8,22 +8,7 @@ import net.i2p.data.Destination;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.router.TunnelPoolSettings;
|
||||
|
||||
public class ConfigTunnelsHelper {
|
||||
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 class ConfigTunnelsHelper extends HelperBase {
|
||||
public ConfigTunnelsHelper() {}
|
||||
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class ConfigUpdateHandler extends FormHandler {
|
||||
if ( (_updatePolicy == null) || (!_updatePolicy.equals("notify")) )
|
||||
addFormNotice("Update available, attempting to download now");
|
||||
else
|
||||
addFormNotice("Update available, click link on left to download");
|
||||
addFormNotice("Update available, click button on left to download");
|
||||
} else
|
||||
addFormNotice("No update available");
|
||||
}
|
||||
|
@ -4,22 +4,7 @@ import net.i2p.crypto.TrustedUpdate;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.router.RouterContext;
|
||||
|
||||
public class ConfigUpdateHelper {
|
||||
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 class ConfigUpdateHelper extends HelperBase {
|
||||
public ConfigUpdateHelper() {}
|
||||
|
||||
public boolean updateAvailable() {
|
||||
|
@ -6,25 +6,11 @@ import java.util.Locale;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.util.FileUtil;
|
||||
|
||||
public class ContentHelper {
|
||||
public class ContentHelper extends HelperBase {
|
||||
private String _page;
|
||||
private int _maxLines;
|
||||
private boolean _startAtBeginning;
|
||||
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() {}
|
||||
|
||||
|
@ -11,27 +11,12 @@ import net.i2p.data.DataHelper;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.stat.Rate;
|
||||
|
||||
public class GraphHelper {
|
||||
private RouterContext _context;
|
||||
private Writer _out;
|
||||
public class GraphHelper extends HelperBase {
|
||||
private int _periodCount;
|
||||
private boolean _showEvents;
|
||||
private int _width;
|
||||
private int _height;
|
||||
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() {
|
||||
_periodCount = 60; // SummaryListener.PERIODS;
|
||||
@ -41,7 +26,6 @@ public class GraphHelper {
|
||||
_refreshDelaySeconds = 60;
|
||||
}
|
||||
|
||||
public void setOut(Writer out) { _out = out; }
|
||||
public void setPeriodCount(String str) {
|
||||
try { _periodCount = Integer.parseInt(str); } catch (NumberFormatException nfe) {}
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
@ -7,27 +7,9 @@ import java.io.Writer;
|
||||
|
||||
import net.i2p.router.RouterContext;
|
||||
|
||||
public class JobQueueHelper {
|
||||
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 class JobQueueHelper extends HelperBase {
|
||||
public JobQueueHelper() {}
|
||||
|
||||
public void setWriter(Writer writer) { _out = writer; }
|
||||
|
||||
public String getJobQueueSummary() {
|
||||
try {
|
||||
if (_out != null) {
|
||||
|
@ -5,22 +5,7 @@ import java.util.List;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.util.FileUtil;
|
||||
|
||||
public class LogsHelper {
|
||||
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 class LogsHelper extends HelperBase {
|
||||
public LogsHelper() {}
|
||||
|
||||
public String getLogs() {
|
||||
|
@ -6,22 +6,8 @@ import java.util.Map;
|
||||
|
||||
import net.i2p.router.RouterContext;
|
||||
|
||||
public class NavHelper {
|
||||
public class NavHelper extends HelperBase {
|
||||
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() {}
|
||||
|
||||
|
@ -7,29 +7,12 @@ import java.io.Writer;
|
||||
|
||||
import net.i2p.router.RouterContext;
|
||||
|
||||
public class NetDbHelper {
|
||||
private RouterContext _context;
|
||||
private Writer _out;
|
||||
public class NetDbHelper extends HelperBase {
|
||||
private String _routerPrefix;
|
||||
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 void setWriter(Writer writer) { _out = writer; }
|
||||
public void setRouter(String r) { _routerPrefix = r; }
|
||||
public void setFull(String f) { _full = "1".equals(f); };
|
||||
|
||||
|
@ -7,22 +7,7 @@ import net.i2p.router.RouterContext;
|
||||
* Simple helper to query the appropriate router for data necessary to render
|
||||
* any emergency notices
|
||||
*/
|
||||
public class NoticeHelper {
|
||||
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 class NoticeHelper extends HelperBase {
|
||||
public String getSystemNotice() {
|
||||
if (true) return ""; // moved to the left hand nav
|
||||
if (_context.router().gracefulShutdownInProgress()) {
|
||||
@ -35,4 +20,4 @@ public class NoticeHelper {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,29 +8,9 @@ import java.io.Writer;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.router.admin.StatsGenerator;
|
||||
|
||||
public class OldConsoleHelper {
|
||||
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 class OldConsoleHelper extends HelperBase {
|
||||
public OldConsoleHelper() {}
|
||||
|
||||
public void setWriter(Writer writer) {
|
||||
_out = writer;
|
||||
}
|
||||
|
||||
public String getConsole() {
|
||||
try {
|
||||
if (_out != null) {
|
||||
|
@ -5,28 +5,12 @@ import java.io.Writer;
|
||||
|
||||
import net.i2p.router.RouterContext;
|
||||
|
||||
public class PeerHelper {
|
||||
private RouterContext _context;
|
||||
private Writer _out;
|
||||
public class PeerHelper extends HelperBase {
|
||||
private int _sortFlags;
|
||||
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 void setOut(Writer out) { _out = out; }
|
||||
public void setSort(String flags) {
|
||||
if (flags != null) {
|
||||
try {
|
||||
|
@ -6,22 +6,7 @@ import java.io.OutputStreamWriter;
|
||||
|
||||
import net.i2p.router.RouterContext;
|
||||
|
||||
public class ProfilesHelper {
|
||||
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 class ProfilesHelper extends HelperBase {
|
||||
public ProfilesHelper() {}
|
||||
|
||||
public String getProfileSummary() {
|
||||
|
@ -11,12 +11,10 @@ import net.i2p.router.RouterContext;
|
||||
* uuuugly. dump the peer profile data if given a peer.
|
||||
*
|
||||
*/
|
||||
public class StatHelper {
|
||||
public class StatHelper extends HelperBase {
|
||||
private String _peer;
|
||||
private Writer _writer;
|
||||
|
||||
public void setPeer(String peer) { _peer = peer; }
|
||||
public void setWriter(Writer writer) { _writer = writer; }
|
||||
|
||||
public String getProfile() {
|
||||
RouterContext ctx = (RouterContext)net.i2p.router.RouterContext.listContexts().get(0);
|
||||
@ -25,10 +23,10 @@ public class StatHelper {
|
||||
Hash peer = (Hash)iter.next();
|
||||
if (peer.toBase64().startsWith(_peer)) {
|
||||
try {
|
||||
WriterOutputStream wos = new WriterOutputStream(_writer);
|
||||
WriterOutputStream wos = new WriterOutputStream(_out);
|
||||
ctx.profileOrganizer().exportProfile(peer, wos);
|
||||
wos.flush();
|
||||
_writer.flush();
|
||||
_out.flush();
|
||||
return "";
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -25,22 +25,7 @@ import net.i2p.stat.RateStat;
|
||||
* Simple helper to query the appropriate router for data necessary to render
|
||||
* the summary sections on the router console.
|
||||
*/
|
||||
public class SummaryHelper {
|
||||
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 class SummaryHelper extends HelperBase {
|
||||
/**
|
||||
* Retrieve the shortened 4 character ident for the router located within
|
||||
* the current JVM at the given context.
|
||||
|
@ -7,27 +7,9 @@ import java.io.Writer;
|
||||
|
||||
import net.i2p.router.RouterContext;
|
||||
|
||||
public class TunnelHelper {
|
||||
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 class TunnelHelper extends HelperBase {
|
||||
public TunnelHelper() {}
|
||||
|
||||
public void setWriter(Writer writer) { _out = writer; }
|
||||
|
||||
public String getTunnelSummary() {
|
||||
try {
|
||||
if (_out != null) {
|
||||
|
Reference in New Issue
Block a user