I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit b6846324 authored by jrandom's avatar jrandom Committed by zzz
Browse files

first pass at the 0.4 architecture. not ready for use or integration yet, but...

first pass at the 0.4 architecture.  not ready for use or integration yet, but is functional with some manual build/config work
parent 740a2da7
No related branches found
No related tags found
No related merge requests found
Showing
with 1320 additions and 0 deletions
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="all" name="routerconsole">
<target name="all" depends="clean, build" />
<target name="build" depends="builddep, jar" />
<target name="builddep" depends="jetty" >
<ant dir="../../../router/java/" target="build" />
<!-- router will build core -->
</target>
<target name="jetty">
<untar src="jetty-4.2.21-min.tar.bz2" compression="bzip2" dest="." />
<ant dir="jetty-4.2.21-min/extra/jdk1.2/" target="all" />
</target>
<target name="compile">
<mkdir dir="./build" />
<mkdir dir="./build/obj" />
<javac
srcdir="./src"
debug="true" deprecation="on" source="1.3" target="1.3"
destdir="./build/obj"
classpath="../../../core/java/build/i2p.jar:../../../router/java/build/router.jar:jetty-4.2.21-min/extra/lib/org.mortbay.jetty-jdk1.2.jar" />
</target>
<target name="jar" depends="compile">
<jar destfile="./build/routerconsole.jar" basedir="./build/obj" includes="**/*.class">
<manifest>
<attribute name="Class-Path" value="i2p.jar router.jar" />
</manifest>
</jar>
<ant target="war" />
</target>
<target name="war">
<war destfile="build/routerconsole.war" webxml="../jsp/web.xml"
basedir="../jsp/" excludes="web.xml">
</war>
</target>
<target name="javadoc">
<mkdir dir="./build" />
<mkdir dir="./build/javadoc" />
<javadoc
sourcepath="./src:../../../core/java/src:../../router/java/src" destdir="./build/javadoc"
packagenames="*"
use="true"
splitindex="true"
windowtitle="Router Console" />
</target>
<target name="clean">
<delete dir="./build" />
</target>
<target name="cleandep" depends="clean">
<!-- router will clean core -->
<ant dir="../../../router/java/" target="distclean" />
</target>
<target name="distclean" depends="clean">
<!-- router will clean core -->
<ant dir="../../../router/java/" target="distclean" />
<delete dir="./jetty-4.2.21-min" />
</target>
</project>
package net.i2p.router.web;
import java.util.Iterator;
import java.util.Set;
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 ConfigAdvancedHelper() {}
public String getSettings() {
StringBuffer buf = new StringBuffer(4*1024);
Set names = _context.router().getConfigSettings();
TreeSet sortedNames = new TreeSet(names);
for (Iterator iter = sortedNames.iterator(); iter.hasNext(); ) {
String name = (String)iter.next();
String val = _context.router().getConfigSetting(name);
buf.append(name).append('=').append(val).append('\n');
}
return buf.toString();
}
}
package net.i2p.router.web;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.Iterator;
import java.util.TreeMap;
import net.i2p.util.Log;
import net.i2p.router.RouterContext;
import net.i2p.router.ClientTunnelSettings;
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();
}
}
/** copied from the package private {@link net.i2p.router.tunnelmanager.TunnelPool} */
public final static String TARGET_CLIENTS_PARAM = "router.targetClients";
/** copied from the package private {@link net.i2p.router.tunnelmanager.TunnelPool} */
public final static int TARGET_CLIENTS_DEFAULT = 3;
public ConfigClientsHelper() {}
public String getClientCountSelectBox() {
int count = TARGET_CLIENTS_DEFAULT;
String val = _context.router().getConfigSetting(TARGET_CLIENTS_PARAM);
if (val != null) {
try {
count = Integer.parseInt(val);
} catch (NumberFormatException nfe) {
// ignore, use default from above
}
}
StringBuffer buf = new StringBuffer(1024);
buf.append("<select name=\"clientcount\">\n");
for (int i = 0; i < 5; i++) {
buf.append("<option value=\"").append(i).append("\" ");
if (count == i)
buf.append("selected=\"true\" ");
buf.append(">").append(i).append("</option>\n");
}
if (count >= 5) {
buf.append("<option value=\"").append(count);
buf.append("\" selected>").append(count);
buf.append("</option>\n");
}
buf.append("</select>\n");
return buf.toString();
}
public String getTunnelCountSelectBox() {
int count = ClientTunnelSettings.DEFAULT_NUM_INBOUND;
String val = _context.router().getConfigSetting(ClientTunnelSettings.PROP_NUM_INBOUND);
if (val != null) {
try {
count = Integer.parseInt(val);
} catch (NumberFormatException nfe) {
// ignore, use default from above
}
}
StringBuffer buf = new StringBuffer(1024);
buf.append("<select name=\"tunnelcount\">\n");
for (int i = 0; i < 4; i++) {
buf.append("<option value=\"").append(i).append("\" ");
if (count == i)
buf.append("selected=\"true\" ");
buf.append(">").append(i).append("</option>\n");
}
if (count >= 4) {
buf.append("<option value=\"").append(count);
buf.append("\" selected>").append(count);
buf.append("</option>\n");
}
buf.append("</select>\n");
return buf.toString();
}
public String getTunnelDepthSelectBox() {
int count = ClientTunnelSettings.DEFAULT_DEPTH_INBOUND;
String val = _context.router().getConfigSetting(ClientTunnelSettings.PROP_DEPTH_INBOUND);
if (val != null) {
try {
count = Integer.parseInt(val);
} catch (NumberFormatException nfe) {
// ignore, use default from above
}
}
StringBuffer buf = new StringBuffer(1024);
buf.append("<select name=\"tunneldepth\">\n");
for (int i = 0; i < 4; i++) {
buf.append("<option value=\"").append(i).append("\" ");
if (count == i)
buf.append("selected=\"true\" ");
buf.append(">").append(i).append("</option>\n");
}
if (count >= 4) {
buf.append("<option value=\"").append(count);
buf.append("\" selected>").append(count);
buf.append("</option>\n");
}
buf.append("</select>\n");
return buf.toString();
}
}
package net.i2p.router.web;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.Iterator;
import java.util.TreeMap;
import net.i2p.util.Log;
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 ConfigLoggingHelper() {}
public String getLogFilePattern() {
return _context.logManager().getBaseLogfilename();
}
public String getRecordPattern() {
return new String(_context.logManager().getFormat());
}
public String getDatePattern() {
return _context.logManager().getDateFormatPattern();
}
public String getMaxFileSize() {
int bytes = _context.logManager().getFileSize();
if (bytes == 0) return "1m";
if (bytes > 1024*1024*1024)
return (bytes/(1024*1024*1024)) + "g";
else if (bytes > 1024*1024)
return (bytes/(1024*1024)) + "m";
else
return (bytes/(1024)) + "k";
}
public String getLogLevelTable() {
StringBuffer buf = new StringBuffer(32*1024);
buf.append("<textarea rows=\"20\" cols=\"80\">");
List logs = _context.logManager().getLogs();
TreeMap sortedLogs = new TreeMap();
for (int i = 0; i < logs.size(); i++) {
Log l = (Log)logs.get(i);
sortedLogs.put(l.getName(), l);
}
int i = 0;
for (Iterator iter = sortedLogs.values().iterator(); iter.hasNext(); i++) {
Log l = (Log)iter.next();
buf.append(l.getName()).append('=');
buf.append(Log.toLevelString(l.getMinimumPriority()));
buf.append("\n");
}
buf.append("</textarea><br />\n");
buf.append("<i>Valid levels are DEBUG, INFO, WARN, ERROR, CRIT</i>\n");
return buf.toString();
}
public String getLogLevelTableDetail() {
StringBuffer buf = new StringBuffer(8*1024);
buf.append("<table border=\"1\">\n");
buf.append("<tr><td>Package/class</td><td>Level</td></tr>\n");
List logs = _context.logManager().getLogs();
TreeMap sortedLogs = new TreeMap();
for (int i = 0; i < logs.size(); i++) {
Log l = (Log)logs.get(i);
sortedLogs.put(l.getName(), l);
}
int i = 0;
for (Iterator iter = sortedLogs.values().iterator(); iter.hasNext(); i++) {
Log l = (Log)iter.next();
buf.append("<tr>\n <td><input size=\"50\" type=\"text\" name=\"logrecord.");
buf.append(i).append(".package\" value=\"").append(l.getName());
buf.append("\" /></td>\n");
buf.append("<td><select name=\"logrecord.").append(i);
buf.append(".level\">\n\t");
buf.append("<option value=\"DEBUG\" ");
if (l.getMinimumPriority() == Log.DEBUG)
buf.append("selected=\"true\" ");
buf.append(">Debug</option>\n\t");
buf.append("<option value=\"INFO\" ");
if (l.getMinimumPriority() == Log.INFO)
buf.append("selected=\"true\" ");
buf.append(">Info</option>\n\t");
buf.append("<option value=\"WARN\" ");
if (l.getMinimumPriority() == Log.WARN)
buf.append("selected=\"true\" ");
buf.append(">Warn</option>\n\t");
buf.append("<option value=\"ERROR\" ");
if (l.getMinimumPriority() == Log.ERROR)
buf.append("selected=\"true\" ");
buf.append(">Error</option>\n\t");
buf.append("<option value=\"CRIT\" ");
if (l.getMinimumPriority() == Log.CRIT)
buf.append("selected=\"true\" ");
buf.append(">Critical</option>\n\t");
buf.append("</select></td>\n</tr>\n");
}
buf.append("</table>\n");
return buf.toString();
}
}
package net.i2p.router.web;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.Iterator;
import java.util.TreeMap;
import net.i2p.util.Log;
import net.i2p.router.RouterContext;
import net.i2p.router.ClientTunnelSettings;
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 ConfigNetHelper() {}
/** copied from various private TCP components */
private final static String PROP_I2NP_TCP_HOSTNAME = "i2np.tcp.hostname";
private final static String PROP_I2NP_TCP_PORT = "i2np.tcp.port";
public String getHostname() {
return _context.getProperty(PROP_I2NP_TCP_HOSTNAME);
}
public String getPort() {
int port = 8887;
String val = _context.getProperty(PROP_I2NP_TCP_PORT);
if (val != null) {
try {
port = Integer.parseInt(val);
} catch (NumberFormatException nfe) {
// ignore, use default from above
}
}
return "" + port;
}
public String getEnableTimeSyncChecked() {
String enabled = System.getProperty("timestamper.enabled");
if ( (enabled == null) || (!"true".equals(enabled)) )
return "";
else
return " checked ";
}
public static final String PROP_INBOUND_KBPS = "i2np.bandwidth.inboundKBytesPerSecond";
public static final String PROP_OUTBOUND_KBPS = "i2np.bandwidth.outboundKBytesPerSecond";
public static final String PROP_INBOUND_BURST = "i2np.bandwidth.inboundBurstKBytes";
public static final String PROP_OUTBOUND_BURST = "i2np.bandwidth.outboundBurstKBytes";
public String getInboundRate() {
String rate = _context.getProperty(PROP_INBOUND_KBPS);
if (rate != null)
return rate;
else
return "-1";
}
public String getOutboundRate() {
String rate = _context.getProperty(PROP_OUTBOUND_KBPS);
if (rate != null)
return rate;
else
return "Unlimited";
}
public String getInboundBurstFactorBox() {
String rate = _context.getProperty(PROP_INBOUND_KBPS);
String burst = _context.getProperty(PROP_INBOUND_BURST);
int numSeconds = 1;
if ( (burst != null) && (rate != null) ) {
int rateKBps = 0;
int burstKB = 0;
try {
rateKBps = Integer.parseInt(rate);
burstKB = Integer.parseInt(burst);
} catch (NumberFormatException nfe) {
// ignore
}
if ( (rateKBps > 0) && (burstKB > 0) ) {
numSeconds = burstKB / rateKBps;
}
}
return getBurstFactor(numSeconds, "inboundburstfactor");
}
public String getOutboundBurstFactorBox() {
String rate = _context.getProperty(PROP_OUTBOUND_KBPS);
String burst = _context.getProperty(PROP_OUTBOUND_BURST);
int numSeconds = 1;
if ( (burst != null) && (rate != null) ) {
int rateKBps = 0;
int burstKB = 0;
try {
rateKBps = Integer.parseInt(rate);
burstKB = Integer.parseInt(burst);
} catch (NumberFormatException nfe) {
// ignore
}
if ( (rateKBps > 0) && (burstKB > 0) ) {
numSeconds = burstKB / rateKBps;
}
}
return getBurstFactor(numSeconds, "outboundburstfactor");
}
private static String getBurstFactor(int numSeconds, String name) {
StringBuffer buf = new StringBuffer(256);
buf.append("<select name=\"").append(name).append("\">\n");
for (int i = 1; i < 10; i++) {
buf.append("<option value=\"").append(i).append("\" ");
if ( (i == numSeconds) || (i == 10) )
buf.append("selected ");
buf.append(">");
if (i == 1)
buf.append("1 second (no burst)</option>\n");
else
buf.append(i).append(" seconds</option>\n");
}
buf.append("</select>\n");
return buf.toString();
}
}
package net.i2p.router.web;
import java.util.List;
import net.i2p.data.Hash;
import net.i2p.router.RouterContext;
class ContextHelper {
public static RouterContext getContext(String contextId) {
List contexts = RouterContext.listContexts();
if ( (contexts == null) || (contexts.size() <= 0) )
throw new IllegalStateException("No contexts? wtf");
if ( (contextId == null) || (contextId.trim().length() <= 0) )
return (RouterContext)contexts.get(0);
for (int i = 0; i < contexts.size(); i++) {
RouterContext context = (RouterContext)contexts.get(i);
Hash hash = context.routerHash();
if (hash == null) continue;
if (hash.toBase64().startsWith(contextId))
return context;
}
// not found, so just give them the first we can find
return (RouterContext)contexts.get(0);
}
}
\ No newline at end of file
package net.i2p.router.web;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
import net.i2p.router.RouterContext;
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 LogsHelper() {}
public String getLogs() {
List msgs = _context.logManager().getBuffer().getMostRecentMessages();
StringBuffer buf = new StringBuffer(16*1024);
buf.append("<h2>Most recent console messages:</h2><ul>");
buf.append("<code>\n");
for (int i = 0; i < msgs.size(); i++) {
String msg = (String)msgs.get(i);
buf.append("<li>");
buf.append(msg);
buf.append("</li>\n");
}
buf.append("</code></ul>\n");
return buf.toString();
}
}
package net.i2p.router.web;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import net.i2p.router.RouterContext;
public class NavHelper {
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() {}
/**
* To register a new client application so that it shows up on the router
* console's nav bar, it should be registered with this singleton.
*
* @param name pretty name the app will be called in the link
* @param path full path pointing to the application's root
* (e.g. /i2ptunnel/index.jsp)
*/
public static void registerApp(String name, String path) {
_apps.put(name, path);
}
public static void unregisterApp(String name) {
_apps.remove(name);
}
public String getClientAppLinks() {
StringBuffer buf = new StringBuffer(1024);
for (Iterator iter = _apps.keySet().iterator(); iter.hasNext(); ) {
String name = (String)iter.next();
String path = (String)_apps.get(name);
buf.append("<a href=\"").append(path).append("\">");
buf.append(name).append("</a> |");
}
return buf.toString();
}
}
package net.i2p.router.web;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import net.i2p.router.RouterContext;
public class NetDbHelper {
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 NetDbHelper() {}
public String getNetDbSummary() {
ByteArrayOutputStream baos = new ByteArrayOutputStream(32*1024);
try {
_context.netDb().renderStatusHTML(baos);
} catch (IOException ioe) {
ioe.printStackTrace();
}
return new String(baos.toByteArray());
}
}
package net.i2p.router.web;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
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 ProfilesHelper() {}
public String getProfileSummary() {
ByteArrayOutputStream baos = new ByteArrayOutputStream(16*1024);
try {
_context.profileOrganizer().renderStatusHTML(baos);
} catch (IOException ioe) {
ioe.printStackTrace();
}
return new String(baos.toByteArray());
}
}
package net.i2p.router.web;
import java.io.IOException;
import org.mortbay.jetty.Server;
import org.mortbay.util.MultiException;
public class RouterConsoleRunner {
private Server _server;
private String _listenPort = "7657";
private String _listenHost = "0.0.0.0";
private String _webAppsDir = "./webapps/";
public RouterConsoleRunner(String args[]) {
if (args.length == 3) {
_listenPort = args[0].trim();
_listenHost = args[1].trim();
_webAppsDir = args[2].trim();
}
}
public static void main(String args[]) {
RouterConsoleRunner runner = new RouterConsoleRunner(args);
runner.startConsole();
}
public void startConsole() {
_server = new Server();
try {
_server.addListener(_listenHost + ':' + _listenPort);
_server.setRootWebApp("routerconsole");
_server.addWebApplications(_webAppsDir);
} catch (IOException ioe) {
ioe.printStackTrace();
}
try {
_server.start();
} catch (MultiException me) {
me.printStackTrace();
}
}
public void stopConsole() {
try {
_server.stop();
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
}
package net.i2p.router.web;
import java.text.DecimalFormat;
import net.i2p.data.DataHelper;
import net.i2p.stat.Rate;
import net.i2p.stat.RateStat;
import net.i2p.router.Router;
import net.i2p.router.RouterContext;
import net.i2p.router.RouterVersion;
/**
* 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();
}
}
/**
* Retrieve the shortened 4 character ident for the router located within
* the current JVM at the given context.
*
*/
public String getIdent() {
if (_context == null) return "[no router]";
if (_context.routerHash() != null)
return _context.routerHash().toBase64().substring(0, 4);
else
return "[unknown]";
}
/**
* Retrieve the version number of the router.
*
*/
public String getVersion() {
return RouterVersion.VERSION;
}
/**
* Retrieve a pretty printed uptime count (ala 4d or 7h or 39m)
*
*/
public String getUptime() {
if (_context == null) return "[no router]";
Router router = _context.router();
if (router == null)
return "[not up]";
else
return DataHelper.formatDuration(router.getUptime());
}
/**
* How many active peers the router has.
*
*/
public int getActivePeers() {
if (_context == null)
return 0;
else
return _context.profileOrganizer().countActivePeers();
}
/**
* How many active peers the router ranks as fast.
*
*/
public int getFastPeers() {
if (_context == null)
return 0;
else
return _context.profileOrganizer().countFastPeers();
}
/**
* How many active peers the router ranks as having a high capacity.
*
*/
public int getHighCapacityPeers() {
if (_context == null)
return 0;
else
return _context.profileOrganizer().countHighCapacityPeers();
}
/**
* How many active peers the router ranks as well integrated.
*
*/
public int getWellIntegratedPeers() {
if (_context == null)
return 0;
else
return _context.profileOrganizer().countWellIntegratedPeers();
}
/**
* How many peers the router ranks as failing.
*
*/
public int getFailingPeers() {
if (_context == null)
return 0;
else
return _context.profileOrganizer().countFailingPeers();
}
/**
* How many peers totally suck.
*
*/
public int getShitlistedPeers() {
if (_context == null)
return 0;
else
return _context.shitlist().getRouterCount();
}
/**
* How fast we have been receiving data over the last minute (pretty printed
* string with 2 decimal places representing the KBps)
*
*/
public String getInboundMinuteKBps() {
if (_context == null)
return "0.0";
RateStat receiveRate = _context.statManager().getRate("transport.receiveMessageSize");
Rate rate = receiveRate.getRate(60*1000);
double bytes = rate.getLastTotalValue();
double bps = (bytes*1000.0d)/(rate.getPeriod()*1024.0d);
DecimalFormat fmt = new DecimalFormat("##0.00");
return fmt.format(bps);
}
/**
* How fast we have been sending data over the last minute (pretty printed
* string with 2 decimal places representing the KBps)
*
*/
public String getOutboundMinuteKBps() {
if (_context == null)
return "0.0";
RateStat receiveRate = _context.statManager().getRate("transport.sendMessageSize");
Rate rate = receiveRate.getRate(60*1000);
double bytes = rate.getLastTotalValue();
double bps = (bytes*1000.0d)/(rate.getPeriod()*1024.0d);
DecimalFormat fmt = new DecimalFormat("##0.00");
return fmt.format(bps);
}
/**
* How fast we have been receiving data over the last 5 minutes (pretty printed
* string with 2 decimal places representing the KBps)
*
*/
public String getInboundFiveMinuteKBps() {
if (_context == null)
return "0.0";
RateStat receiveRate = _context.statManager().getRate("transport.receiveMessageSize");
Rate rate = receiveRate.getRate(5*60*1000);
double bytes = rate.getLastTotalValue();
double bps = (bytes*1000.0d)/(rate.getPeriod()*1024.0d);
DecimalFormat fmt = new DecimalFormat("##0.00");
return fmt.format(bps);
}
/**
* How fast we have been sending data over the last 5 minutes (pretty printed
* string with 2 decimal places representing the KBps)
*
*/
public String getOutboundFiveMinuteKBps() {
if (_context == null)
return "0.0";
RateStat receiveRate = _context.statManager().getRate("transport.sendMessageSize");
Rate rate = receiveRate.getRate(5*60*1000);
double bytes = rate.getLastTotalValue();
double bps = (bytes*1000.0d)/(rate.getPeriod()*1024.0d);
DecimalFormat fmt = new DecimalFormat("##0.00");
return fmt.format(bps);
}
/**
* How fast we have been receiving data since the router started (pretty printed
* string with 2 decimal places representing the KBps)
*
*/
public String getInboundLifetimeKBps() {
if (_context == null)
return "0.0";
long received = _context.bandwidthLimiter().getTotalAllocatedInboundBytes();
DecimalFormat fmt = new DecimalFormat("##0.00");
// we use the unadjusted time, since thats what getWhenStarted is based off
long lifetime = _context.clock().now()-_context.clock().getOffset()
- _context.router().getWhenStarted();
lifetime /= 1000;
if (received > 0) {
double receivedKBps = received / (lifetime*1024.0);
return fmt.format(receivedKBps);
} else {
return "0.0";
}
}
/**
* How fast we have been sending data since the router started (pretty printed
* string with 2 decimal places representing the KBps)
*
*/
public String getOutboundLifetimeKBps() {
if (_context == null)
return "0.0";
long sent = _context.bandwidthLimiter().getTotalAllocatedOutboundBytes();
DecimalFormat fmt = new DecimalFormat("##0.00");
// we use the unadjusted time, since thats what getWhenStarted is based off
long lifetime = _context.clock().now()-_context.clock().getOffset()
- _context.router().getWhenStarted();
lifetime /= 1000;
if (sent > 0) {
double sendKBps = sent / (lifetime*1024.0);
return fmt.format(sendKBps);
} else {
return "0.0";
}
}
/**
* How much data have we received since the router started (pretty printed
* string with 2 decimal places and the appropriate units - GB/MB/KB/bytes)
*
*/
public String getInboundTransferred() {
if (_context == null)
return "0.0";
long received = _context.bandwidthLimiter().getTotalAllocatedInboundBytes();
return getTransferred(received);
}
/**
* How much data have we sent since the router started (pretty printed
* string with 2 decimal places and the appropriate units - GB/MB/KB/bytes)
*
*/
public String getOutboundTransferred() {
if (_context == null)
return "0.0";
long sent = _context.bandwidthLimiter().getTotalAllocatedOutboundBytes();
return getTransferred(sent);
}
private static String getTransferred(long bytes) {
int scale = 0;
if (bytes > 1024*1024*1024) {
// gigs transferred
scale = 3;
bytes /= (1024*1024*1024);
} else if (bytes > 1024*1024) {
// megs transferred
scale = 2;
bytes /= (1024*1024);
} else if (bytes > 1024) {
// kbytes transferred
scale = 1;
bytes /= 1024;
} else {
scale = 0;
}
DecimalFormat fmt = new DecimalFormat("##0.00");
String str = fmt.format(bytes);
switch (scale) {
case 1: return str + "KB";
case 2: return str + "MB";
case 3: return str + "GB";
default: return bytes + "bytes";
}
}
/**
* How many free inbound tunnels we have.
*
* @param contextId begging few characters of the routerHash, or null to pick
* the first one we come across.
*/
public int getInboundTunnels() {
if (_context == null)
return 0;
else
return _context.tunnelManager().getFreeTunnelCount();
}
/**
* How many active outbound tunnels we have.
*
*/
public int getOutboundTunnels() {
if (_context == null)
return 0;
else
return _context.tunnelManager().getOutboundTunnelCount();
}
/**
* How many tunnels we are participating in.
*
*/
public int getParticipatingTunnels() {
if (_context == null)
return 0;
else
return _context.tunnelManager().getParticipatingCount();
}
/**
* How lagged our job queue is over the last minute (pretty printed with
* the units attached)
*
*/
public String getJobLag() {
if (_context == null)
return "0ms";
Rate lagRate = _context.statManager().getRate("jobQueue.jobLag").getRate(60*1000);
return ((int)lagRate.getAverageValue()) + "ms";
}
/**
* How long it takes us to pump out a message, averaged over the last minute
* (pretty printed with the units attached)
*
*/
public String getMessageDelay() {
if (_context == null)
return "0ms";
Rate delayRate = _context.statManager().getRate("transport.sendProcessingTime").getRate(60*1000);
return ((int)delayRate.getAverageValue()) + "ms";
}
/**
* How long it takes us to test our tunnels, averaged over the last 10 minutes
* (pretty printed with the units attached)
*
*/
public String getTunnelLag() {
if (_context == null)
return "0ms";
Rate lagRate = _context.statManager().getRate("tunnel.testSuccessTime").getRate(10*60*1000);
return ((int)lagRate.getAverageValue()) + "ms";
}
}
\ No newline at end of file
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<title>I2P Router Console - logs</title>
<link rel="stylesheet" href="default.css" type="text/css" />
</head><body>
<%@include file="nav.jsp" %>
<%@include file="summary.jsp" %>
<%@include file="notice.jsp" %>
<jsp:useBean class="net.i2p.router.web.ConfigNetHelper" id="nethelper" scope="request" />
<jsp:setProperty name="nethelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
<div class="main" id="main">
<%@include file="confignav.jsp" %>
<form action="config.jsp" method="POST">
<b>External hostname/IP address:</b>
<input name="hostname" type="text" size="32" value="<jsp:getProperty name="nethelper" property="hostname" />" />
<input type="submit" name="guesshost" value="Guess" /><br />
<b>Externally reachable TCP port:</b>
<input name="port" type="text" size="4" value="<jsp:getProperty name="nethelper" property="port" />" /> <br />
<i>The hostname/IP address and TCP port must be reachable from the outside world. If
you are behind a firewall or NAT, this means you must poke a hole for this port. If
you are using DHCP and do not have a static IP address, you must use a service like
<a href="http://dyndns.org/">dyndns</a>. The "guess" functionality makes an HTTP request
to <a href="http://www.whatismyip.com/">www.whatismyip.com</a>.</i>
<hr />
<b>Enable internal time synchronization?</b> <input type="checkbox" <jsp:getProperty name="nethelper" property="enableTimeSyncChecked" /> name="enabletimesync" /><br />
<i>If disabled, your machine <b>must</b> be NTP synchronized</i>
<hr />
<b>Bandwidth limiter</b><br />
<b>Inbound rate</b>:
<input name="inboundrate" type="text" size="2" value="<jsp:getProperty name="nethelper" property="inboundRate" />" /> KBytes per second<br />
<b>Inbound burst duration:</b>
<jsp:getProperty name="nethelper" property="inboundBurstFactorBox" /><br />
<b>Outbound rate:</b>
<input name="outboundrate" type="text" size="2" value="<jsp:getProperty name="nethelper" property="outboundRate" />" /> KBytes per second<br />
<b>Outbound burst duration:</b>
<jsp:getProperty name="nethelper" property="outboundBurstFactorBox" /><br />
<i>A negative rate means there is no limit</i><br />
<hr />
<b>Reseed</b> (from <input name="reseedfrom" type="text" size="40" value="http://dev.i2p.net/i2pdb/" />):
<input type="submit" name="reseed" value="now" /><br />
<hr />
<input type="submit" value="Save changes" /> <input type="reset" value="Cancel" />
</form>
</div>
</body>
</html>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<title>I2P Router Console - config advanced</title>
<link rel="stylesheet" href="default.css" type="text/css" />
</head><body>
<%@include file="nav.jsp" %>
<%@include file="summary.jsp" %>
<%@include file="notice.jsp" %>
<jsp:useBean class="net.i2p.router.web.ConfigAdvancedHelper" id="advancedhelper" scope="request" />
<jsp:setProperty name="advancedhelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
<div class="main" id="main">
<%@include file="confignav.jsp" %>
<form action="configadvanced.jsp" method="POST">
<textarea rows="20" cols="80" name="config"><jsp:getProperty name="advancedhelper" property="settings" /></textarea><br />
<input type="submit" value="Apply" /> <input type="reset" value="Cancel" />
</form>
</div>
</body>
</html>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<title>I2P Router Console - config clients</title>
<link rel="stylesheet" href="default.css" type="text/css" />
</head><body>
<%@include file="nav.jsp" %>
<%@include file="summary.jsp" %>
<%@include file="notice.jsp" %>
<jsp:useBean class="net.i2p.router.web.ConfigClientsHelper" id="clientshelper" scope="request" />
<jsp:setProperty name="clientshelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
<div class="main" id="main">
<%@include file="confignav.jsp" %>
<form action="configclients.jsp" method="POST">
<b>Estimated number of clients/destinations:</b>
<jsp:getProperty name="clientshelper" property="clientCountSelectBox" /><br />
<b>Default number of inbound tunnels per client:</b>
<jsp:getProperty name="clientshelper" property="tunnelCountSelectBox" /><br />
<b>Default number of hops per tunnel:</b>
<jsp:getProperty name="clientshelper" property="tunnelDepthSelectBox" /><br />
<hr />
<input type="submit" value="Save changes" /> <input type="reset" value="Cancel" />
</form>
</div>
</body>
</html>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<title>I2P Router Console - config clients</title>
<link rel="stylesheet" href="default.css" type="text/css" />
</head><body>
<jsp:useBean class="net.i2p.router.web.ConfigLoggingHelper" id="logginghelper" scope="request" />
<jsp:setProperty name="logginghelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
<%@include file="nav.jsp" %>
<%@include file="summary.jsp" %>
<%@include file="notice.jsp" %>
<div class="main" id="main">
<%@include file="confignav.jsp" %>
<form action="configlogging.jsp" method="POST">
<b>Logging filename:</b>
<input type="text" name="logfilename" size="40" value="<jsp:getProperty name="logginghelper" property="logFilePattern" />" /><br />
<i>(the symbol '#' will be replaced during log rotation)</i><br />
<b>Log record format:</b>
<input type="text" name="logformat" size="20" value="<jsp:getProperty name="logginghelper" property="recordPattern" />" /><br />
<i>(use 'd' = date, 'c' = class, 't' = thread, 'p' = priority, 'm' = message)</i><br />
<b>Log date format:</b>
<input type="text" name="logdateformat" size="20" value="<jsp:getProperty name="logginghelper" property="datePattern" />" /><br />
<i>('MM' = month, 'dd' = day, 'HH' = hour, 'mm' = minute, 'ss' = second, 'SSS' = millisecond)</i><br />
<b>Max log file size:</b>
<input type="text" name="logfilesize" size="4" value="<jsp:getProperty name="logginghelper" property="maxFileSize" />" /><br />
<hr />
<b>Log levels:</b> <br />
<jsp:getProperty name="logginghelper" property="logLevelTable" />
<hr />
<input type="submit" value="Apply changes" /> <input type="submit" value="Apply and Save" /> <input type="reset" value="Cancel" />
</form>
</div>
</body>
</html>
<h4><% if (request.getRequestURI().indexOf("config.jsp") != -1) {
%>Network | <% } else { %><a href="config.jsp">Network</a> | <% }
if (request.getRequestURI().indexOf("configclients.jsp") != -1) {
%>Clients | <% } else { %><a href="configclients.jsp">Clients</a> | <% }
if (request.getRequestURI().indexOf("configlogging.jsp") != -1) {
%>Logging | <% } else { %><a href="configlogging.jsp">Logging</a> | <% }
if (request.getRequestURI().indexOf("configadvanced.jsp") != -1) {
%>Advanced | <% } else { %><a href="configadvanced.jsp">Advanced</a> | <% } %></h4>
body {
font-family: Verdana, Tahoma, Helvetica, sans-serif;
margin: 1em 0em;
padding: 0em;
text-align: center;
background-color: white;
color: black;
}
.hide {
display: none;
}
img {
border: none;
}
div.logo {
float: left;
left: 1em;
top: 1em;
margin: 0em;
padding: .5em;
text-align: left;
}
div.routersummary {
/* width: 8em; */
/* height: 5em; */
/* position: fixed; */
float: left;
/* left: 1em; */
/* top: 1em; */
margin: 0em;
padding: .5em;
text-align: left;
border: medium solid #efefff;
background-color: #fafaff;
color: inherit;
font-size: small;
clear: left; /* fixes a bug in Opera */
}
div.warning {
margin: 0em 1em 1em 12em;
padding: .5em 1em;
background-color: #ffefef;
border: medium solid #ffafaf;
text-align: left;
color: inherit;
}
div.main {
margin: 0em 1em 1em 12em;
padding: .5em 1em;
background-color: #ffffef;
border: medium solid #ffffd0;
text-align: left;
color: inherit;
}
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<title>I2P Router Console - logs</title>
<link rel="stylesheet" href="default.css" type="text/css" />
</head><body>
<%@include file="nav.jsp" %>
<%@include file="summary.jsp" %>
<%@include file="notice.jsp" %>
<div class="main" id="main">
hmm. we should probably have some help text here.<br />
This "routerconsole" application runs on top of a trimmed down <a href="jetty.mortbay.com/jetty/index.html">Jetty</a>
instance (trimmed down, as in, we do not include the demo apps or other add-ons), allowing you to deploy standard
JSP/Servlet web applications into your router. Jetty in turn makes use of Apache's javax.servlet (javax.servlet.jar)
implementation, as well as their xerces-j XML parser (xerces.jar). Their XML parser requires the Sun XML
APIs (JAXP) which is included in binary form (xml-apis.jar) as required by their binary code license.
This product includes software developed by the Apache Software Foundation (http://www.apache.org/). See the
<a href="http://www.i2p.net/">I2P</a> site or the source for more license details.
</div>
</body>
</html>
apps/routerconsole/jsp/i2plogo.png

925 B

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment