propagate from branch 'i2p.i2p' (head f42d02067d4fb58b86ffb79222a285f26c3a2628)

to branch 'i2p.i2p.zzz.test' (head 2ceb319557032e54cc8ace070515c6d540e0a7a4)
This commit is contained in:
zzz
2009-11-27 13:26:52 +00:00
209 changed files with 33301 additions and 14083 deletions

View File

@@ -0,0 +1,17 @@
#
# Update messages_xx.po and messages_xx.class files,
# from both java and jsp sources.
# Requires installed programs xgettext, msgfmt, msgmerge, and find.
# zzz - public domain
#
## launching sh.exe with -login parameter will open a shell with the current path always pointing to \bin\
## need to cd into our orignal path - where we call sh.exe from.
cd $CALLFROM
## echo $PWD
## except this everything is the same with bundle-message.sh
## walking - public domain :-D
source bundle-messages.sh $PARAS

View File

@@ -89,10 +89,28 @@
<!-- jar again to get the latest messages_*.class files -->
<jar destfile="./build/routerconsole.jar" basedir="./build/obj" includes="**/*.class" update="true" />
</target>
<target name="poupdate" depends="compile">
<ant target="war" />
<!-- Update the messages_*.po files.
We need to supply the bat file for windows, and then change the fail property to true -->
<exec executable="sh" osfamily="unix" failifexecutionfails="true" >
<arg value="./bundle-messages.sh" />
<arg value="-p" />
</exec>
<exec executable="sh" osfamily="mac" failifexecutionfails="true" >
<arg value="./bundle-messages.sh" />
<arg value="-p" />
</exec>
<exec executable="cmd" osfamily="windows" failifexecutionfails="true" >
<arg value="/c" />
<arg value="bundle-messages.bat" />
<arg value="-p" />
</exec>
</target>
<target name="war" depends="precompilejsp">
<!-- Don't include the css in the war, the main build.xml will copy it to docs/themes/console/ -->
<war destfile="build/routerconsole.war" webxml="../jsp/web-out.xml"
basedir="../jsp/" excludes="web.xml, *.css, **/*.java, *.jsp, web-fragment.xml">
basedir="../jsp/" excludes="web.xml, *.css, **/*.java, *.jsp, *.jsi, web-fragment.xml">
</war>
</target>
<target name="precompilejsp" unless="precompilejsp.uptodate">
@@ -101,7 +119,36 @@
<delete file="../jsp/web-out.xml" />
<mkdir dir="../jsp/WEB-INF/" />
<mkdir dir="../jsp/WEB-INF/classes" />
<!-- there are various jspc ant tasks, but they all seem a bit flakey -->
<!--
** Usage: jspc <options> <jsp files>
** where jsp files is
** -webapp <dir> A directory containing a web-app, whose JSP pages
** will be processed recursively
** or any number of
** <file> A file to be parsed as a JSP page
** where options include:
** -help Print this help message
** -v Verbose mode
** -d <dir> Output Directory (default -Djava.io.tmpdir)
** -l Outputs the name of the JSP page upon failure
** -s Outputs the name of the JSP page upon success
** -p <name> Name of target package (default org.apache.jsp)
** -c <name> Name of target class name (only applies to first JSP page)
** -mapped Generates separate write() calls for each HTML line in the JSP
** -die[#] Generates an error return code (#) on fatal errors (default 1)
** -uribase <dir> The uri directory compilations should be relative to
** (default "/")
** -uriroot <dir> Same as -webapp
** -compile Compiles generated servlets
** -webinc <file> Creates a partial servlet mappings in the file
** -webxml <file> Creates a complete web.xml in the file
** -ieplugin <clsid> Java Plugin classid for Internet Explorer
** -classpath <path> Overrides java.class.path system property
** -xpoweredBy Add X-Powered-By response header
** -trimSpaces Trim spaces in template text between actions, directives
-->
<java classname="org.apache.jasper.JspC" fork="true" failonerror="true">
<classpath>
<pathelement location="../../jetty/jettylib/jasper-compiler.jar" />

View File

@@ -0,0 +1,26 @@
@echo off
set Callfrom=%cd%
set Paras=%1
rem before calling make sure you have msys and mingw 's "bin" path
rem in your current searching path
rem type "set path" to check
if not exist ..\locale\*.only goto updateALL
rem put a messages_xx.only(eg messages_zh.only) into locale folder
rem this script will only touch the po file(eg zh) you specified, leaving other po files untact.
for %%i in (..\locale\*.only) do set PO=%%~ni
echo [Notice] Yu choose to Ony update the choosen file: %PO%.po
for %%i in (..\locale\*.po) do if not %%~ni==%PO% ren %%i %%~ni.po-
call sh --login %cd%\bmsg.sh
for %%i in (..\locale\*.po-) do if not %%~ni==%PO% ren %%i %%~ni.po
goto end
:updateALL
call sh --login %cd%\bmsg.sh
:end
echo End of Message Bundling

View File

@@ -2,65 +2,112 @@
# Update messages_xx.po and messages_xx.class files,
# from both java and jsp sources.
# Requires installed programs xgettext, msgfmt, msgmerge, and find.
#
# usage:
# bundle-messages.sh (generates the resource bundle from the .po file)
# bundle-messages.sh -p (updates the .po file from the source tags, then generates the resource bundle)
#
# zzz - public domain
#
CLASS=net.i2p.router.web.messages
TMPFILE=build/javafiles.txt
export TZ=UTC
if [ "$1" = "-p" ]
then
POUPDATE=1
fi
#
# generate strings/Countries.java from ../../../installer/resources/countries.txt
#
CFILE=../../../installer/resources/countries.txt
# add ../java/ so the refs will work in the po file
JFILE=../java/build/Countries.java
if [ $CFILE -nt $JFILE -o ! -s $JFILE ]
then
mkdir -p build
echo '// Automatically generated pseudo-java for xgettext - do not edit' > $JFILE
echo '// Translators may wish to translate a few of these, do not bother to translate all of them!!' >> $JFILE
sed 's/..,\(..*\)/_("\1");/' $CFILE >> $JFILE
fi
# list specific files in router/ here, so we don't scan the whole tree
ROUTERFILES="\
../../../router/java/src/net/i2p/router/RouterThrottleImpl.java \
../../../router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java \
../../../router/java/src/net/i2p/router/transport/TransportManager.java \
../../../router/java/src/net/i2p/router/transport/GetBidsJob.java \
../../../router/java/src/net/i2p/router/Blocklist.java \
../../../router/java/src/net/i2p/router/transport/ntcp/EstablishState.java"
# add ../java/ so the refs will work in the po file
JPATHS="../java/src ../jsp/WEB-INF ../java/strings $JFILE $ROUTERFILES"
for i in ../locale/messages_*.po
do
# get language
LG=${i#../locale/messages_}
LG=${LG%.po}
# make list of java files newer than the .po file
find src ../jsp/WEB-INF -name *.java -newer $i > $TMPFILE
if [ -s build/obj/net/i2p/router/web/messages_$LG.class -a ! -s $TMPFILE ]
if [ "$POUPDATE" = "1" ]
then
# make list of java files newer than the .po file
find $JPATHS -name *.java -newer $i > $TMPFILE
fi
if [ -s build/obj/net/i2p/router/web/messages_$LG.class -a \
build/obj/net/i2p/router/web/messages_$LG.class -nt $i -a \
! -s $TMPFILE ]
then
continue
fi
echo "Generating ${CLASS}_$LG ResourceBundle..."
if [ "$POUPDATE" = "1" ]
then
echo "Updating the $i file from the tags..."
# extract strings from java and jsp files, and update messages.po files
# translate calls must be one of the forms:
# _("foo")
# _x("foo")
# intl._("foo")
# intl.title("foo")
# handler._("foo")
# formhandler._("foo")
# net.i2p.router.web.Messages.getString("foo")
# In a jsp, you must use a helper or handler that has the context set.
# To start a new translation, copy the header from an old translation to the new .po file,
# then ant distclean updater.
find $JPATHS -name *.java > $TMPFILE
xgettext -f $TMPFILE -F -L java --from-code=UTF-8 \
--keyword=_ --keyword=_x --keyword=intl._ --keyword=intl.title \
--keyword=handler._ --keyword=formhandler._ \
--keyword=net.i2p.router.web.Messages.getString \
-o ${i}t
if [ $? -ne 0 ]
then
echo 'Warning - xgettext failed, not updating translations'
rm -f ${i}t
break
fi
msgmerge -U --backup=none $i ${i}t
if [ $? -ne 0 ]
then
echo 'Warning - msgmerge failed, not updating translations'
rm -f ${i}t
break
fi
rm -f ${i}t
# so we don't do this again
touch $i
fi
# extract strings from java and jsp files, and update messages.po files
# translate calls must be one of the forms:
# _("foo")
# _x("foo")
# cssHelper._("foo")
# cssHelper.title("foo")
# handler._("foo")
# formhandler._("foo")
# In a jsp, you must use a helper or handler that has the context set.
# To start a new translation, copy the header from an old translation to the new .po file,
# then ant distclean updater.
find src ../jsp/WEB-INF -name *.java > $TMPFILE
xgettext -f $TMPFILE -F -L java \
--keyword=_ --keyword=_x --keyword=cssHelper._ --keyword=cssHelper.title \
--keyword=handler._ --keyword=formhandler._ \
-o ${i}t
if [ $? -ne 0 ]
then
echo 'Warning - xgettext failed, not updating translations'
rm -f ${i}t
break
fi
msgmerge -U --backup=none $i ${i}t
if [ $? -ne 0 ]
then
echo 'Warning - msgmerge failed, not updating translations'
rm -f ${i}t
break
fi
rm -f ${i}t
# so we don't do this again
touch $i
echo "Generating ${CLASS}_$LG ResourceBundle..."
# convert to class files in build/obj
msgfmt --java -r $CLASS -l $LG -d build/obj $i
if [ $? -ne 0 ]
then
echo 'Warning - xgettext failed, not updating translations'
echo 'Warning - msgfmt failed, not updating translations'
break
fi
done

View File

@@ -13,7 +13,7 @@ import java.util.Iterator;
*
*/
public class ConfigAdvancedHandler extends FormHandler {
private boolean _forceRestart;
//private boolean _forceRestart;
private boolean _shouldSave;
private String _config;
@@ -27,7 +27,7 @@ public class ConfigAdvancedHandler extends FormHandler {
}
public void setShouldsave(String moo) { _shouldSave = true; }
public void setRestart(String moo) { _forceRestart = true; }
//public void setRestart(String moo) { _forceRestart = true; }
public void setConfig(String val) {
_config = val;
@@ -54,7 +54,7 @@ public class ConfigAdvancedHandler extends FormHandler {
unsetKeys.remove(key);
}
} catch (IOException ioe) {
addFormError("Error updating the configuration (IOERROR) - please see the error logs");
addFormError(_("Error updating the configuration - please see the error logs"));
return;
}
@@ -66,15 +66,15 @@ public class ConfigAdvancedHandler extends FormHandler {
boolean saved = _context.router().saveConfig();
if (saved)
addFormNotice("Configuration saved successfully");
addFormNotice(_("Configuration saved successfully"));
else
addFormNotice("Error saving the configuration (applied but not saved) - please see the error logs");
addFormNotice(_("Error saving the configuration (applied but not saved) - please see the error logs"));
if (_forceRestart) {
addFormNotice("Performing a soft restart");
_context.router().restart();
addFormNotice("Soft restart complete");
}
//if (_forceRestart) {
// addFormNotice("Performing a soft restart");
// _context.router().restart();
// addFormNotice("Soft restart complete");
//}
}
}
}

View File

@@ -29,11 +29,16 @@ public class ConfigClientsHandler extends FormHandler {
@Override
protected void processForm() {
if (_action.startsWith("Save Client")) {
if (_action.equals(_("Save Client Configuration"))) {
saveClientChanges();
} else if (_action.startsWith("Save WebApp")) {
return;
}
if (_action.equals(_("Save WebApp Configuration"))) {
saveWebAppChanges();
} else if (_action.startsWith("Start ")) {
return;
}
// value
if (_action.startsWith("Start ")) {
String app = _action.substring(6);
int appnum = -1;
try {
@@ -43,10 +48,14 @@ public class ConfigClientsHandler extends FormHandler {
startClient(appnum);
else
startWebApp(app);
} else if (_action.toLowerCase().startsWith("start<span class=hide> ") &&
return;
}
// label (IE)
String xStart = _("Start");
if (_action.toLowerCase().startsWith(xStart + "<span class=hide> ") &&
_action.toLowerCase().endsWith("</span>")) {
// IE sucks
String app = _action.substring(23, _action.length() - 7);
String app = _action.substring(xStart.length() + 18, _action.length() - 7);
int appnum = -1;
try {
appnum = Integer.parseInt(app);
@@ -56,7 +65,7 @@ public class ConfigClientsHandler extends FormHandler {
else
startWebApp(app);
} else {
addFormError("Unsupported " + _action + ".");
addFormError(_("Unsupported") + ' ' + _action + '.');
}
}
@@ -67,22 +76,22 @@ public class ConfigClientsHandler extends FormHandler {
for (int cur = 0; cur < clients.size(); cur++) {
ClientAppConfig ca = (ClientAppConfig) clients.get(cur);
Object val = _settings.get(cur + ".enabled");
if (! "webConsole".equals(ca.clientName))
if (! ("webConsole".equals(ca.clientName) || "Web console".equals(ca.clientName)))
ca.disabled = val == null;
}
ClientAppConfig.writeClientAppConfig(_context, clients);
addFormNotice("Client configuration saved successfully - restart required to take effect.");
addFormNotice(_("Client configuration saved successfully - restart required to take effect."));
}
private void startClient(int i) {
List clients = ClientAppConfig.getClientApps(_context);
if (i >= clients.size()) {
addFormError("Bad client index.");
addFormError(_("Bad client index."));
return;
}
ClientAppConfig ca = (ClientAppConfig) clients.get(i);
LoadClientAppsJob.runClient(ca.className, ca.clientName, LoadClientAppsJob.parseArgs(ca.args), configClient_log);
addFormNotice("Client " + ca.clientName + " started.");
addFormNotice(_("Client") + ' ' + _(ca.clientName) + ' ' + _("started") + '.');
}
private void saveWebAppChanges() {
@@ -99,7 +108,7 @@ public class ConfigClientsHandler extends FormHandler {
props.setProperty(name, "" + (val != null));
}
RouterConsoleRunner.storeWebAppProperties(props);
addFormNotice("WebApp configuration saved successfully - restart required to take effect.");
addFormNotice(_("WebApp configuration saved successfully - restart required to take effect."));
}
// Big hack for the moment, not using properties for directory and port
@@ -117,14 +126,14 @@ public class ConfigClientsHandler extends FormHandler {
path = new File(path, app + ".war");
s.addWebApplication("/"+ app, path.getAbsolutePath()).start();
// no passwords... initialize(wac);
addFormNotice("WebApp <a href=\"/" + app + "/\">" + app + "</a> started.");
addFormNotice(_("WebApp") + " <a href=\"/" + app + "/\">" + _(app) + "</a> " + _("started") + '.');
} catch (Exception ioe) {
addFormError("Failed to start " + app + " " + ioe + ".");
addFormError(_("Failed to start") + ' ' + _(app) + " " + ioe + '.');
}
return;
}
}
}
addFormError("Failed to find server.");
addFormError(_("Failed to find server."));
}
}

View File

@@ -14,12 +14,13 @@ public class ConfigClientsHelper extends HelperBase {
public String getForm1() {
StringBuilder buf = new StringBuilder(1024);
buf.append("<table>\n");
buf.append("<tr><th align=\"right\">Client</th><th>Run at Startup?</th><th>Start Now</th><th align=\"left\">Class and arguments</th></tr>\n");
buf.append("<tr><th align=\"right\">" + _("Client") + "</th><th>" + _("Run at Startup?") + "</th><th>" + _("Start Now") + "</th><th align=\"left\">" + _("Class and arguments") + "</th></tr>\n");
List clients = ClientAppConfig.getClientApps(_context);
for (int cur = 0; cur < clients.size(); cur++) {
ClientAppConfig ca = (ClientAppConfig) clients.get(cur);
renderForm(buf, ""+cur, ca.clientName, false, !ca.disabled, "webConsole".equals(ca.clientName),
renderForm(buf, ""+cur, ca.clientName, false, !ca.disabled,
"webConsole".equals(ca.clientName) || "Web console".equals(ca.clientName),
ca.className + ((ca.args != null) ? " " + ca.args : ""));
}
@@ -30,7 +31,7 @@ public class ConfigClientsHelper extends HelperBase {
public String getForm2() {
StringBuilder buf = new StringBuilder(1024);
buf.append("<table>\n");
buf.append("<tr><th align=\"right\">WebApp</th><th>Run at Startup?</th><th>Start Now</th><th align=\"left\">Description</th></tr>\n");
buf.append("<tr><th align=\"right\">" + _("WebApp") + "</th><th>" + _("Run at Startup?") + "</th><th>" + _("Start Now") + "</th><th align=\"left\">" + _("Description") + "</th></tr>\n");
Properties props = RouterConsoleRunner.webAppProperties();
Set keys = new TreeSet(props.keySet());
for (Iterator iter = keys.iterator(); iter.hasNext(); ) {
@@ -51,9 +52,9 @@ public class ConfigClientsHelper extends HelperBase {
String link = "/";
if (! RouterConsoleRunner.ROUTERCONSOLE.equals(name))
link += name + "/";
buf.append("<a href=\"").append(link).append("\">").append(name).append("</a>");
buf.append("<a href=\"").append(link).append("\">").append(_(name)).append("</a>");
} else {
buf.append(name);
buf.append(_(name));
}
buf.append("</td><td align=\"center\" width=\"10%\"><input type=\"checkbox\" class=\"optbox\" name=\"").append(index).append(".enabled\" value=\"true\" ");
if (enabled) {
@@ -63,7 +64,7 @@ public class ConfigClientsHelper extends HelperBase {
}
buf.append("/></td><td align=\"center\" width=\"15%\">");
if (!enabled) {
buf.append("<button type=\"submit\" name=\"action\" value=\"Start ").append(index).append("\" >Start<span class=hide> ").append(index).append("</span></button>");
buf.append("<button type=\"submit\" name=\"action\" value=\"Start ").append(index).append("\" >" + _("Start") + "<span class=hide> ").append(index).append("</span></button>");
}
buf.append("</td><td align=\"left\" width=\"50%\">").append(desc).append("</td></tr>\n");
}

View File

@@ -15,12 +15,12 @@ public class ConfigKeyringHandler extends FormHandler {
@Override
protected void processForm() {
if (_action == null) return;
boolean adding = _action.startsWith("Add");
if (adding || _action.startsWith("Delete")) {
boolean adding = _action.equals(_("Add key"));
if (adding || _action.equals(_("Delete key"))) {
if (_peer == null)
addFormError("You must enter a destination");
addFormError(_("You must enter a destination"));
if (_key == null && adding)
addFormError("You must enter a key");
addFormError(_("You must enter a key"));
if (_peer == null || (_key == null && adding))
return;
Hash h = ConvertToHash.getHash(_peer);
@@ -31,22 +31,22 @@ public class ConfigKeyringHandler extends FormHandler {
} catch (DataFormatException dfe) {}
if (h != null && h.getData() != null && sk.getData() != null) {
_context.keyRing().put(h, sk);
addFormNotice("Key for " + h.toBase64() + " added to keyring");
addFormNotice(_("Key for") + " " + h.toBase64() + " " + _("added to keyring"));
} else {
addFormError("Invalid destination or key");
addFormError(_("Invalid destination or key"));
}
} else { // Delete
if (h != null && h.getData() != null) {
if (_context.keyRing().remove(h) != null)
addFormNotice("Key for " + h.toBase64() + " removed from keyring");
addFormNotice(_("Key for") + " " + h.toBase64() + " " + _("removed from keyring"));
else
addFormNotice("Key for " + h.toBase64() + " not found in keyring");
addFormNotice(_("Key for") + " " + h.toBase64() + " " + _("not found in keyring"));
} else {
addFormError("Invalid destination");
addFormError(_("Invalid destination"));
}
}
} else {
addFormError("Unsupported");
addFormError(_("Unsupported"));
}
}

View File

@@ -36,7 +36,7 @@ public class ConfigLoggingHelper extends HelperBase {
sortedLogs.add(prefix);
}
buf.append("<textarea name=\"levels\" rows=\"4\" cols=\"60\">");
buf.append("<textarea name=\"levels\" rows=\"4\" cols=\"60\" wrap=\"off\">");
for (Iterator iter = sortedLogs.iterator(); iter.hasNext(); ) {
String prefix = (String)iter.next();
String level = limits.getProperty(prefix);
@@ -48,30 +48,21 @@ public class ConfigLoggingHelper extends HelperBase {
buf.append("<i>Valid levels are DEBUG, INFO, WARN, ERROR, CRIT</i>\n");
return buf.toString();
}
private static String[] levels = { _x("CRIT"), _x("ERROR"), _x("WARN"), _x("INFO"), _x("DEBUG") };
public String getDefaultLogLevelBox() {
String cur = _context.logManager().getDefaultLimit();
StringBuilder buf = new StringBuilder(128);
buf.append("<select name=\"defaultloglevel\">\n");
buf.append("<option value=\"DEBUG\" ");
if ("DEBUG".equals(cur)) buf.append(" selected=\"true\" ");
buf.append(">DEBUG</option>\n");
buf.append("<option value=\"INFO\" ");
if ("INFO".equals(cur)) buf.append(" selected=\"true\" ");
buf.append(">INFO</option>\n");
buf.append("<option value=\"WARN\" ");
if ("WARN".equals(cur)) buf.append(" selected=\"true\" ");
buf.append(">WARN</option>\n");
buf.append("<option value=\"ERROR\" ");
if ("ERROR".equals(cur)) buf.append(" selected=\"true\" ");
buf.append(">ERROR</option>\n");
buf.append("<option value=\"CRIT\" ");
if ("CRIT".equals(cur)) buf.append(" selected=\"true\" ");
buf.append(">CRIT</option>\n");
for (int i = 0; i < levels.length; i++) {
String l = levels[i];
buf.append("<option value=\"").append(l).append("\" ");
if (l.equals(cur))
buf.append(" selected=\"true\" ");
buf.append('>').append(_(l)).append("</option>\n");
}
buf.append("</select>\n");
return buf.toString();

View File

@@ -44,7 +44,7 @@ public class ConfigNetHandler extends FormHandler {
@Override
protected void processForm() {
if (_saveRequested || ( (_action != null) && ("Save changes".equals(_action)) )) {
if (_saveRequested || ( (_action != null) && (_("Save changes").equals(_action)) )) {
saveChanges();
} else if (_recheckReachabilityRequested) {
recheckReachability();
@@ -116,7 +116,7 @@ public class ConfigNetHandler extends FormHandler {
private void recheckReachability() {
_context.commSystem().recheckReachability();
addFormNotice("Rechecking router reachability...");
addFormNotice(_("Rechecking router reachability..."));
}
/**
@@ -145,7 +145,7 @@ public class ConfigNetHandler extends FormHandler {
// Todo: Catch local IPs right here rather than complaining later
_context.router().setConfigSetting(UDPTransport.PROP_EXTERNAL_HOST, uhost);
if ((!oldUdp.equals(_udpAutoIP)) || (!oldUHost.equals(uhost))) {
addFormNotice("Updating IP address");
addFormNotice(_("Updating IP address"));
restartRequired = true;
}
}
@@ -163,17 +163,17 @@ public class ConfigNetHandler extends FormHandler {
if ((!oldAutoHost.equals(_ntcpAutoIP)) || ! oldNHost.equalsIgnoreCase(_ntcpHostname)) {
if ("disabled".equals(_ntcpAutoIP)) {
addFormNotice("Disabling TCP completely");
addFormNotice(_("Disabling TCP completely"));
} else if ("false".equals(_ntcpAutoIP) && _ntcpHostname.length() > 0) {
// Todo: Catch local IPs right here rather than complaining later
_context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_HOSTNAME, _ntcpHostname);
addFormNotice("Updating inbound TCP address to " + _ntcpHostname);
addFormNotice(_("Updating inbound TCP address to") + " " + _ntcpHostname);
} else {
_context.router().removeConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_HOSTNAME);
if ("false".equals(_ntcpAutoIP))
addFormNotice("Disabling inbound TCP");
addFormNotice(_("Disabling inbound TCP"));
else
addFormNotice("Updating inbound TCP address to auto"); // true or always
addFormNotice(_("Updating inbound TCP address to auto")); // true or always
}
_context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_AUTO_IP, _ntcpAutoIP);
_context.router().setConfigSetting(TransportManager.PROP_ENABLE_NTCP, "" + !"disabled".equals(_ntcpAutoIP));
@@ -182,10 +182,10 @@ public class ConfigNetHandler extends FormHandler {
if (oldAutoPort != _ntcpAutoPort || ! oldNPort.equals(_ntcpPort)) {
if (_ntcpPort.length() > 0 && !_ntcpAutoPort) {
_context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_PORT, _ntcpPort);
addFormNotice("Updating inbound TCP port to " + _ntcpPort);
addFormNotice(_("Updating inbound TCP port to") + " " + _ntcpPort);
} else {
_context.router().removeConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_PORT);
addFormNotice("Updating inbound TCP port to auto");
addFormNotice(_("Updating inbound TCP port to auto"));
}
_context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_AUTO_PORT, "" + _ntcpAutoPort);
restartRequired = true;
@@ -197,7 +197,7 @@ public class ConfigNetHandler extends FormHandler {
if (!oldPort.equals(_udpPort)) {
_context.router().setConfigSetting(UDPTransport.PROP_INTERNAL_PORT, _udpPort);
_context.router().setConfigSetting(UDPTransport.PROP_EXTERNAL_PORT, _udpPort);
addFormNotice("Updating UDP port from " + oldPort + " to " + _udpPort);
addFormNotice(_("Updating UDP port from") + " " + oldPort + " " + _("to") + " " + _udpPort);
restartRequired = true;
}
}
@@ -213,9 +213,9 @@ public class ConfigNetHandler extends FormHandler {
if (switchRequired) {
_context.router().setConfigSetting(PROP_HIDDEN, "" + _hiddenMode);
if (_hiddenMode)
addFormError("Gracefully restarting into Hidden Router Mode");
addFormError(_("Gracefully restarting into Hidden Router Mode"));
else
addFormError("Gracefully restarting to exit Hidden Router Mode");
addFormError(_("Gracefully restarting to exit Hidden Router Mode"));
}
_context.router().setConfigSetting(Router.PROP_DYNAMIC_KEYS, "" + _dynamicKeys);
@@ -224,15 +224,15 @@ public class ConfigNetHandler extends FormHandler {
_upnp) {
// This is minor, don't set restartRequired
if (_upnp)
addFormNotice("Enabling UPnP, restart required to take effect");
addFormNotice(_("Enabling UPnP, restart required to take effect"));
else
addFormNotice("Disabling UPnP, restart required to take effect");
addFormNotice(_("Disabling UPnP, restart required to take effect"));
}
_context.router().setConfigSetting(TransportManager.PROP_ENABLE_UPNP, "" + _upnp);
if (_requireIntroductions) {
_context.router().setConfigSetting(UDPTransport.PROP_FORCE_INTRODUCERS, "true");
addFormNotice("Requiring SSU introduers");
addFormNotice(_("Requiring SSU introduers"));
} else {
_context.router().removeConfigSetting(UDPTransport.PROP_FORCE_INTRODUCERS);
}
@@ -246,11 +246,11 @@ public class ConfigNetHandler extends FormHandler {
}
boolean saved = _context.router().saveConfig();
if ( (_action != null) && ("Save changes".equals(_action)) ) {
if ( (_action != null) && (_("Save changes").equals(_action)) ) {
if (saved)
addFormNotice("Configuration saved successfully");
addFormNotice(_("Configuration saved successfully"));
else
addFormNotice("Error saving the configuration (applied but not saved) - please see the error logs");
addFormNotice(_("Error saving the configuration (applied but not saved) - please see the error logs"));
}
if (switchRequired) {
@@ -272,7 +272,7 @@ public class ConfigNetHandler extends FormHandler {
// There's a few changes that don't really require restart (e.g. enabling inbound TCP)
// But it would be hard to get right, so just do a restart.
addFormError("Gracefully restarting I2P to change published router address");
addFormError(_("Gracefully restarting I2P to change published router address"));
_context.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
}
}
@@ -290,7 +290,7 @@ public class ConfigNetHandler extends FormHandler {
String old = _context.router().getConfigSetting(Router.PROP_BANDWIDTH_SHARE_PERCENTAGE);
if ( (old == null) || (!old.equalsIgnoreCase(_sharePct)) ) {
_context.router().setConfigSetting(Router.PROP_BANDWIDTH_SHARE_PERCENTAGE, _sharePct);
addFormNotice("Updating bandwidth share percentage");
addFormNotice(_("Updating bandwidth share percentage"));
updated = true;
}
}
@@ -360,7 +360,7 @@ public class ConfigNetHandler extends FormHandler {
if (updated && !_ratesOnly) {
_context.bandwidthLimiter().reinitialize();
addFormNotice("Updated bandwidth limits");
addFormNotice(_("Updated bandwidth limits"));
}
}
}

View File

@@ -36,7 +36,7 @@ public class ConfigNetHelper extends HelperBase {
public String getUdpAddress() {
RouterAddress addr = _context.router().getRouterInfo().getTargetAddress("SSU");
if (addr == null)
return "unknown";
return _("unknown");
UDPAddress ua = new UDPAddress(addr);
return ua.toString();
}
@@ -44,20 +44,20 @@ public class ConfigNetHelper extends HelperBase {
public String getUdpIP() {
RouterAddress addr = _context.router().getRouterInfo().getTargetAddress("SSU");
if (addr == null)
return "unknown";
return _("unknown");
UDPAddress ua = new UDPAddress(addr);
if (ua.getHost() == null)
return "unknown";
return _("unknown");
return ua.getHost();
}
public String getUdpPort() {
RouterAddress addr = _context.router().getRouterInfo().getTargetAddress("SSU");
if (addr == null)
return "unknown";
return _("unknown");
UDPAddress ua = new UDPAddress(addr);
if (ua.getPort() <= 0)
return "unknown";
return _("unknown");
return "" + ua.getPort();
}
@@ -162,7 +162,7 @@ public class ConfigNetHelper extends HelperBase {
return kbytesToBits(getShareBandwidth());
}
private String kbytesToBits(int kbytes) {
return DataHelper.formatSize(kbytes * 8 * 1024) + " bits per second";
return DataHelper.formatSize(kbytes * 8 * 1024) + ' ' + _("bits per second");
}
public String getInboundBurstRate() {
return "" + _context.bandwidthLimiter().getInboundBurstKBytesPerSecond();

View File

@@ -17,26 +17,26 @@ public class ConfigPeerHandler extends FormHandler {
if ("Save Configuration".equals(_action)) {
_context.router().saveConfig();
addFormNotice("Settings saved - not really!!!!!");
} else if (_action.startsWith("Ban")) {
} else if (_action.equals(_("Ban peer until restart"))) {
Hash h = getHash();
if (h != null) {
_context.shitlist().shitlistRouterForever(h, "Manually banned via <a href=\"configpeer.jsp\">configpeer.jsp</a>");
addFormNotice("Peer " + _peer + " banned until restart");
_context.shitlist().shitlistRouterForever(h, _("Manually banned via {0}"), "<a href=\"configpeer.jsp\">configpeer.jsp</a>");
addFormNotice(_("Peer") + " " + _peer + " " + _("banned until restart") );
return;
}
addFormError("Invalid peer");
} else if (_action.startsWith("Unban")) {
addFormError(_("Invalid peer"));
} else if (_action.equals(_("Unban peer"))) {
Hash h = getHash();
if (h != null) {
if (_context.shitlist().isShitlisted(h)) {
_context.shitlist().unshitlistRouter(h);
addFormNotice("Peer " + _peer + " unbanned");
addFormNotice(_("Peer") + " " + _peer + " " + _("unbanned") );
} else
addFormNotice("Peer " + _peer + " is not currently banned");
addFormNotice(_("Peer") + " " + _peer + " " + _("is not currently banned") );
return;
}
addFormError("Invalid peer");
} else if (_action.startsWith("Adjust")) {
addFormError(_("Invalid peer"));
} else if (_action.equals(_("Adjust Profile Bonuses"))) {
Hash h = getHash();
if (h != null) {
PeerProfile prof = _context.profileOrganizer().getProfile(h);
@@ -44,19 +44,19 @@ public class ConfigPeerHandler extends FormHandler {
try {
prof.setSpeedBonus(Long.parseLong(_speed));
} catch (NumberFormatException nfe) {
addFormError("Bad speed value");
addFormError(_("Bad speed value"));
}
try {
prof.setCapacityBonus(Long.parseLong(_capacity));
} catch (NumberFormatException nfe) {
addFormError("Bad capacity value");
addFormError(_("Bad capacity value"));
}
addFormNotice("Bonuses adjusted for " + _peer);
} else
addFormError("No profile exists for " + _peer);
return;
}
addFormError("Invalid peer");
addFormError(_("Invalid peer"));
} else if (_action.startsWith("Check")) {
addFormError("Unsupported");
}

View File

@@ -1,7 +1,5 @@
package net.i2p.router.web;
import java.util.StringTokenizer;
import net.i2p.data.DataHelper;
import net.i2p.router.Router;
import net.i2p.router.RouterContext;
@@ -11,6 +9,12 @@ import net.i2p.router.RouterContext;
*
*/
public class ConfigRestartBean {
/** all these are tagged below so no need to _x them here */
static final String[] SET1 = {"shutdownImmediate", "Shutdown immediately", "cancelShutdown", "Cancel shutdown"};
static final String[] SET2 = {"restartImmediate", "Restart immediately", "cancelShutdown", "Cancel restart"};
static final String[] SET3 = {"restart", "Restart", "shutdown", "Shutdown"};
static final String[] SET4 = {"shutdown", "Shutdown"};
public static String getNonce() {
RouterContext ctx = ContextHelper.getContext(null);
String nonce = System.getProperty("console.nonce");
@@ -25,20 +29,21 @@ public class ConfigRestartBean {
String systemNonce = getNonce();
if ( (nonce != null) && (systemNonce.equals(nonce)) && (action != null) ) {
// Normal browsers send value, IE sends button label
if ("shutdownImmediate".equals(action) || "Shutdown immediately".equals(action)) {
if ("shutdownImmediate".equals(action) || _("Shutdown immediately", ctx).equals(action)) {
ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_HARD));
//ctx.router().shutdown(Router.EXIT_HARD); // never returns
ctx.router().shutdownGracefully(Router.EXIT_HARD); // give the UI time to respond
} else if ("cancelShutdown".equals(action) || "Cancel shutdown".equals(action)) {
} else if ("cancelShutdown".equals(action) || _("Cancel shutdown", ctx).equals(action) ||
_("Cancel restart", ctx).equals(action)) {
ctx.router().cancelGracefulShutdown();
} else if ("restartImmediate".equals(action) || "Restart immediately".equals(action)) {
} else if ("restartImmediate".equals(action) || _("Restart immediately", ctx).equals(action)) {
ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_HARD_RESTART));
//ctx.router().shutdown(Router.EXIT_HARD_RESTART); // never returns
ctx.router().shutdownGracefully(Router.EXIT_HARD_RESTART); // give the UI time to respond
} else if ("restart".equalsIgnoreCase(action)) {
} else if ("restart".equals(action) || _("Restart", ctx).equals(action)) {
ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_GRACEFUL_RESTART));
ctx.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
} else if ("shutdown".equalsIgnoreCase(action)) {
} else if ("shutdown".equals(action) || _("Shutdown", ctx).equals(action)) {
ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_GRACEFUL));
ctx.router().shutdownGracefully();
}
@@ -47,38 +52,35 @@ public class ConfigRestartBean {
boolean shuttingDown = isShuttingDown(ctx);
boolean restarting = isRestarting(ctx);
long timeRemaining = ctx.router().getShutdownTimeRemaining();
if (shuttingDown) {
if (timeRemaining <= 0) {
return "<center><b>Shutdown imminent</b></center>";
} else {
return "<center><b>Shutdown in " + DataHelper.formatDuration(timeRemaining) + "</b></center><br>"
+ buttons(urlBase, systemNonce, "shutdownImmediate,Shutdown immediately,cancelShutdown,Cancel shutdown");
}
StringBuilder buf = new StringBuilder(128);
if ((shuttingDown || restarting) && timeRemaining <= 0) {
buf.append("<center><b>").append(_("Shutdown imminent", ctx)).append("</b></center>");
} else if (shuttingDown) {
buf.append("<center><b>");
buf.append(_("Shutdown in {0}", DataHelper.formatDuration(timeRemaining), ctx));
buf.append("</b></center><br>");
buttons(ctx, buf, urlBase, systemNonce, SET1);
} else if (restarting) {
if (timeRemaining <= 0) {
return "<center><b>Restart imminent</b></center>";
} else {
return "<center><b>Restart in " + DataHelper.formatDuration(timeRemaining) + "</b></center><br>"
+ buttons(urlBase, systemNonce, "restartImmediate,Restart immediately,cancelShutdown,Cancel restart");
}
buf.append("<center><b>");
buf.append(_("Restart in {0}", DataHelper.formatDuration(timeRemaining), ctx));
buf.append("</b></center><br>");
buttons(ctx, buf, urlBase, systemNonce, SET2);
} else {
if (System.getProperty("wrapper.version") != null)
return buttons(urlBase, systemNonce, "restart,Restart,shutdown,Shutdown");
buttons(ctx, buf, urlBase, systemNonce, SET3);
else
return buttons(urlBase, systemNonce, "shutdown,Shutdown");
buttons(ctx, buf, urlBase, systemNonce, SET4);
}
return buf.toString();
}
/** @param s value,label,... pairs */
private static String buttons(String url, String nonce, String s) {
StringBuilder buf = new StringBuilder(128);
StringTokenizer tok = new StringTokenizer(s, ",");
private static void buttons(RouterContext ctx, StringBuilder buf, String url, String nonce, String[] s) {
buf.append("<form action=\"").append(url).append("\" method=\"GET\">\n");
buf.append("<input type=\"hidden\" name=\"consoleNonce\" value=\"").append(nonce).append("\" >\n");
while (tok.hasMoreTokens())
buf.append("<button type=\"submit\" name=\"action\" value=\"").append(tok.nextToken()).append("\" >").append(tok.nextToken()).append("</button>\n");
for (int i = 0; i < s.length; i+= 2)
buf.append("<button type=\"submit\" name=\"action\" value=\"").append(s[i]).append("\" >").append(_(s[i+1], ctx)).append("</button>\n");
buf.append("</form>\n");
return buf.toString();
}
private static boolean isShuttingDown(RouterContext ctx) {
@@ -96,4 +98,13 @@ public class ConfigRestartBean {
return ctx.router().getShutdownTimeRemaining();
return Long.MAX_VALUE/2; // summaryframe.jsp adds a safety factor so we don't want to overflow...
}
private static String _(String s, RouterContext ctx) {
return Messages.getString(s, ctx);
}
private static String _(String s, Object o, RouterContext ctx) {
return Messages.getString(s, o, ctx);
}
}

View File

@@ -50,74 +50,74 @@ public class ConfigServiceHandler extends FormHandler {
protected void processForm() {
if (_action == null) return;
if ("Shutdown gracefully".equals(_action)) {
if (_("Shutdown gracefully").equals(_action)) {
_context.addShutdownTask(new UpdateWrapperManagerTask(Router.EXIT_GRACEFUL));
_context.router().shutdownGracefully();
addFormNotice("Graceful shutdown initiated");
} else if ("Shutdown immediately".equals(_action)) {
addFormNotice(_("Graceful shutdown initiated"));
} else if (_("Shutdown immediately").equals(_action)) {
_context.addShutdownTask(new UpdateWrapperManagerTask(Router.EXIT_HARD));
_context.router().shutdown(Router.EXIT_HARD);
addFormNotice("Shutdown immediately! boom bye bye bad bwoy");
} else if ("Cancel graceful shutdown".equals(_action)) {
addFormNotice(_("Shutdown immediately! boom bye bye bad bwoy"));
} else if (_("Cancel graceful shutdown").equals(_action)) {
_context.router().cancelGracefulShutdown();
addFormNotice("Graceful shutdown cancelled");
} else if ("Graceful restart".equals(_action)) {
addFormNotice(_("Graceful shutdown cancelled"));
} else if (_("Graceful restart").equals(_action)) {
_context.addShutdownTask(new UpdateWrapperManagerTask(Router.EXIT_GRACEFUL_RESTART));
_context.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
addFormNotice("Graceful restart requested");
} else if ("Hard restart".equals(_action)) {
addFormNotice(_("Graceful restart requested"));
} else if (_("Hard restart").equals(_action)) {
_context.addShutdownTask(new UpdateWrapperManagerTask(Router.EXIT_HARD_RESTART));
_context.router().shutdown(Router.EXIT_HARD_RESTART);
addFormNotice("Hard restart requested");
} else if ("Rekey and Restart".equals(_action)) {
addFormNotice("Rekeying after graceful restart");
addFormNotice(_("Hard restart requested"));
} else if (_("Rekey and Restart").equals(_action)) {
addFormNotice(_("Rekeying after graceful restart"));
_context.addShutdownTask(new UpdateWrapperManagerAndRekeyTask(Router.EXIT_GRACEFUL_RESTART));
_context.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
} else if ("Rekey and Shutdown".equals(_action)) {
addFormNotice("Rekeying after graceful shutdown");
} else if (_("Rekey and Shutdown").equals(_action)) {
addFormNotice(_("Rekeying after graceful shutdown"));
_context.addShutdownTask(new UpdateWrapperManagerAndRekeyTask(Router.EXIT_GRACEFUL));
_context.router().shutdownGracefully(Router.EXIT_GRACEFUL);
} else if ("Run I2P on startup".equals(_action)) {
} else if (_("Run I2P on startup").equals(_action)) {
installService();
} else if ("Don't run I2P on startup".equals(_action)) {
} else if (_("Don't run I2P on startup").equals(_action)) {
uninstallService();
} else if ("Dump threads".equals(_action)) {
} else if (_("Dump threads").equals(_action)) {
try {
WrapperManager.requestThreadDump();
} catch (Throwable t) {
addFormError("Warning: unable to contact the service manager - " + t.getMessage());
}
addFormNotice("Threads dumped to wrapper.log");
} else if ("Show systray icon".equals(_action)) {
} else if (_("Show systray icon").equals(_action)) {
try {
SysTray tray = SysTray.getInstance();
if (tray != null) {
tray.show();
addFormNotice("System tray icon enabled.");
addFormNotice(_("System tray icon enabled."));
} else {
addFormNotice("System tray icon feature not supported on this platform. Sorry!");
addFormNotice(_("System tray icon feature not supported on this platform. Sorry!"));
}
} catch (Throwable t) {
addFormError("Warning: unable to contact the systray manager - " + t.getMessage());
addFormError(_("Warning: unable to contact the systray manager") + " - " + t.getMessage());
}
} else if ("Hide systray icon".equals(_action)) {
} else if (_("Hide systray icon").equals(_action)) {
try {
SysTray tray = SysTray.getInstance();
if (tray != null) {
tray.hide();
addFormNotice("System tray icon disabled.");
addFormNotice(_("System tray icon disabled."));
} else {
addFormNotice("System tray icon feature not supported on this platform. Sorry!");
addFormNotice(_("System tray icon feature not supported on this platform. Sorry!"));
}
} catch (Throwable t) {
addFormError("Warning: unable to contact the systray manager - " + t.getMessage());
addFormError(_("Warning: unable to contact the systray manager") + " - " + t.getMessage());
}
} else if ("View console on startup".equals(_action)) {
} else if (_("View console on startup").equals(_action)) {
browseOnStartup(true);
addFormNotice("Console is to be shown on startup");
} else if ("Do not view console on startup".equals(_action)) {
addFormNotice(_("Console is to be shown on startup"));
} else if (_("Do not view console on startup").equals(_action)) {
browseOnStartup(false);
addFormNotice("Console is not to be shown on startup");
addFormNotice(_("Console is not to be shown on startup"));
} else {
//addFormNotice("Blah blah blah. whatever. I'm not going to " + _action);
}
@@ -126,17 +126,17 @@ public class ConfigServiceHandler extends FormHandler {
private void installService() {
try {
Runtime.getRuntime().exec("install_i2p_service_winnt.bat");
addFormNotice("Service installed");
addFormNotice(_("Service installed"));
} catch (IOException ioe) {
addFormError("Warning: unable to install the service - " + ioe.getMessage());
addFormError(_("Warning: unable to install the service") + " - " + ioe.getMessage());
}
}
private void uninstallService() {
try {
Runtime.getRuntime().exec("uninstall_i2p_service_winnt.bat");
addFormNotice("Service removed");
addFormNotice(_("Service removed"));
} catch (IOException ioe) {
addFormError("Warning: unable to remove the service - " + ioe.getMessage());
addFormError(_("Warning: unable to remove the service") + " - " + ioe.getMessage());
}
}

View File

@@ -115,10 +115,10 @@ public class ConfigStatsHandler extends FormHandler {
_context.router().setConfigSetting(StatManager.PROP_STAT_FULL, "" + _isFull);
boolean ok = _context.router().saveConfig();
if (ok)
addFormNotice("Stat filter and location updated successfully to: " + stats.toString());
addFormNotice(_("Stat filter and location updated successfully to") + ": " + stats.toString());
else
addFormError("Failed to update the stat filter and location");
addFormNotice("Graph list updated, may take up to 60s to be reflected here and on the <a href=\"graphs.jsp\">Graphs Page</a>");
addFormError(_("Failed to update the stat filter and location"));
addFormNotice(_("Graph list updated, may take up to 60s to be reflected here and on the <a href=\"graphs.jsp\">Graphs Page</a>"));
}
}

View File

@@ -32,7 +32,7 @@ public class ConfigTunnelsHandler extends FormHandler {
}
public void setShouldsave(String moo) {
if ( (moo != null) && (moo.equals("Save changes")) )
if ( (moo != null) && (moo.equals(_("Save changes"))) )
_shouldSave = true;
}
@@ -132,14 +132,16 @@ public class ConfigTunnelsHandler extends FormHandler {
}
if (updated > 0)
addFormNotice("Updated settings for " + updated + " pools.");
// the count isn't really correct anyway, since we don't check for actual changes
//addFormNotice("Updated settings for " + updated + " pools.");
addFormNotice(_("Updated settings for all pools."));
if (saveRequired) {
boolean saved = _context.router().saveConfig();
if (saved)
addFormNotice("Exploratory tunnel configuration saved successfully.");
addFormNotice(_("Exploratory tunnel configuration saved successfully."));
else
addFormNotice("Error saving the configuration (applied but not saved) - please see the error logs.");
addFormNotice(_("Error saving the configuration (applied but not saved) - please see the error logs."));
}
}
private static final int getInt(Object val) {

View File

@@ -8,9 +8,14 @@ import net.i2p.data.Destination;
import net.i2p.router.TunnelPoolSettings;
public class ConfigTunnelsHelper extends HelperBase {
static final String HOP = _x("hop");
static final String TUNNEL = _x("tunnel");
/** dummies for translation */
static final String HOPS = _x("hops");
static final String TUNNELS = _x("tunnels");
public ConfigTunnelsHelper() {}
public String getForm() {
StringBuilder buf = new StringBuilder(1024);
buf.append("<table>\n");
@@ -18,7 +23,7 @@ public class ConfigTunnelsHelper extends HelperBase {
TunnelPoolSettings exploratoryOut = _context.tunnelManager().getOutboundSettings();
buf.append("<input type=\"hidden\" name=\"pool.0\" value=\"exploratory\" >");
renderForm(buf, 0, "exploratory", "Exploratory tunnels", exploratoryIn, exploratoryOut);
renderForm(buf, 0, "exploratory", _("Exploratory tunnels"), exploratoryIn, exploratoryOut);
int cur = 1;
Set clients = _context.clientManager().listClients();
@@ -38,7 +43,7 @@ public class ConfigTunnelsHelper extends HelperBase {
String prefix = dest.calculateHash().toBase64().substring(0,4);
buf.append("<input type=\"hidden\" name=\"pool.").append(cur).append("\" value=\"");
buf.append(dest.calculateHash().toBase64()).append("\" >");
renderForm(buf, cur, prefix, "Client tunnels for " + name, in, out);
renderForm(buf, cur, prefix, _("Client tunnels for") + " " + _(name), in, out);
cur++;
}
@@ -61,95 +66,95 @@ public class ConfigTunnelsHelper extends HelperBase {
in.getLength() + in.getLengthVariance() <= 0 ||
out.getLength() <= 0 ||
out.getLength() + out.getLengthVariance() <= 0)
buf.append("<tr><th colspan=\"3\"><font color=\"red\">ANONYMITY WARNING - Settings include 0-hop tunnels.</font></th></tr>");
buf.append("<tr><th colspan=\"3\"><font color=\"red\">" + _("ANONYMITY WARNING - Settings include 0-hop tunnels.") + "</font></th></tr>");
else if (in.getLength() <= 1 ||
in.getLength() + in.getLengthVariance() <= 1 ||
out.getLength() <= 1 ||
out.getLength() + out.getLengthVariance() <= 1)
buf.append("<tr><th colspan=\"3\"><font color=\"red\">ANONYMITY WARNING - Settings include 1-hop tunnels.</font></th></tr>");
buf.append("<tr><th colspan=\"3\"><font color=\"red\">" + _("ANONYMITY WARNING - Settings include 1-hop tunnels.") + "</font></th></tr>");
if (in.getLength() + Math.abs(in.getLengthVariance()) >= WARN_LENGTH ||
out.getLength() + Math.abs(out.getLengthVariance()) >= WARN_LENGTH)
buf.append("<tr><th colspan=\"3\"><font color=\"red\">PERFORMANCE WARNING - Settings include very long tunnels.</font></th></tr>");
buf.append("<tr><th colspan=\"3\"><font color=\"red\">" + _("PERFORMANCE WARNING - Settings include very long tunnels.") + "</font></th></tr>");
if (in.getQuantity() + in.getBackupQuantity() >= WARN_QUANTITY ||
out.getQuantity() + out.getBackupQuantity() >= WARN_QUANTITY)
buf.append("<tr><th colspan=\"3\"><font color=\"red\">PERFORMANCE WARNING - Settings include high tunnel quantities.</font></th></tr>");
buf.append("<tr><th colspan=\"3\"><font color=\"red\">" + _("PERFORMANCE WARNING - Settings include high tunnel quantities.") + "</font></th></tr>");
buf.append("<tr><th></th><th><img src=\"/themes/console/images/inbound.png\" alt=\"Inbound\" title=\"Inbound Tunnels\">&nbsp;&nbsp;Inbound</th><th><img src=\"/themes/console/images/outbound.png\" alt=\"Outbound Tunnels\" title=\"Outbound\">&nbsp;&nbsp;Outbound</th></tr>\n");
buf.append("<tr><th></th><th><img src=\"/themes/console/images/inbound.png\" alt=\"Inbound\" title=\"Inbound Tunnels\">&nbsp;&nbsp;" + _("Inbound") + "</th><th><img src=\"/themes/console/images/outbound.png\" alt=\"Outbound Tunnels\" title=\"Outbound\">&nbsp;&nbsp;" + _("Outbound") + "</th></tr>\n");
// buf.append("<tr><th></th><th>Inbound</th><th>Outbound</th></tr>\n");
// tunnel depth
buf.append("<tr><td align=\"right\" class=\"mediumtags\">Depth:</td>\n");
buf.append("<tr><td align=\"right\" class=\"mediumtags\">" + _("Depth") + ":</td>\n");
buf.append("<td align=\"center\"><select name=\"").append(index).append(".depthInbound\">\n");
int now = in.getLength();
renderOptions(buf, 0, MAX_LENGTH, now, "", "hop");
renderOptions(buf, 0, MAX_LENGTH, now, "", HOP);
if (now > MAX_LENGTH)
renderOptions(buf, now, now, now, "", "hop");
renderOptions(buf, now, now, now, "", HOP);
buf.append("</select></td>\n");
buf.append("<td align=\"center\"><select name=\"").append(index).append(".depthOutbound\">\n");
now = out.getLength();
renderOptions(buf, 0, MAX_LENGTH, now, "", "hop");
renderOptions(buf, 0, MAX_LENGTH, now, "", HOP);
if (now > MAX_LENGTH)
renderOptions(buf, now, now, now, "", "hop");
renderOptions(buf, now, now, now, "", HOP);
buf.append("</select></td>\n");
buf.append("</tr>\n");
// tunnel depth variance
buf.append("<tr><td align=\"right\" class=\"mediumtags\">Randomization:</td>\n");
buf.append("<tr><td align=\"right\" class=\"mediumtags\">" + _("Randomization") + ":</td>\n");
buf.append("<td align=\"center\"><select name=\"").append(index).append(".varianceInbound\">\n");
now = in.getLengthVariance();
renderOptions(buf, 0, 0, now, "", "hop");
renderOptions(buf, 1, MAX_VARIANCE, now, "+ 0-", "hop");
renderOptions(buf, MIN_NEG_VARIANCE, -1, now, "+/- 0", "hop");
renderOptions(buf, 0, 0, now, "", HOP);
renderOptions(buf, 1, MAX_VARIANCE, now, "+ 0-", HOP);
renderOptions(buf, MIN_NEG_VARIANCE, -1, now, "+/- 0", HOP);
if (now > MAX_VARIANCE)
renderOptions(buf, now, now, now, "+ 0-", "hop");
renderOptions(buf, now, now, now, "+ 0-", HOP);
else if (now < MIN_NEG_VARIANCE)
renderOptions(buf, now, now, now, "+/- 0", "hop");
renderOptions(buf, now, now, now, "+/- 0", HOP);
buf.append("</select></td>\n");
buf.append("<td align=\"center\"><select name=\"").append(index).append(".varianceOutbound\">\n");
now = out.getLengthVariance();
renderOptions(buf, 0, 0, now, "", "hop");
renderOptions(buf, 1, MAX_VARIANCE, now, "+ 0-", "hop");
renderOptions(buf, MIN_NEG_VARIANCE, -1, now, "+/- 0", "hop");
renderOptions(buf, 0, 0, now, "", HOP);
renderOptions(buf, 1, MAX_VARIANCE, now, "+ 0-", HOP);
renderOptions(buf, MIN_NEG_VARIANCE, -1, now, "+/- 0", HOP);
if (now > MAX_VARIANCE)
renderOptions(buf, now, now, now, "+ 0-", "hop");
renderOptions(buf, now, now, now, "+ 0-", HOP);
else if (now < MIN_NEG_VARIANCE)
renderOptions(buf, now, now, now, "+/- 0", "hop");
renderOptions(buf, now, now, now, "+/- 0", HOP);
buf.append("</select></td>\n");
// tunnel quantity
buf.append("<tr><td align=\"right\" class=\"mediumtags\">Quantity:</td>\n");
buf.append("<tr><td align=\"right\" class=\"mediumtags\">" + _("Quantity") + ":</td>\n");
buf.append("<td align=\"center\"><select name=\"").append(index).append(".quantityInbound\">\n");
now = in.getQuantity();
renderOptions(buf, 1, MAX_QUANTITY, now, "", "tunnel");
renderOptions(buf, 1, MAX_QUANTITY, now, "", TUNNEL);
if (now > MAX_QUANTITY)
renderOptions(buf, now, now, now, "", "tunnel");
renderOptions(buf, now, now, now, "", TUNNEL);
buf.append("</select></td>\n");
buf.append("<td align=\"center\"><select name=\"").append(index).append(".quantityOutbound\">\n");
now = out.getQuantity();
renderOptions(buf, 1, MAX_QUANTITY, now, "", "tunnel");
renderOptions(buf, 1, MAX_QUANTITY, now, "", TUNNEL);
if (now > MAX_QUANTITY)
renderOptions(buf, now, now, now, "", "tunnel");
renderOptions(buf, now, now, now, "", TUNNEL);
buf.append("</select></td>\n");
buf.append("</tr>\n");
// tunnel backup quantity
buf.append("<tr><td align=\"right\" class=\"mediumtags\">Backup quantity:</td>\n");
buf.append("<tr><td align=\"right\" class=\"mediumtags\">" + _("Backup quantity") + ":</td>\n");
buf.append("<td align=\"center\"><select name=\"").append(index).append(".backupInbound\">\n");
now = in.getBackupQuantity();
renderOptions(buf, 0, MAX_BACKUP_QUANTITY, now, "", "tunnel");
renderOptions(buf, 0, MAX_BACKUP_QUANTITY, now, "", TUNNEL);
if (now > MAX_BACKUP_QUANTITY)
renderOptions(buf, now, now, now, "", "tunnel");
renderOptions(buf, now, now, now, "", TUNNEL);
buf.append("</select></td>\n");
buf.append("<td align=\"center\"><select name=\"").append(index).append(".backupOutbound\">\n");
now = out.getBackupQuantity();
renderOptions(buf, 0, MAX_BACKUP_QUANTITY, now, "", "tunnel");
renderOptions(buf, 0, MAX_BACKUP_QUANTITY, now, "", TUNNEL);
if (now > MAX_BACKUP_QUANTITY)
renderOptions(buf, now, now, now, "", "tunnel");
renderOptions(buf, now, now, now, "", TUNNEL);
buf.append("</select></td>\n");
buf.append("</tr>\n");
@@ -159,7 +164,7 @@ buf.append("<tr><th></th><th><img src=\"/themes/console/images/inbound.png\" alt
// And let's not display them at all unless they have contents, which should be rare.
Properties props = in.getUnknownOptions();
if (props.size() > 0) {
buf.append("<tr><td align=\"right\" class=\"mediumtags\">Inbound options:</td>\n" +
buf.append("<tr><td align=\"right\" class=\"mediumtags\">" + _("Inbound options") + ":</td>\n" +
"<td colspan=\"2\" align=\"center\"><input name=\"").append(index);
buf.append(".inboundOptions\" type=\"text\" size=\"32\" disabled=\"true\" " +
"value=\"");
@@ -172,7 +177,7 @@ buf.append("<tr><th></th><th><img src=\"/themes/console/images/inbound.png\" alt
}
props = out.getUnknownOptions();
if (props.size() > 0) {
buf.append("<tr><td align=\"right\" class=\"mediumtags\">Outbound options:</td>\n" +
buf.append("<tr><td align=\"right\" class=\"mediumtags\">" + _("Outbound options") + ":</td>\n" +
"<td colspan=\"2\" align=\"center\"><input name=\"").append(index);
buf.append(".outboundOptions\" type=\"text\" size=\"32\" disabled=\"true\" " +
"value=\"");
@@ -191,9 +196,13 @@ buf.append("<tr><th></th><th><img src=\"/themes/console/images/inbound.png\" alt
buf.append("<option value=\"").append(i).append("\" ");
if (i == now)
buf.append("selected=\"true\" ");
buf.append(">").append(prefix).append(i).append(' ').append(name);
String pname;
// pluralize and then translate
if (i != 1 && i != -1)
buf.append('s');
pname = name + 's';
else
pname = name;
buf.append(">").append(prefix).append(i).append(' ').append(_(pname));
buf.append("</option>\n");
}
}

View File

@@ -17,16 +17,23 @@ public class ConfigUIHandler extends FormHandler {
_config = val;
}
/** note - lang change is handled in CSSHelper but we still need to save it here */
private void saveChanges() {
if (_config == null)
return;
String oldTheme = _context.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
if (_config.equals("default")) // obsolete
_context.router().removeConfigSetting(CSSHelper.PROP_THEME_NAME);
else
_context.router().setConfigSetting(CSSHelper.PROP_THEME_NAME, _config);
if (_context.router().saveConfig())
addFormNotice("Theme change saved. <a href=\"configui.jsp\">Refresh the page</a> to view.");
else
addFormNotice("Error saving the configuration (applied but not saved) - please see the error logs.");
if (_context.router().saveConfig()) {
if (!oldTheme.equals(_config))
addFormNotice(_("Theme change saved.") +
" <a href=\"configui.jsp\">" +
_("Refresh the page to view.") +
"</a>");
} else {
addFormNotice(_("Error saving the configuration (applied but not saved) - please see the error logs."));
}
}
}

View File

@@ -1,13 +1,15 @@
package net.i2p.router.web;
import java.io.File;
import java.util.TreeSet;
import java.util.Set;
public class ConfigUIHelper extends HelperBase {
public ConfigUIHelper() {}
private static final String themes[] = {_x("classic"), _x("dark"), _x("light")};
public String getSettings() {
StringBuilder buf = new StringBuilder(512);
String current = _context.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
Set<String> themes = themeSet();
for (String theme : themes) {
buf.append("<input type=\"radio\" class=\"optbox\" name=\"theme\" ");
if (theme.equals(current))
@@ -17,10 +19,29 @@ public class ConfigUIHelper extends HelperBase {
return buf.toString();
}
/** @return standard and user-installed themes, sorted (untranslated) */
private Set<String> themeSet() {
Set<String> rv = new TreeSet();
// add a failsafe even if we can't find any themes
rv.add(CSSHelper.DEFAULT_THEME);
File dir = new File(_context.getBaseDir(), "docs/themes/console");
File[] files = dir.listFiles();
if (files == null)
return rv;
for (int i = 0; i < files.length; i++) {
String name = files[i].getName();
if (files[i].isDirectory() && ! name.equals("images"))
rv.add(name);
}
return rv;
}
private static final String langs[] = {"de", "en", "fr", "nl", "se", "zh"};
private static final String flags[] = {"de", "us", "fr", "nl", "se", "cn"};
private static final String xlangs[] = {_x("German"), _x("English"), _x("French"),
_x("Dutch"), _x("Swedish"), _x("Chinese")};
/** todo sort by translated string */
public String getLangSettings() {
StringBuilder buf = new StringBuilder(512);
String current = Messages.getLanguage(_context);
@@ -29,7 +50,9 @@ public class ConfigUIHelper extends HelperBase {
buf.append("<input type=\"radio\" class=\"optbox\" name=\"lang\" ");
if (langs[i].equals(current))
buf.append("checked=\"true\" ");
buf.append("value=\"").append(langs[i]).append("\">").append(_(xlangs[i])).append("<br>\n");
buf.append("value=\"").append(langs[i]).append("\">")
.append("<img height=\"11\" width=\"16\" alt=\"\" src=\"/flags.jsp?c=").append(flags[i]).append("\"> ")
.append(_(xlangs[i])).append("<br>\n");
}
return buf.toString();
}

View File

@@ -51,25 +51,28 @@ public class ConfigUpdateHandler extends FormHandler {
@Override
protected void processForm() {
if (_action != null && _action.startsWith("Check")) {
if (_action == null)
return;
if (_action.equals(_("Check for updates"))) {
NewsFetcher fetcher = NewsFetcher.getInstance(I2PAppContext.getGlobalContext());
fetcher.fetchNews();
if (fetcher.shouldFetchUnsigned())
fetcher.fetchUnsignedHead();
if (fetcher.updateAvailable() || fetcher.unsignedUpdateAvailable()) {
if ( (_updatePolicy == null) || (!_updatePolicy.equals("notify")) )
addFormNotice("Update available, attempting to download now");
addFormNotice(_("Update available, attempting to download now"));
else
addFormNotice("Update available, click button on left to download");
addFormNotice(_("Update available, click button on left to download"));
} else
addFormNotice("No update available");
addFormNotice(_("No update available"));
return;
}
if ( (_newsURL != null) && (_newsURL.length() > 0) ) {
String oldURL = ConfigUpdateHelper.getNewsURL(_context);
if ( (oldURL == null) || (!_newsURL.equals(oldURL)) ) {
_context.router().setConfigSetting(PROP_NEWS_URL, _newsURL);
addFormNotice("Updating news URL to " + _newsURL);
addFormNotice(_("Updating news URL to") + " " + _newsURL);
}
}
@@ -77,7 +80,7 @@ public class ConfigUpdateHandler extends FormHandler {
String oldHost = _context.router().getConfigSetting(PROP_PROXY_HOST);
if ( (oldHost == null) || (!_proxyHost.equals(oldHost)) ) {
_context.router().setConfigSetting(PROP_PROXY_HOST, _proxyHost);
addFormNotice("Updating proxy host to " + _proxyHost);
addFormNotice(_("Updating proxy host to") + " " + _proxyHost);
}
}
@@ -85,7 +88,7 @@ public class ConfigUpdateHandler extends FormHandler {
String oldPort = _context.router().getConfigSetting(PROP_PROXY_PORT);
if ( (oldPort == null) || (!_proxyPort.equals(oldPort)) ) {
_context.router().setConfigSetting(PROP_PROXY_PORT, _proxyPort);
addFormNotice("Updating proxy port to " + _proxyPort);
addFormNotice(_("Updating proxy port to") + " " + _proxyPort);
}
}
@@ -98,14 +101,14 @@ public class ConfigUpdateHandler extends FormHandler {
try { oldFreq = Long.parseLong(oldFreqStr); } catch (NumberFormatException nfe) {}
if (_refreshFrequency != oldFreq) {
_context.router().setConfigSetting(PROP_REFRESH_FREQUENCY, ""+_refreshFrequency);
addFormNotice("Updating refresh frequency to " + DataHelper.formatDuration(_refreshFrequency));
addFormNotice(_("Updating refresh frequency to") + " " + DataHelper.formatDuration(_refreshFrequency));
}
if ( (_updatePolicy != null) && (_updatePolicy.length() > 0) ) {
String oldPolicy = _context.router().getConfigSetting(PROP_UPDATE_POLICY);
if ( (oldPolicy == null) || (!_updatePolicy.equals(oldPolicy)) ) {
_context.router().setConfigSetting(PROP_UPDATE_POLICY, _updatePolicy);
addFormNotice("Updating update policy to " + _updatePolicy);
addFormNotice(_("Updating update policy to") + " " + _updatePolicy);
}
}
@@ -114,7 +117,7 @@ public class ConfigUpdateHandler extends FormHandler {
String oldURL = _context.router().getConfigSetting(PROP_UPDATE_URL);
if ( (oldURL == null) || (!_updateURL.equals(oldURL)) ) {
_context.router().setConfigSetting(PROP_UPDATE_URL, _updateURL);
addFormNotice("Updating update URLs.");
addFormNotice(_("Updating update URLs."));
}
}
@@ -122,7 +125,7 @@ public class ConfigUpdateHandler extends FormHandler {
String oldKeys = new TrustedUpdate(_context).getTrustedKeysString();
if ( (oldKeys == null) || (!_trustedKeys.equals(oldKeys)) ) {
_context.router().setConfigSetting(PROP_TRUSTED_KEYS, _trustedKeys);
addFormNotice("Updating trusted keys.");
addFormNotice(_("Updating trusted keys."));
}
}
@@ -130,7 +133,7 @@ public class ConfigUpdateHandler extends FormHandler {
String oldURL = _context.router().getConfigSetting(PROP_ZIP_URL);
if ( (oldURL == null) || (!_zipURL.equals(oldURL)) ) {
_context.router().setConfigSetting(PROP_ZIP_URL, _zipURL);
addFormNotice("Updating unsigned update URL to " + _zipURL);
addFormNotice(_("Updating unsigned update URL to") + " " + _zipURL);
}
}

View File

@@ -72,9 +72,9 @@ public class ConfigUpdateHelper extends HelperBase {
buf.append("\" selected=\"true\"");
if (PERIODS[i] == -1)
buf.append("\">Never</option>\n");
buf.append("\">" + _("Never") + "</option>\n");
else
buf.append("\">Every ").append(DataHelper.formatDuration(PERIODS[i])).append("</option>\n");
buf.append("\">" + _("Every") + " ").append(DataHelper.formatDuration(PERIODS[i])).append("</option>\n");
}
buf.append("</select>\n");
return buf.toString();
@@ -89,18 +89,18 @@ public class ConfigUpdateHelper extends HelperBase {
if ("notify".equals(policy))
buf.append("<option value=\"notify\" selected=\"true\">").append(_("Notify only")).append("</option>");
else
buf.append("<option value=\"notify\">Notify only</option>");
buf.append("<option value=\"notify\">" + _("Notify only") + "</option>");
if ("download".equals(policy))
buf.append("<option value=\"download\" selected=\"true\">Download and verify only</option>");
buf.append("<option value=\"download\" selected=\"true\">" + _("Download and verify only") + "</option>");
else
buf.append("<option value=\"download\">Download and verify only</option>");
buf.append("<option value=\"download\">" + _("Download and verify only") + "</option>");
if (System.getProperty("wrapper.version") != null) {
if ("install".equals(policy))
buf.append("<option value=\"install\" selected=\"true\">Download, verify, and restart</option>");
buf.append("<option value=\"install\" selected=\"true\">" + _("Download, verify, and restart") + "</option>");
else
buf.append("<option value=\"install\">Download, verify, and restart</option>");
buf.append("<option value=\"install\">" + _("Download, verify, and restart") + "</option>");
}
buf.append("</select>\n");

View File

@@ -104,33 +104,24 @@ public class GraphHelper extends HelperBase {
}
public String getForm() {
try {
_out.write("<br><h3>Configure Graph Display [<a href=\"configstats.jsp\">Select Stats</a>]</h3>");
_out.write("<br><h3>" + _("Configure Graph Display") + " [<a href=\"configstats.jsp\">" + _("Select Stats") + "</a>]</h3>");
_out.write("<form action=\"graphs.jsp\" method=\"GET\">");
_out.write("Periods: <input size=\"3\" type=\"text\" name=\"periodCount\" value=\"" + _periodCount + "\"><br>\n");
_out.write("Plot averages: <input type=\"radio\" class=\"optbox\" name=\"showEvents\" value=\"false\" " + (_showEvents ? "" : "checked=\"true\" ") + "> ");
_out.write("or plot events: <input type=\"radio\" class=\"optbox\" name=\"showEvents\" value=\"true\" "+ (_showEvents ? "checked=\"true\" " : "") + "><br>\n");
_out.write("Image sizes: width: <input size=\"4\" type=\"text\" name=\"width\" value=\"" + _width
+ "\"> pixels, height: <input size=\"4\" type=\"text\" name=\"height\" value=\"" + _height
+ "\"><br>\n");
_out.write("Refresh delay: <select name=\"refreshDelay\"><option value=\"60\">1 minute</option><option value=\"120\">2 minutes</option><option value=\"300\">5 minutes</option><option value=\"600\">10 minutes</option><option value=\"1800\">30 minutes</option><option value=\"3600\">1 hour</option><option value=\"-1\">Never</option></select><br>\n");
_out.write("<hr><div class=\"formaction\"><input type=\"submit\" value=\"Redraw\"></div></form>");
_out.write(_("Periods") + ": <input size=\"3\" type=\"text\" name=\"periodCount\" value=\"" + _periodCount + "\"><br>\n");
_out.write(_("Plot averages") + ": <input type=\"radio\" class=\"optbox\" name=\"showEvents\" value=\"false\" " + (_showEvents ? "" : "checked=\"true\" ") + "> ");
_out.write(_("or")+ " " +_("plot events") + ": <input type=\"radio\" class=\"optbox\" name=\"showEvents\" value=\"true\" "+ (_showEvents ? "checked=\"true\" " : "") + "><br>\n");
_out.write(_("Image sizes") + ": " + _("width") + ": <input size=\"4\" type=\"text\" name=\"width\" value=\"" + _width
+ "\"> " + _("pixels") + ", " + _("height") + ": <input size=\"4\" type=\"text\" name=\"height\" value=\"" + _height
+ "\"> " + _("pixels") + "<br>\n");
_out.write(_("Refresh delay") + ": <select name=\"refreshDelay\"><option value=\"60\">1 " + _("minute") + "</option><option value=\"120\">2 " + _("minutes") + "</option><option value=\"300\">5 " + _("minutes") + "</option><option value=\"600\">10 " + _("minutes") + "</option><option value=\"1800\">30 " + _("minutes") + "</option><option value=\"3600\">1 " + _("hour") + "</option><option value=\"-1\">" + _("Never") + "</option></select><br>\n");
_out.write("<hr><div class=\"formaction\"><input type=\"submit\" value=\"" + _("Redraw") + "\"></div></form>");
} catch (IOException ioe) {
ioe.printStackTrace();
}
return "";
}
public String getPeerSummary() {
try {
_context.commSystem().renderStatusHTML(_out);
_context.bandwidthLimiter().renderStatusHTML(_out);
} catch (IOException ioe) {
ioe.printStackTrace();
}
return "";
}
}
class AlphaComparator implements Comparator {
/** inner class, don't bother reindenting */
private static class AlphaComparator implements Comparator {
public int compare(Object lhs, Object rhs) {
SummaryListener l = (SummaryListener)lhs;
SummaryListener r = (SummaryListener)rhs;
@@ -139,3 +130,5 @@ class AlphaComparator implements Comparator {
return lName.compareTo(rName);
}
}
}

View File

@@ -10,7 +10,7 @@ public class LogsHelper extends HelperBase {
public String getLogs() {
String str = formatMessages(_context.logManager().getBuffer().getMostRecentMessages());
return "Location: <code>" + _context.logManager().currentFile() + "</code><br><br>" + str;
return "Location: <b><code>" + _context.logManager().currentFile() + "</code></b><br><br>" + str;
}
public String getCriticalLogs() {
@@ -34,7 +34,7 @@ public class LogsHelper extends HelperBase {
return "";
else {
str = str.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
return "Location:<code> " + f.getAbsolutePath() + "</code> <pre>" + str + "</pre>";
return "Location:<b><code> " + f.getAbsolutePath() + "</code></b> <pre>" + str + "</pre>";
}
}

View File

@@ -25,8 +25,12 @@ public class Messages {
private static final String _localeLang = Locale.getDefault().getLanguage();
private static final Map<String, ResourceBundle> _bundles = new ConcurrentHashMap(2);
private static final Set<String> _missing = new ConcurrentHashSet(2);
/** use to look for untagged strings */
private static final String TEST_LANG = "xx";
private static final String TEST_STRING = "XXXX";
/** current locale **/
/* unused
public static String getString(String key) {
if (_localeLang.equals("en"))
return key;
@@ -39,12 +43,15 @@ public class Messages {
return key;
}
}
*/
/** lang in routerconsole.lang property, else current locale */
public static String getString(String key, I2PAppContext ctx) {
String lang = getLanguage(ctx);
if (lang.equals("en"))
return key;
else if (lang.equals(TEST_LANG))
return TEST_STRING;
ResourceBundle bundle = findBundle(lang);
if (bundle == null)
return key;
@@ -68,17 +75,20 @@ public class Messages {
* Use autoboxing to call with ints, longs, floats, etc.
*/
public static String getString(String s, Object o, I2PAppContext ctx) {
String lang = getLanguage(ctx);
if (lang.equals(TEST_LANG))
return TEST_STRING + '(' + o + ')' + TEST_STRING;
String x = getString(s, ctx);
Object[] oArray = new Object[1];
oArray[0] = o;
try {
MessageFormat fmt = new MessageFormat(x, new Locale(getLanguage(ctx)));
MessageFormat fmt = new MessageFormat(x, new Locale(lang));
return fmt.format(oArray, new StringBuffer(), null).toString();
} catch (IllegalArgumentException iae) {
System.err.println("Bad format: orig: \"" + s +
"\" trans: \"" + x +
"\" param: \"" + o +
"\" lang: " + getLanguage(ctx));
"\" lang: " + lang);
return "FIXME: " + x + ' ' + o;
}
}

View File

@@ -7,13 +7,17 @@ import java.io.OutputStreamWriter;
public class NetDbHelper extends HelperBase {
private String _routerPrefix;
private boolean _full = false;
private int _full;
private boolean _lease = false;
public NetDbHelper() {}
public void setRouter(String r) { _routerPrefix = r; }
public void setFull(String f) { _full = "1".equals(f); }
public void setFull(String f) {
try {
_full = Integer.parseInt(f);
} catch (NumberFormatException nfe) {}
}
public void setLease(String l) { _lease = "1".equals(l); }
public String getNetDbSummary() {

View File

@@ -18,6 +18,7 @@ import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import net.i2p.crypto.TrustedUpdate;
import net.i2p.data.DataHelper;
import net.i2p.data.Destination;
import net.i2p.data.Hash;
@@ -55,7 +56,7 @@ public class NetDbRenderer {
public void renderRouterInfoHTML(Writer out, String routerPrefix) throws IOException {
StringBuilder buf = new StringBuilder(4*1024);
buf.append("<h2>Network Database RouterInfo Lookup</h2>\n");
buf.append("<h2>" + _("Network Database RouterInfo Lookup") + "</h2>\n");
if (".".equals(routerPrefix)) {
renderRouterInfo(buf, _context.router().getRouterInfo(), true, true);
} else {
@@ -70,21 +71,17 @@ public class NetDbRenderer {
}
}
if (notFound)
buf.append("Router ").append(routerPrefix).append(" not found in network database");
buf.append(_("Router") + ' ').append(routerPrefix).append(' ' + _("not found in network database") );
}
out.write(buf.toString());
out.flush();
}
public void renderStatusHTML(Writer out) throws IOException {
renderStatusHTML(out, true);
}
public void renderLeaseSetHTML(Writer out) throws IOException {
StringBuilder buf = new StringBuilder(4*1024);
buf.append("<h2>Network Database Contents</h2>\n");
buf.append("<a href=\"netdb.jsp\">View RouterInfo</a>");
buf.append("<h3>LeaseSets</h3>\n");
buf.append("<h2>" + _("Network Database Contents") + "</h2>\n");
buf.append("<a href=\"netdb.jsp\">" + _("View RouterInfo") + "</a>");
buf.append("<h3>").append(_("LeaseSets")).append("</h3>\n");
Set leases = new TreeSet(new LeaseSetComparator());
leases.addAll(_context.netDb().getLeases());
long now = _context.clock().now();
@@ -92,19 +89,19 @@ public class NetDbRenderer {
LeaseSet ls = (LeaseSet)iter.next();
Destination dest = ls.getDestination();
Hash key = dest.calculateHash();
buf.append("<b>LeaseSet: ").append(key.toBase64());
buf.append("<b>").append(_("LeaseSet")).append(": ").append(key.toBase64());
if (_context.clientManager().isLocal(dest)) {
buf.append(" (<a href=\"tunnels.jsp#" + key.toBase64().substring(0,4) + "\">Local</a> ");
buf.append(" (<a href=\"tunnels.jsp#" + key.toBase64().substring(0,4) + "\">" + _("Local") + "</a> ");
if (! _context.clientManager().shouldPublishLeaseSet(key))
buf.append("Unpublished ");
buf.append("Destination ");
buf.append(_("Unpublished") + ' ');
buf.append(_("Destination") + ' ');
TunnelPoolSettings in = _context.tunnelManager().getInboundSettings(key);
if (in != null && in.getDestinationNickname() != null)
buf.append(in.getDestinationNickname());
else
buf.append(dest.toBase64().substring(0, 6));
} else {
buf.append(" (Destination ");
buf.append(" (" + _("Destination") + ' ');
String host = _context.namingService().reverseLookup(dest);
if (host != null)
buf.append(host);
@@ -114,13 +111,13 @@ public class NetDbRenderer {
buf.append(")</b><br>\n");
long exp = ls.getEarliestLeaseDate()-now;
if (exp > 0)
buf.append("Expires in ").append(DataHelper.formatDuration(exp)).append("<br>\n");
buf.append(_("Expires in {0}", DataHelper.formatDuration(exp))).append("<br>\n");
else
buf.append("Expired ").append(DataHelper.formatDuration(0-exp)).append(" ago<br>\n");
buf.append(_("Expired {0} ago", DataHelper.formatDuration(0-exp))).append("<br>\n");
for (int i = 0; i < ls.getLeaseCount(); i++) {
buf.append("Lease ").append(i + 1).append(": Gateway ");
buf.append(_("Lease")).append(' ').append(i + 1).append(": " + _("Gateway") + ' ');
buf.append(_context.commSystem().renderPeerHTML(ls.getLease(i).getGateway()));
buf.append(" Tunnel ").append(ls.getLease(i).getTunnelId().getTunnelId()).append("<br>\n");
buf.append(' ' + _("Tunnel") + ' ').append(ls.getLease(i).getTunnelId().getTunnelId()).append("<br>\n");
}
buf.append("<hr>\n");
out.write(buf.toString());
@@ -130,27 +127,29 @@ public class NetDbRenderer {
out.flush();
}
public void renderStatusHTML(Writer out, boolean full) throws IOException {
int size = _context.netDb().getKnownRouters() * 512;
if (full)
size *= 4;
StringBuilder buf = new StringBuilder(size);
out.write("<h2>Network Database Contents (<a href=\"netdb.jsp?l=1\">View LeaseSets</a>)</h2>\n");
/**
* @param mode 0: our info and charts only; 1: full routerinfos and charts; 2: abbreviated routerinfos and charts
*/
public void renderStatusHTML(Writer out, int mode) throws IOException {
out.write("<h2>" + _("Network Database Contents") + " (<a href=\"netdb.jsp?l=1\">" + _("View LeaseSets") + "</a>)</h2>\n");
if (!_context.netDb().isInitialized()) {
buf.append("Not initialized\n");
out.write(buf.toString());
out.write(_("Not initialized"));
out.flush();
return;
}
boolean full = mode == 1;
boolean shortStats = mode == 2;
boolean showStats = full || shortStats;
Hash us = _context.routerHash();
out.write("<a name=\"routers\" ></a><h3>Routers (<a href=\"netdb.jsp");
if (full)
out.write("#routers\" >view without");
out.write("<a name=\"routers\" ></a><h3>" + _("Routers") + " (<a href=\"netdb.jsp");
if (full || !showStats)
out.write("?f=2#routers\" >" + _("Show all routers"));
else
out.write("?f=1#routers\" >view with");
out.write(" stats</a>)</h3>\n");
out.write("?f=1#routers\" >" + _("Show all routers with full stats"));
out.write("</a>)</h3>\n");
StringBuilder buf = new StringBuilder(8192);
RouterInfo ourInfo = _context.router().getRouterInfo();
renderRouterInfo(buf, ourInfo, true, true);
out.write(buf.toString());
@@ -158,6 +157,7 @@ public class NetDbRenderer {
ObjectCounter<String> versions = new ObjectCounter();
ObjectCounter<String> countries = new ObjectCounter();
int[] transportCount = new int[8];
Set routers = new TreeSet(new RouterInfoComparator());
routers.addAll(_context.netDb().getRouters());
@@ -166,24 +166,28 @@ public class NetDbRenderer {
Hash key = ri.getIdentity().getHash();
boolean isUs = key.equals(us);
if (!isUs) {
renderRouterInfo(buf, ri, false, full);
out.write(buf.toString());
buf.setLength(0);
if (showStats) {
renderRouterInfo(buf, ri, false, full);
out.write(buf.toString());
buf.setLength(0);
}
String routerVersion = ri.getOption("router.version");
if (routerVersion != null)
versions.increment(routerVersion);
String country = _context.commSystem().getCountry(key);
if(country != null)
countries.increment(country);
transportCount[classifyTransports(ri)]++;
}
}
buf.append("<table border=\"0\" cellspacing=\"30\"><tr><td>");
buf.append("<table border=\"0\" cellspacing=\"30\"><tr><th colspan=\"3\">").append(_("Network Database Router Statistics")).append("</th><tr><td>");
// versions table
List<String> versionList = new ArrayList(versions.objects());
if (versionList.size() > 0) {
Collections.sort(versionList, Collections.reverseOrder());
Collections.sort(versionList, Collections.reverseOrder(new TrustedUpdate.VersionComparator()));
buf.append("<table>\n");
buf.append("<tr><th>Version</th><th>Count</th></tr>\n");
buf.append("<tr><th>" + _("Version") + "</th><th>" + _("Count") + "</th></tr>\n");
for (String routerVersion : versionList) {
int num = versions.count(routerVersion);
buf.append("<tr><td align=\"center\">").append(DataHelper.stripHTML(routerVersion));
@@ -195,25 +199,50 @@ public class NetDbRenderer {
out.write(buf.toString());
buf.setLength(0);
// transports table
buf.append("<table>\n");
buf.append("<tr><th align=\"left\">" + _("Transports") + "</th><th>" + _("Count") + "</th></tr>\n");
for (int i = 0; i < 8; i++) {
int num = transportCount[i];
if (num > 0) {
buf.append("<tr><td>").append(_(TNAMES[i]));
buf.append("</td><td align=\"center\">").append(num).append("</td></tr>\n");
}
}
buf.append("</table>\n");
buf.append("</td><td>");
out.write(buf.toString());
buf.setLength(0);
// country table
List<String> countryList = new ArrayList(countries.objects());
if (countryList.size() > 0) {
Collections.sort(countryList);
Collections.sort(countryList, new CountryComparator());
buf.append("<table>\n");
buf.append("<tr><th align=\"left\">Country</th><th>Count</th></tr>\n");
buf.append("<tr><th align=\"left\">" + _("Country") + "</th><th>" + _("Count") + "</th></tr>\n");
for (String country : countryList) {
int num = countries.count(country);
buf.append("<tr><td><img height=\"11\" width=\"16\" alt=\"").append(country.toUpperCase()).append("\"");
buf.append(" src=\"/flags.jsp?c=").append(country).append("\"> ");
buf.append(_context.commSystem().getCountryName(country));
buf.append(_(_context.commSystem().getCountryName(country)));
buf.append("</td><td align=\"center\">").append(num).append("</td></tr>\n");
}
buf.append("</table>\n");
}
buf.append("</td></tr></table>");
out.write(buf.toString());
out.flush();
}
/** sort by translated country name */
private class CountryComparator implements Comparator {
public int compare(Object l, Object r) {
return _(_context.commSystem().getCountryName((String)l))
.compareTo(_(_context.commSystem().getCountryName((String)r)));
}
}
/**
* Be careful to use stripHTML for any displayed routerInfo data
* to prevent vulnerabilities
@@ -222,32 +251,37 @@ public class NetDbRenderer {
String hash = info.getIdentity().getHash().toBase64();
buf.append("<table><tr><th><a name=\"").append(hash.substring(0, 6)).append("\" ></a>");
if (isUs) {
buf.append("<a name=\"our-info\" ></a><b>Our info: ").append(hash).append("</b></th></tr><tr><td>\n");
buf.append("<a name=\"our-info\" ></a><b>" + _("Our info") + ": ").append(hash).append("</b></th></tr><tr><td>\n");
} else {
buf.append("<b>Peer info for:</b> ").append(hash).append("\n");
buf.append("<b>" + _("Peer info for") + ":</b> ").append(hash).append("\n");
if (full) {
buf.append("[<a href=\"netdb.jsp\" >Back</a>]</th></tr><td>\n");
} else {
buf.append("[<a href=\"netdb.jsp?r=").append(hash.substring(0, 6)).append("\" >Full entry</a>]</th></tr><td>\n");
buf.append("[<a href=\"netdb.jsp?r=").append(hash.substring(0, 6)).append("\" >").append(_("Full entry")).append("</a>]</th></tr><td>\n");
}
}
long age = _context.clock().now() - info.getPublished();
if (isUs && _context.router().isHidden())
buf.append("<b>Hidden, Updated:</b> ").append(DataHelper.formatDuration(age)).append(" ago<br>\n");
else if (age > 0)
buf.append("<b>Published:</b> ").append(DataHelper.formatDuration(age)).append(" ago<br>\n");
else
buf.append("<b>Published:</b> in ").append(DataHelper.formatDuration(0-age)).append("???<br>\n");
buf.append("<b>Address(es):</b> ");
if (isUs && _context.router().isHidden()) {
buf.append("<b>").append(_("Hidden")).append(", ").append(_("Updated")).append(":</b> ")
.append(_("{0} ago", DataHelper.formatDuration(age))).append("<br>\n");
} else if (age > 0) {
buf.append("<b>").append(_("Published")).append(":</b> ")
.append(_("{0} ago", DataHelper.formatDuration(age))).append("<br>\n");
} else {
// shouldnt happen
buf.append("<b>" + _("Published") + ":</b> in ").append(DataHelper.formatDuration(0-age)).append("???<br>\n");
}
buf.append("<b>" + _("Address(es)") + ":</b> ");
String country = _context.commSystem().getCountry(info.getIdentity().getHash());
if(country != null) {
buf.append("<img height=\"11\" width=\"16\" alt=\"").append(country.toUpperCase()).append("\"");
buf.append("<img height=\"11\" width=\"16\" alt=\"").append(country.toUpperCase()).append('\"');
buf.append(" title=\"").append(_(_context.commSystem().getCountryName(country))).append('\"');
buf.append(" src=\"/flags.jsp?c=").append(country).append("\"> ");
}
for (Iterator iter = info.getAddresses().iterator(); iter.hasNext(); ) {
RouterAddress addr = (RouterAddress)iter.next();
buf.append(DataHelper.stripHTML(addr.getTransportStyle())).append(": ");
buf.append("<b>").append(DataHelper.stripHTML(addr.getTransportStyle())).append(":</b> ");
for (Iterator optIter = addr.getOptions().keySet().iterator(); optIter.hasNext(); ) {
String name = (String)optIter.next();
String val = addr.getOptions().getProperty(name);
@@ -256,7 +290,7 @@ public class NetDbRenderer {
}
buf.append("</td></tr>\n");
if (full) {
buf.append("<tr><td>Stats: <br><code>\n");
buf.append("<tr><td>" + _("Stats") + ": <br><code>\n");
for (Iterator iter = info.getOptions().keySet().iterator(); iter.hasNext(); ) {
String key = (String)iter.next();
String val = info.getOption(key);
@@ -268,8 +302,55 @@ public class NetDbRenderer {
buf.append("</td></tr>\n");
}
private static final int SSU = 1;
private static final int SSUI = 2;
private static final int NTCP = 4;
private static final String[] TNAMES = { _x("Hidden or starting up"), _x("SSU"), _x("SSU with introducers"), "",
_x("NTCP"), _x("NTCP and SSU"), _x("NTCP and SSU with introducers"), "" };
/**
* what transport types
*/
private int classifyTransports(RouterInfo info) {
int rv = 0;
String hash = info.getIdentity().getHash().toBase64();
for (Iterator iter = info.getAddresses().iterator(); iter.hasNext(); ) {
RouterAddress addr = (RouterAddress)iter.next();
String style = addr.getTransportStyle();
if (style.equals("NTCP")) {
rv |= NTCP;
} else if (style.equals("SSU")) {
if (addr.getOptions().getProperty("iport0") != null)
rv |= SSUI;
else
rv |= SSU;
}
}
return rv;
}
/** translate a string */
private String _(String s) {
return Messages.getString(s, _context);
}
/** tag only */
private static final String _x(String s) {
return s;
}
/**
* translate a string with a parameter
* This is a lot more expensive than _(s), so use sparingly.
*
* @param s string to be translated containing {0}
* The {0} will be replaced by the parameter.
* Single quotes must be doubled, i.e. ' -> '' in the string.
* @param o parameter, not translated.
* To tranlslate parameter also, use _("foo {0} bar", _("baz"))
* Do not double the single quotes in the parameter.
* Use autoboxing to call with ints, longs, floats, etc.
*/
private String _(String s, Object o) {
return Messages.getString(s, o, _context);
}
}

View File

@@ -74,10 +74,20 @@ public class NewsFetcher implements Runnable, EepGet.StatusListener {
public String unsignedUpdateVersion() { return _unsignedUpdateVersion; }
public String status() {
StringBuilder buf = new StringBuilder(128);
long now = _context.clock().now();
return
(_lastUpdated > 0 ? "News last updated " + DataHelper.formatDuration(now - _lastUpdated) + " ago" : "") +
(_lastFetch > _lastUpdated ? ", last checked " + DataHelper.formatDuration(now - _lastFetch) + " ago" : "");
if (_lastUpdated > 0) {
buf.append(Messages.getString("News last updated {0} ago.",
DataHelper.formatDuration(now - _lastUpdated),
_context))
.append('\n');
}
if (_lastFetch > _lastUpdated) {
buf.append(Messages.getString("News last checked {0} ago.",
DataHelper.formatDuration(now - _lastFetch),
_context));
}
return buf.toString();
}
public void run() {

View File

@@ -25,7 +25,8 @@ public class PeerHelper extends HelperBase {
public String getPeerSummary() {
try {
_context.commSystem().renderStatusHTML(_out, _urlBase, _sortFlags);
_context.bandwidthLimiter().renderStatusHTML(_out);
// boring and not worth translating
//_context.bandwidthLimiter().renderStatusHTML(_out);
} catch (IOException ioe) {
ioe.printStackTrace();
}

View File

@@ -32,7 +32,7 @@ class ProfileOrganizerRenderer {
_organizer = organizer;
_comparator = new ProfileComparator();
}
public void renderStatusHTML(Writer out) throws IOException {
public void renderStatusHTML(Writer out, boolean full) throws IOException {
Set peers = _organizer.selectAllPeers();
long now = _context.clock().now();
@@ -40,6 +40,8 @@ class ProfileOrganizerRenderer {
TreeSet order = new TreeSet(_comparator);
TreeSet integratedPeers = new TreeSet(_comparator);
int older = 0;
int standard = 0;
for (Iterator iter = peers.iterator(); iter.hasNext();) {
Hash peer = (Hash)iter.next();
if (_organizer.getUs().equals(peer)) continue;
@@ -51,7 +53,14 @@ class ProfileOrganizerRenderer {
if (info != null && info.getCapabilities().indexOf("f") >= 0)
integratedPeers.add(prof);
}
if (prof.getLastSendSuccessful() <= hideBefore) continue;
if (prof.getLastSendSuccessful() <= hideBefore) {
older++;
continue;
}
if ((!full) && !_organizer.isHighCapacity(peer)) {
standard++;
continue;
}
order.add(prof);
}
@@ -60,20 +69,23 @@ class ProfileOrganizerRenderer {
int integrated = 0;
int failing = 0;
StringBuilder buf = new StringBuilder(16*1024);
buf.append("<h2>Peer Profiles</h2>\n<p>");
buf.append("<h2>").append(_("Peer Profiles")).append("</h2>\n<p>");
buf.append(_("Showing {0} recent profiles.", order.size())).append('\n');
buf.append(_("Hiding {0} older profiles.", peers.size()-order.size()));
buf.append("</p>" +
"<table>" +
"<tr>" +
"<th>").append(_("Peer")).append("</th>" +
"<th>").append(_("Groups (Caps)")).append("</th>" +
"<th>").append(_("Speed")).append("</th>" +
"<th>").append(_("Capacity")).append("</th>" +
"<th>").append(_("Integration")).append("</th>" +
"<th>").append(_("Status")).append("</th>" +
"<th>&nbsp;</th>" +
"</tr>");
if (older > 0)
buf.append(_("Hiding {0} older profiles.", older)).append('\n');
if (standard > 0)
buf.append("<a href=\"/profiles.jsp?f=1\">").append(_("Hiding {0} standard profiles.", standard)).append("</a>\n");
buf.append("</p>");
buf.append("<table>");
buf.append("<tr>");
buf.append("<th>").append(_("Peer")).append("</th>");
buf.append("<th>").append(_("Groups (Caps)")).append("</th>");
buf.append("<th>").append(_("Speed")).append("</th>");
buf.append("<th>").append(_("Capacity")).append("</th>");
buf.append("<th>").append(_("Integration")).append("</th>");
buf.append("<th>").append(_("Status")).append("</th>");
buf.append("<th>&nbsp;</th>");
buf.append("</tr>");
int prevTier = 1;
for (Iterator iter = order.iterator(); iter.hasNext();) {
PeerProfile prof = (PeerProfile)iter.next();
@@ -105,15 +117,18 @@ class ProfileOrganizerRenderer {
buf.append("<tr><td align=\"center\" nowrap>");
buf.append(_context.commSystem().renderPeerHTML(peer));
// debug
//if(prof.getIsExpandedDB())
// buf.append(" ** ");
buf.append("</td><td align=\"center\">");
switch (tier) {
case 1: buf.append("Fast, High Capacity"); break;
case 2: buf.append("High Capacity"); break;
case 3: buf.append("Not Failing"); break;
default: buf.append("Failing"); break;
case 1: buf.append(_("Fast, High Capacity")); break;
case 2: buf.append(_("High Capacity")); break;
case 3: buf.append(_("Standard")); break;
default: buf.append(_("Failing")); break;
}
if (isIntegrated) buf.append(", Integrated");
if (isIntegrated) buf.append(", ").append(_("Integrated"));
RouterInfo info = _context.netDb().lookupRouterInfoLocally(peer);
if (info != null) {
// prevent HTML injection in the caps and version
@@ -144,19 +159,20 @@ class ProfileOrganizerRenderer {
}
buf.append("</td><td align=\"right\">").append(num(prof.getIntegrationValue()));
buf.append("</td><td align=\"center\">");
if (_context.shitlist().isShitlisted(peer)) buf.append("Banned");
if (prof.getIsFailing()) buf.append(" Failing");
if (_context.commSystem().wasUnreachable(peer)) buf.append(" Unreachable");
if (_context.shitlist().isShitlisted(peer)) buf.append(_("Banned"));
if (prof.getIsFailing()) buf.append(' ').append(_("Failing"));
if (_context.commSystem().wasUnreachable(peer)) buf.append(' ').append(_("Unreachable"));
Rate failed = prof.getTunnelHistory().getFailedRate().getRate(30*60*1000);
long fails = failed.getCurrentEventCount() + failed.getLastEventCount();
if (fails > 0) {
Rate accepted = prof.getTunnelCreateResponseTime().getRate(30*60*1000);
long total = fails + accepted.getCurrentEventCount() + accepted.getLastEventCount();
if (total / fails <= 10) // hide if < 10%
buf.append(' ').append(fails).append('/').append(total).append(" Test Fails");
buf.append(' ').append(fails).append('/').append(total).append(' ').append(_("Test Fails"));
}
buf.append("&nbsp;</td>");
buf.append("<td nowrap align=\"center\"><a target=\"_blank\" href=\"dumpprofile.jsp?peer=").append(peer.toBase64().substring(0,6)).append("\">profile</a>");
buf.append("<td nowrap align=\"center\"><a target=\"_blank\" href=\"dumpprofile.jsp?peer=")
.append(peer.toBase64().substring(0,6)).append("\">").append(_("profile")).append("</a>");
buf.append("&nbsp;<a href=\"configpeer.jsp?peer=").append(peer.toBase64()).append("\">+-</a></td>\n");
buf.append("</tr>");
// let's not build the whole page in memory (~500 bytes per peer)
@@ -165,30 +181,26 @@ class ProfileOrganizerRenderer {
}
buf.append("</table>");
buf.append("<h2>Floodfill and Integrated Peers</h2>\n" +
"<table>" +
"<tr>" +
"<th class=\"smallhead\">Peer</th>" +
"<th class=\"smallhead\">Caps</th>" +
"<th class=\"smallhead\">Integ. Value</th>" +
"<th class=\"smallhead\">Last Heard About</th>" +
"<th class=\"smallhead\">Last Heard From</th>" +
// "<th class=\"smallhead\">Last Successful Send</th>" +
"<th class=\"smallhead\">Last Good Send</th>" +
// "<th class=\"smallhead\">Last Failed Send</th>" +
"<th class=\"smallhead\">Last Bad Send</th>" +
"<th class=\"smallhead\">10m Resp. Time</th>" +
"<th class=\"smallhead\">1h Resp. Time</th>" +
"<th class=\"smallhead\">1d Resp. Time</th>" +
// "<th class=\"smallhead\">Successful Lookups</th>" +
"<th class=\"smallhead\">Good Lookups</th>" +
// "<th>Failed Lookups</th>" +
"<th class=\"smallhead\">Bad Lookups</th>" +
"<th class=\"smallhead\">New Stores</th>" +
"<th class=\"smallhead\">Old Stores</th>" +
"<th class=\"smallhead\">1h Fail Rate</th>" +
"<th class=\"smallhead\">1d Fail Rate</th>" +
"</tr>");
buf.append("<h2><a name=\"flood\"></a>").append(_("Floodfill and Integrated Peers")).append("</h2>\n");
buf.append("<table>");
buf.append("<tr>");
buf.append("<th class=\"smallhead\">").append(_("Peer")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("Caps")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("Integ. Value")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("Last Heard About")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("Last Heard From")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("Last Good Send")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("Last Bad Send")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("10m Resp. Time")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("1h Resp. Time")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("1d Resp. Time")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("Last Good Lookup")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("Last Bad Lookup")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("Last Good Store")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("Last Bad Store")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("1h Fail Rate")).append("</th>");
buf.append("<th class=\"smallhead\">").append(_("1d Fail Rate")).append("</th>");
buf.append("</tr>");
for (Iterator iter = integratedPeers.iterator(); iter.hasNext();) {
PeerProfile prof = (PeerProfile)iter.next();
Hash peer = prof.getPeer();
@@ -217,28 +229,39 @@ class ProfileOrganizerRenderer {
buf.append("<td align=\"right\">").append(avg(prof, 24*60*60*1000l)).append("</td>");
DBHistory dbh = prof.getDBHistory();
if (dbh != null) {
buf.append("<td align=\"right\">").append(dbh.getSuccessfulLookups()).append("</td>");
buf.append("<td align=\"right\">").append(dbh.getFailedLookups()).append("</td>");
buf.append("<td align=\"right\">").append(dbh.getUnpromptedDbStoreNew()).append("</td>");
buf.append("<td align=\"right\">").append(dbh.getUnpromptedDbStoreOld()).append("</td>");
time = now - dbh.getLastLookupSuccessful();
buf.append("<td align=\"right\">").append(DataHelper.formatDuration(time)).append("</td>");
time = now - dbh.getLastLookupFailed();
buf.append("<td align=\"right\">").append(DataHelper.formatDuration(time)).append("</td>");
time = now - dbh.getLastStoreSuccessful();
buf.append("<td align=\"right\">").append(DataHelper.formatDuration(time)).append("</td>");
time = now - dbh.getLastStoreFailed();
buf.append("<td align=\"right\">").append(DataHelper.formatDuration(time)).append("</td>");
buf.append("<td align=\"right\">").append(davg(dbh, 60*60*1000l)).append("</td>");
buf.append("<td align=\"right\">").append(davg(dbh, 24*60*60*1000l)).append("</td>");
} else {
for (int i = 0; i < 6; i++)
buf.append("<td align=\"right\">").append(_(NA));
}
buf.append("</tr>\n");
}
buf.append("</table>");
buf.append("<h3>Thresholds:</h3>");
buf.append("<b>Speed:</b> ").append(num(_organizer.getSpeedThreshold())).append(" (").append(fast).append(" fast peers)<br>");
buf.append("<b>Capacity:</b> ").append(num(_organizer.getCapacityThreshold())).append(" (").append(reliable).append(" high capacity peers)<br>");
buf.append("<b>Integration:</b> ").append(num(_organizer.getIntegrationThreshold())).append(" (").append(integrated).append(" well integrated peers)");
buf.append("<h3>Definitions:</h3><ul>" +
"<li><b>groups</b>: as determined by the profile organizer</li>" +
"<li><b>caps</b>: capabilities in the netDb, not used to determine profiles</li>" +
"<li><b>speed</b>: peak throughput (bytes per second) over a 1 minute period that the peer has sustained in a single tunnel</li>" +
"<li><b>capacity</b>: how many tunnels can we ask them to join in an hour?</li>" +
"<li><b>integration</b>: how many new peers have they told us about lately?</li>" +
"<li><b>status</b>: is the peer banned, or unreachable, or failing tunnel tests?</li>" +
"</ul></i>");
buf.append("<h3>").append(_("Thresholds")).append("</h3>");
buf.append("<p><b>").append(_("Speed")).append(":</b> ").append(num(_organizer.getSpeedThreshold()))
.append(" (").append(fast).append(' ').append(_("fast peers")).append(")<br>");
buf.append("<b>").append(_("Capacity")).append(":</b> ").append(num(_organizer.getCapacityThreshold()))
.append(" (").append(reliable).append(' ').append(_("high capacity peers")).append(")<br>");
buf.append("<b>").append(_("Integration")).append(":</b> ").append(num(_organizer.getIntegrationThreshold()))
.append(" (").append(integrated).append(' ').append(_(" well integrated peers")).append(")</p>");
buf.append("<h3>").append(_("Definitions")).append("</h3><ul>");
buf.append("<li><b>").append(_("groups")).append("</b>: ").append(_("as determined by the profile organizer")).append("</li>");
buf.append("<li><b>").append(_("caps")).append("</b>: ").append(_("capabilities in the netDb, not used to determine profiles")).append("</li>");
buf.append("<li><b>").append(_("speed")).append("</b>: ").append(_("peak throughput (bytes per second) over a 1 minute period that the peer has sustained in a single tunnel")).append("</li>");
buf.append("<li><b>").append(_("capacity")).append("</b>: ").append(_("how many tunnels can we ask them to join in an hour?")).append("</li>");
buf.append("<li><b>").append(_("integration")).append("</b>: ").append(_("how many new peers have they told us about lately?")).append("</li>");
buf.append("<li><b>").append(_("status")).append("</b>: ").append(_("is the peer banned, or unreachable, or failing tunnel tests?")).append("</li>");
buf.append("</ul></i>");
out.write(buf.toString());
out.flush();
}
@@ -295,31 +318,34 @@ class ProfileOrganizerRenderer {
private final static DecimalFormat _fmt = new DecimalFormat("###,##0.00");
private final static String num(double num) { synchronized (_fmt) { return _fmt.format(num); } }
private final static String na = "n/a";
private final static String NA = HelperBase._x("n/a");
private static String avg (PeerProfile prof, long rate) {
private String avg (PeerProfile prof, long rate) {
RateStat rs = prof.getDbResponseTime();
if (rs == null)
return na;
return _(NA);
Rate r = rs.getRate(rate);
if (r == null)
return na;
return _(NA);
long c = r.getCurrentEventCount() + r.getLastEventCount();
if (c == 0)
return na;
return _(NA);
double d = r.getCurrentTotalValue() + r.getLastTotalValue();
return Math.round(d/c) + "ms";
}
private static String davg (DBHistory dbh, long rate) {
private String davg (DBHistory dbh, long rate) {
RateStat rs = dbh.getFailedLookupRate();
if (rs == null)
return na;
return "0%";
Rate r = rs.getRate(rate);
if (r == null)
return na;
return "0%";
long c = r.getCurrentEventCount() + r.getLastEventCount();
return "" + c;
if (c <= 0)
return "0%";
double avg = 0.5 + 100 * (r.getCurrentTotalValue() + r.getLastTotalValue()) / c;
return ((int) avg) + "%";
}
/** translate a string */
@@ -339,7 +365,7 @@ class ProfileOrganizerRenderer {
* Do not double the single quotes in the parameter.
* Use autoboxing to call with ints, longs, floats, etc.
*/
public String _(String s, Object o) {
private String _(String s, Object o) {
return Messages.getString(s, o, _context);
}
}

View File

@@ -4,13 +4,19 @@ import java.io.IOException;
public class ProfilesHelper extends HelperBase {
private boolean _full;
public ProfilesHelper() {}
public void setFull(String f) {
_full = f != null;
}
/** @return empty string, writes directly to _out */
public String getProfileSummary() {
try {
ProfileOrganizerRenderer rend = new ProfileOrganizerRenderer(_context.profileOrganizer(), _context);
rend.renderStatusHTML(_out);
rend.renderStatusHTML(_out, _full);
} catch (IOException ioe) {
ioe.printStackTrace();
}
@@ -20,7 +26,8 @@ public class ProfilesHelper extends HelperBase {
/** @return empty string, writes directly to _out */
public String getShitlistSummary() {
try {
_context.shitlist().renderStatusHTML(_out);
ShitlistRenderer rend = new ShitlistRenderer(_context);
rend.renderStatusHTML(_out);
} catch (IOException ioe) {
ioe.printStackTrace();
}

View File

@@ -0,0 +1,99 @@
package net.i2p.router.web;
/*
* free (adj.): unencumbered; not under the control of others
* Written by jrandom in 2003 and released into the public domain
* with no warranty of any kind, either expressed or implied.
* It probably won't make your computer catch on fire, or eat
* your children, but it might. Use at your own risk.
*
*/
import java.io.IOException;
import java.io.Writer;
import java.util.Comparator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import net.i2p.data.DataHelper;
import net.i2p.data.Hash;
import net.i2p.router.RouterContext;
import net.i2p.router.Shitlist;
/**
* Moved from Shitlist.java
*/
public class ShitlistRenderer {
private RouterContext _context;
public ShitlistRenderer(RouterContext context) {
_context = context;
}
private static class HashComparator implements Comparator {
public int compare(Object l, Object r) {
return ((Hash)l).toBase64().compareTo(((Hash)r).toBase64());
}
}
public void renderStatusHTML(Writer out) throws IOException {
StringBuilder buf = new StringBuilder(1024);
// move to the jsp
//buf.append("<h2>Banned Peers</h2>");
Map<Hash, Shitlist.Entry> entries = new TreeMap(new HashComparator());
entries.putAll(_context.shitlist().getEntries());
buf.append("<ul>");
for (Map.Entry<Hash, Shitlist.Entry> e : entries.entrySet()) {
Hash key = e.getKey();
Shitlist.Entry entry = e.getValue();
buf.append("<li>").append(_context.commSystem().renderPeerHTML(key));
buf.append(' ');
long expires = entry.expireOn-_context.clock().now();
String expireString = DataHelper.formatDuration(expires);
if (expires < 5l*24*60*60*1000)
buf.append(_("Temporary ban expiring in {0}", expireString));
else
buf.append(_("Banned until restart or in {0}", expireString));
Set transports = entry.transports;
if ( (transports != null) && (transports.size() > 0) )
buf.append(" on the following transport: ").append(transports);
if (entry.cause != null) {
buf.append("<br>\n");
if (entry.causeCode != null)
buf.append(_(entry.cause, entry.causeCode));
else
buf.append(_(entry.cause));
}
buf.append(" (<a href=\"configpeer.jsp?peer=").append(key.toBase64())
.append("#unsh\">").append(_("unban now")).append("</a>)");
buf.append("</li>\n");
}
buf.append("</ul>\n");
out.write(buf.toString());
out.flush();
}
/** translate a string */
private String _(String s) {
return Messages.getString(s, _context);
}
/**
* translate a string with a parameter
* This is a lot more expensive than _(s), so use sparingly.
*
* @param s string to be translated containing {0}
* The {0} will be replaced by the parameter.
* Single quotes must be doubled, i.e. ' -> '' in the string.
* @param o parameter, not translated.
* To tranlslate parameter also, use _("foo {0} bar", _("baz"))
* Do not double the single quotes in the parameter.
* Use autoboxing to call with ints, longs, floats, etc.
*/
private String _(String s, Object o) {
return Messages.getString(s, o, _context);
}
}

View File

@@ -29,7 +29,7 @@ public class StatsGenerator {
public void generateStatsPage(Writer out) throws IOException {
StringBuilder buf = new StringBuilder(16*1024);
buf.append("<div class=\"joblog\"><form action=\"/oldstats.jsp\">");
buf.append("<div class=\"joblog\"><form action=\"/stats.jsp\">");
buf.append("<select name=\"go\" onChange='location.href=this.value'>");
out.write(buf.toString());
buf.setLength(0);
@@ -39,11 +39,11 @@ public class StatsGenerator {
Map.Entry entry = (Map.Entry)iter.next();
String group = (String)entry.getKey();
Set stats = (Set)entry.getValue();
buf.append("<option value=\"/oldstats.jsp#").append(group).append("\">");
buf.append("<option value=\"/stats.jsp#").append(group).append("\">");
buf.append(group).append("</option>\n");
for (Iterator statIter = stats.iterator(); statIter.hasNext(); ) {
String stat = (String)statIter.next();
buf.append("<option value=\"/oldstats.jsp#");
buf.append("<option value=\"/stats.jsp#");
buf.append(stat);
buf.append("\">...");
buf.append(stat);
@@ -55,10 +55,10 @@ public class StatsGenerator {
buf.append("</select> <input type=\"submit\" value=\"GO\" />");
buf.append("</form>");
buf.append("Statistics gathered during this router's uptime (");
buf.append(_("Statistics gathered during this router's uptime")).append(" (");
long uptime = _context.router().getUptime();
buf.append(DataHelper.formatDuration(uptime));
buf.append("). The data gathered is quantized over a 1 minute period, so should just be used as an estimate<p />");
buf.append("). ").append( _("The data gathered is quantized over a 1 minute period, so should just be used as an estimate."));
out.write(buf.toString());
buf.setLength(0);
@@ -138,7 +138,7 @@ public class StatsGenerator {
buf.append("</i><br>");
}
if (rate.getLifetimeEventCount() <= 0) {
buf.append("No lifetime events<br>&nbsp;<br>");
buf.append("No lifetime events<br>");
return;
}
long now = _context.clock().now();

View File

@@ -37,7 +37,7 @@ public class SummaryBarRenderer {
buf.append(linkhelper.getContent());
} else {
buf.append("<h3><a href=\"/configclients.jsp\" target=\"_top\" title=\"")
.append("Configure startup of clients and webapps (services); manually start dormant services")
.append(_("Configure startup of clients and webapps (services); manually start dormant services"))
.append("\">")
.append(_("I2P Services"))
.append("</a></h3>\n" +
@@ -118,7 +118,7 @@ public class SummaryBarRenderer {
.append(_("Graphs"))
.append("</a>\n" +
"<a href=\"oldstats.jsp\" target=\"_top\" title=\"")
"<a href=\"stats.jsp\" target=\"_top\" title=\"")
.append(_("Textual router performance statistics"))
.append("\">")
.append(_("Stats"))
@@ -143,7 +143,7 @@ public class SummaryBarRenderer {
.append(_("never reveal it to anyone"))
.append("\" href=\"netdb.jsp?r=.\" target=\"_top\">")
.append(_("Local Identity"))
.append("<a></h4><hr>\n" +
.append("</a></h4><hr>\n" +
"<table><tr><td align=\"left\">" +
"<b>")
@@ -287,9 +287,9 @@ public class SummaryBarRenderer {
if (prev != null) System.setProperty("net.i2p.router.web.ReseedHandler.noncePrev", prev);
System.setProperty("net.i2p.router.web.ReseedHandler.nonce", nonce+"");
String uri = _helper.getRequestURI();
buf.append("<form action=\"").append(uri).append("\" method=\"GET\">\n");
buf.append("<p><form action=\"").append(uri).append("\" method=\"GET\">\n");
buf.append("<input type=\"hidden\" name=\"reseedNonce\" value=\"").append(nonce).append("\" >\n");
buf.append("<button type=\"submit\" >Reseed</button></form>\n");
buf.append("<button type=\"submit\" value=\"Reseed\" >").append(_("Reseed")).append("</button></form></p>\n");
}
anotherLine = true;
}
@@ -401,7 +401,7 @@ public class SummaryBarRenderer {
.append("</td></tr>\n" +
"</table><hr><h4>")
.append(_helper.getTunnelStatus())
.append(_(_helper.getTunnelStatus()))
.append("</h4><hr>\n")
.append(_helper.getDestinations());

View File

@@ -70,7 +70,7 @@ public class SummaryHelper extends HelperBase {
long diff = Math.abs(ms);
if (diff < 3000)
return "";
return " (" + DataHelper.formatDuration(diff) + " skew)";
return " (" + DataHelper.formatDuration(diff) + " " + _("skew") + ")";
}
public boolean allowReseed() {
@@ -89,42 +89,42 @@ public class SummaryHelper extends HelperBase {
private String reachability() {
if (_context.router().getUptime() > 60*1000 && (!_context.router().gracefulShutdownInProgress()) &&
!_context.clientManager().isAlive())
return "ERR-Client Manager I2CP Error - check logs"; // not a router problem but the user should know
return _("ERR-Client Manager I2CP Error - check logs"); // not a router problem but the user should know
if (!_context.clock().getUpdatedSuccessfully())
return "ERR-ClockSkew";
return _("ERR-ClockSkew");
if (_context.router().isHidden())
return "Hidden";
return _("Hidden");
int status = _context.commSystem().getReachabilityStatus();
switch (status) {
case CommSystemFacade.STATUS_OK:
RouterAddress ra = _context.router().getRouterInfo().getTargetAddress("NTCP");
if (ra == null || (new NTCPAddress(ra)).isPubliclyRoutable())
return "OK";
return "ERR-Private TCP Address";
return _("OK");
return _("ERR-Private TCP Address");
case CommSystemFacade.STATUS_DIFFERENT:
return "ERR-SymmetricNAT";
return _("ERR-SymmetricNAT");
case CommSystemFacade.STATUS_REJECT_UNSOLICITED:
if (_context.router().getRouterInfo().getTargetAddress("NTCP") != null)
return "WARN-Firewalled with Inbound TCP Enabled";
return _("WARN-Firewalled with Inbound TCP Enabled");
if (((FloodfillNetworkDatabaseFacade)_context.netDb()).floodfillEnabled())
return "WARN-Firewalled and Floodfill";
return _("WARN-Firewalled and Floodfill");
if (_context.router().getRouterInfo().getCapabilities().indexOf('O') >= 0)
return "WARN-Firewalled and Fast";
return "Firewalled";
return _("WARN-Firewalled and Fast");
return _("Firewalled");
case CommSystemFacade.STATUS_HOSED:
return "ERR-UDP Port In Use - Set i2np.udp.internalPort=xxxx in advanced config and restart";
return _("ERR-UDP Port In Use - Set i2np.udp.internalPort=xxxx in advanced config and restart");
case CommSystemFacade.STATUS_UNKNOWN: // fallthrough
default:
ra = _context.router().getRouterInfo().getTargetAddress("SSU");
if (ra == null && _context.router().getUptime() > 5*60*1000) {
if (_context.getProperty(ConfigNetHelper.PROP_I2NP_NTCP_HOSTNAME) == null ||
_context.getProperty(ConfigNetHelper.PROP_I2NP_NTCP_PORT) == null)
return "ERR-UDP Disabled and Inbound TCP host/port not set";
return _("ERR-UDP Disabled and Inbound TCP host/port not set");
else
return "WARN-Firewalled with UDP Disabled";
return _("WARN-Firewalled with UDP Disabled");
}
return "Testing";
return _("Testing");
}
}
@@ -357,7 +357,7 @@ public class SummaryHelper extends HelperBase {
Collections.sort(clients, new AlphaComparator());
StringBuilder buf = new StringBuilder(512);
buf.append("<h3><a href=\"i2ptunnel/index.jsp\" target=\"_blank\" title=\"Add/remove/edit &amp; control your client and server tunnels (local destinations).\" title=\"View existing tunnels and tunnel build status.\">Local destinations</a></h3><hr><table>");
buf.append("<h3><a href=\"i2ptunnel/index.jsp\" target=\"_blank\" title=\"").append(_("Add/remove/edit &amp; control your client and server tunnels")).append("\">").append(_("Local Destinations")).append("</a></h3><hr><div class=\"tunnels\"><table>");
for (Iterator iter = clients.iterator(); iter.hasNext(); ) {
Destination client = (Destination)iter.next();
@@ -366,11 +366,11 @@ public class SummaryHelper extends HelperBase {
buf.append("<tr><td align=\"right\"><img src=\"/themes/console/images/");
if (_context.clientManager().shouldPublishLeaseSet(h))
buf.append("server.png\" alt=\"Server\" title=\"Server\">");
buf.append("server.png\" alt=\"Server\" title=\"" + _("Server") + "\">");
else
buf.append("client.png\" alt=\"Client\" title=\"Client\">");
buf.append("client.png\" alt=\"Client\" title=\"" + _("Client") + "\">");
buf.append("</td><td align=\"left\"><b><a href=\"tunnels.jsp#").append(h.toBase64().substring(0,4));
buf.append("\" target=\"_top\" title=\"Show tunnels\">");
buf.append("\" target=\"_top\" title=\"" + _("Show tunnels") + "\">");
if (name.length() < 16)
buf.append(name);
else
@@ -381,33 +381,36 @@ public class SummaryHelper extends HelperBase {
long timeToExpire = ls.getEarliestLeaseDate() - _context.clock().now();
if (timeToExpire < 0) {
// red or yellow light
buf.append("<td><img src=\"/themes/console/images/local_inprogress.png\" alt=\"Rebuilding&hellip;\" title=\"Leases expired ").append(DataHelper.formatDuration(0-timeToExpire));
buf.append(" ago. Rebuilding&hellip;\"></td></tr>\n");
buf.append("<td><img src=\"/themes/console/images/local_inprogress.png\" alt=\"").append(_("Rebuilding")).append("&hellip;\" title=\"").append(_("Leases expired")).append(" ").append(DataHelper.formatDuration(0-timeToExpire));
buf.append(" ").append(_("ago")).append(". ").append(_("Rebuilding")).append("&hellip;\"></td></tr>\n");
} else {
// green light
buf.append("<td><img src=\"/themes/console/images/local_up.png\" alt=\"Ready\" title=\"Ready\"></td></tr>\n");
buf.append("<td><img src=\"/themes/console/images/local_up.png\" alt=\"Ready\" title=\"").append(_("Ready")).append("\"></td></tr>\n");
}
} else {
// yellow light
buf.append("<td><img src=\"/themes/console/images/local_inprogress.png\" alt=\"Building&hellip;\" title=\"Tunnel building in progress&hellip;\"></td></tr>\n");
buf.append("<td><img src=\"/themes/console/images/local_inprogress.png\" alt=\"").append(_("Building")).append("&hellip;\" title=\"").append(_("Building tunnels")).append("&hellip;\"></td></tr>\n");
}
}
buf.append("</table><hr>\n");
buf.append("</table></div><hr>\n");
return buf.toString();
}
/** compare translated nicknames - put "shared clients" first in the sort */
private class AlphaComparator implements Comparator {
public int compare(Object lhs, Object rhs) {
String lname = getName((Destination)lhs);
String rname = getName((Destination)rhs);
if (lname.equals("shared clients"))
String xsc = _("shared clients");
if (lname.equals(xsc))
return -1;
if (rname.equals("shared clients"))
if (rname.equals(xsc))
return 1;
return Collator.getInstance().compare(lname, rname);
}
}
/** translate here so collation works above */
private String getName(Destination d) {
TunnelPoolSettings in = _context.tunnelManager().getInboundSettings(d.calculateHash());
String name = (in != null ? in.getDestinationNickname() : null);
@@ -416,6 +419,10 @@ public class SummaryHelper extends HelperBase {
name = (out != null ? out.getDestinationNickname() : null);
if (name == null)
name = d.calculateHash().toBase64().substring(0,6);
else
name = _(name);
} else {
name = _(name);
}
return name;
}

View File

@@ -37,7 +37,7 @@ public class TunnelRenderer {
}
public void renderStatusHTML(Writer out) throws IOException {
out.write("<div class=\"wideload\"><h2><a name=\"exploratory\" ></a>Exploratory tunnels (<a href=\"/configtunnels.jsp#exploratory\">config</a>):</h2>\n");
out.write("<div class=\"wideload\"><h2><a name=\"exploratory\" ></a>" + _("Exploratory tunnels") + " (<a href=\"/configtunnels.jsp#exploratory\">" + _("configure") + "</a>)</h2>\n");
renderPool(out, _context.tunnelManager().getInboundExploratoryPool(), _context.tunnelManager().getOutboundExploratoryPool());
List<Hash> destinations = null;
@@ -50,26 +50,27 @@ public class TunnelRenderer {
TunnelPool outPool = null;
in = clientInboundPools.get(client);
outPool = clientOutboundPools.get(client);
// TODO the following code is duplicated in SummaryHelper
String name = (in != null ? in.getSettings().getDestinationNickname() : null);
if ( (name == null) && (outPool != null) )
name = outPool.getSettings().getDestinationNickname();
if (name == null)
name = client.toBase64().substring(0,4);
out.write("<h2><a name=\"" + client.toBase64().substring(0,4)
+ "\" ></a>Client tunnels for " + name);
+ "\" ></a>" + _("Client tunnels for") + ' ' + _(name));
if (_context.clientManager().isLocal(client))
out.write(" (<a href=\"/configtunnels.jsp#" + client.toBase64().substring(0,4) +"\">config</a>):</h2>\n");
out.write(" (<a href=\"/configtunnels.jsp#" + client.toBase64().substring(0,4) +"\">" + _("configure") + "</a>)</h2>\n");
else
out.write(" (dead):</h2>\n");
out.write(" (" + _("dead") + ")</h2>\n");
renderPool(out, in, outPool);
}
List participating = _context.tunnelDispatcher().listParticipatingTunnels();
Collections.sort(participating, new TunnelComparator());
out.write("<h2><a name=\"participating\"></a>Participating tunnels:</h2><table>\n");
out.write("<tr><th>Receive on</th><th>From</th><th>"
+ "Send on</th><th>To</th><th>Expiration</th>"
+ "<th>Usage</th><th>Rate</th><th>Role</th></tr>\n");
out.write("<h2><a name=\"participating\"></a>" + _("Participating tunnels") + "</h2><table>\n");
out.write("<tr><th>" + _("Receive on") + "</th><th>" + _("From") + "</th><th>"
+ _("Send on") + "</th><th>" + _("To") + "</th><th>" + _("Expiration") + "</th>"
+ "<th>" + _("Usage") + "</th><th>" + _("Rate") + "</th><th>" + _("Role") + "</th></tr>\n");
long processed = 0;
RateStat rs = _context.statManager().getRate("tunnel.participatingMessageCount");
if (rs != null)
@@ -103,7 +104,7 @@ public class TunnelRenderer {
if (timeLeft > 0)
out.write(" <td class=\"cells\" align=\"center\">" + DataHelper.formatDuration(timeLeft) + "</td>");
else
out.write(" <td class=\"cells\" align=\"center\">(grace period)</td>");
out.write(" <td class=\"cells\" align=\"center\">(" + _("grace period") + ")</td>");
out.write(" <td class=\"cells\" align=\"center\">" + cfg.getProcessedMessagesCount() + "KB</td>");
int lifetime = (int) ((_context.clock().now() - cfg.getCreation()) / 1000);
if (lifetime <= 0)
@@ -113,17 +114,17 @@ public class TunnelRenderer {
int bps = 1024 * (int) cfg.getProcessedMessagesCount() / lifetime;
out.write(" <td class=\"cells\" align=\"center\">" + bps + "Bps</td>");
if (cfg.getSendTo() == null)
out.write(" <td class=\"cells\" align=\"center\">Outbound Endpoint</td>");
out.write(" <td class=\"cells\" align=\"center\">" + _("Outbound Endpoint") + "</td>");
else if (cfg.getReceiveFrom() == null)
out.write(" <td class=\"cells\" align=\"center\">Inbound Gateway</td>");
out.write(" <td class=\"cells\" align=\"center\">" + _("Inbound Gateway") + "</td>");
else
out.write(" <td class=\"cells\" align=\"center\">Participant</td>");
out.write(" <td class=\"cells\" align=\"center\">" + _("Participant") + "</td>");
out.write("</tr>\n");
processed += cfg.getProcessedMessagesCount();
}
out.write("</table>\n");
out.write("<div class=\"statusnotes\"><b>Inactive participating tunnels: " + inactive + "</b></div>\n");
out.write("<div class=\"statusnotes\"><b>Lifetime bandwidth usage: " + DataHelper.formatSize(processed*1024) + "B</b></div>\n");
out.write("<div class=\"statusnotes\"><b>" + _("Inactive participating tunnels") + ": " + inactive + "</b></div>\n");
out.write("<div class=\"statusnotes\"><b>" + _("Lifetime bandwidth usage") + ": " + DataHelper.formatSize(processed*1024) + "B</b></div>\n");
renderPeers(out);
}
@@ -152,16 +153,16 @@ public class TunnelRenderer {
if (info.getLength() > maxLength)
maxLength = info.getLength();
}
out.write("<table><tr><th>In/Out</th><th>Expiry</th><th>Usage</th><th>Gateway</th>");
out.write("<table><tr><th>" + _("In/Out") + "</th><th>" + _("Expiry") + "</th><th>" + _("Usage") + "</th><th>" + _("Gateway") + "</th>");
if (maxLength > 3) {
out.write("<th align=\"center\" colspan=\"" + (maxLength - 2));
out.write("\">Participants</th>");
out.write("\">" + _("Participants") + "</th>");
}
else if (maxLength == 3) {
out.write("<th>Participant</th>");
out.write("<th>" + _("Participant") + "</th>");
}
if (maxLength > 1) {
out.write("<th>Endpoint</th>");
out.write("<th>" + _("Endpoint") + "</th>");
}
out.write("</tr>\n");
for (int i = 0; i < tunnels.size(); i++) {
@@ -201,19 +202,19 @@ public class TunnelRenderer {
if (in != null) {
List pending = in.listPending();
if (pending.size() > 0)
out.write("<div class=\"statusnotes\"><center><b>Build in progress: " + pending.size() + " inbound</b></center></div>\n");
out.write("<div class=\"statusnotes\"><center><b>" + _("Build in progress") + ": " + pending.size() + " " + _("inbound") + "</b></center></div>\n");
live += pending.size();
}
if (outPool != null) {
List pending = outPool.listPending();
if (pending.size() > 0)
out.write("<div class=\"statusnotes\"><center><b>Build in progress: " + pending.size() + " outbound</b></center></div>\n");
out.write("<div class=\"statusnotes\"><center><b>" + _("Build in progress") + ": " + pending.size() + " " + _("outbound") + "</b></center></div>\n");
live += pending.size();
}
if (live <= 0)
out.write("<div class=\"statusnotes\"><center><b>No tunnels; waiting for the grace period to end.</center></b></div>\n");
out.write("<div class=\"statusnotes\"><center><b>Lifetime bandwidth usage: " + DataHelper.formatSize(processedIn*1024) + "B in, " +
DataHelper.formatSize(processedOut*1024) + "B out</b></center></div>");
out.write("<div class=\"statusnotes\"><center><b>" + _("No tunnels; waiting for the grace period to end.") + "</center></b></div>\n");
out.write("<div class=\"statusnotes\"><center><b>" + _("Lifetime bandwidth usage") + ": " + DataHelper.formatSize(processedIn*1024) + "B " + _("in") + ", " +
DataHelper.formatSize(processedOut*1024) + "B " + _("out") + "</b></center></div>");
}
private void renderPeers(Writer out) throws IOException {
@@ -230,8 +231,8 @@ public class TunnelRenderer {
List<Hash> peerList = new ArrayList(peers);
Collections.sort(peerList, new HashComparator());
out.write("<h2><a name=\"peers\"></a>Tunnel Counts By Peer:</h2>\n");
out.write("<table><tr><th>Peer</th><th>Expl. + Client</th><th>% of total</th><th>Part. from + to</th><th>% of total</th></tr>\n");
out.write("<h2><a name=\"peers\"></a>" + _("Tunnel Counts By Peer") + "</h2>\n");
out.write("<table><tr><th>" + _("Peer") + "</th><th>" + _("Expl. + Client") + "</th><th>" + _("% of total") + "</th><th>" + _("Part. from + to") + "</th><th>" + _("% of total") + "</th></tr>\n");
for (Hash h : peerList) {
out.write("<tr> <td class=\"cells\" align=\"center\">");
out.write(netDbLink(h));
@@ -249,7 +250,7 @@ public class TunnelRenderer {
out.write('0');
out.write('\n');
}
out.write("<tr class=\"tablefooter\"> <td align=\"center\"><b>Tunnels</b> <td align=\"center\"><b>" + tunnelCount);
out.write("<tr class=\"tablefooter\"> <td align=\"center\"><b>" + _("Tunnels") + "</b> <td align=\"center\"><b>" + tunnelCount);
out.write("</b> <td>&nbsp;</td> <td align=\"center\"><b>" + partCount);
out.write("</b> <td>&nbsp;</td></tr></table></div>\n");
}

View File

@@ -0,0 +1,56 @@
package dummy;
/**
* Just more strings for xgettext, that don't appear in the source anywhere.
* I'm sure there's easier ways to do this, but this will do for now.
*
* Obviously, do not compile this.
*/
class Dummy {
void dummy {
// wars for ConfigClientsHelper
_("addressbook");
_("i2psnark");
_("i2ptunnel");
_("susimail");
_("susidns");
_("routerconsole");
// clients, taken from clients.config, for ConfigClientsHelper
// note that if the wording changes in clients.config, we have to
// keep the old string here as well for existing installs
_("Web console");
_("SAM application bridge");
_("Application tunnels");
_("My eepsite web server");
_("I2P webserver (eepsite)");
_("Browser launch at startup");
_("BOB application bridge");
_("I2P Router Console");
_("Open Router Console in web browser at startup");
// tunnel nicknames, taken from i2ptunnel.config so they will display
// nicely under 'local destinations' in the summary bar
// note that if the wording changes in i2ptunnel.config, we have to
// keep the old string here as well for existing installs
_("shared clients");
_("IRC proxy");
_("eepsite");
_("I2P webserver");
_("HTTP Proxy");
// older names for pre-0.7.4 installs
_("eepProxy");
_("ircProxy");
// hardcoded in i2psnark
_("I2PSnark");
// hardcoded in iMule?
_("iMule");
// standard themes for ConfigUIHelper
_("classic");
_("dark");
_("light");
_("midnight");
}
}