propagate from branch 'i2p.i2p.zzz.test4' (head 7b50b6c3d48da68078a86a53e55e2c18f55685e8)

to branch 'i2p.i2p' (head ebce577e19b70c281daacc5277f98e9bb2bb9630)
This commit is contained in:
zzz
2011-03-08 13:31:57 +00:00
183 changed files with 30058 additions and 11421 deletions

View File

@ -28,10 +28,13 @@ public class CSSHelper extends HelperBase {
return url;
}
/** change default language for the router but don't save it */
/** change default language for the router AND save it */
public void setLang(String lang) {
if (lang != null && lang.length() > 0)
// Protected with nonce in css.jsi
if (lang != null && lang.length() == 2 && !lang.equals(_context.getProperty(Messages.PROP_LANG))) {
_context.router().setConfigSetting(Messages.PROP_LANG, lang);
_context.router().saveConfig();
}
}
/** needed for conditional css loads for zh */
@ -60,4 +63,13 @@ public class CSSHelper extends HelperBase {
.append("</title>");
return buf.toString();
}
/**
* Should we allow a refreshing IFrame?
* @since 0.8.5
*/
public boolean allowIFrame(String ua) {
return ua == null || !(ua.startsWith("Lynx") || ua.startsWith("w3m") ||
ua.startsWith("ELinks") || ua.startsWith("Dillo"));
}
}

View File

@ -22,7 +22,7 @@ public class ConfigReseedHelper extends HelperBase {
public String modeChecked(int mode) {
boolean required = _context.getBooleanProperty(Reseeder.PROP_SSL_REQUIRED);
boolean disabled = _context.getBooleanProperty(Reseeder.PROP_SSL_DISABLE);
boolean disabled = _context.getBooleanPropertyDefaultTrue(Reseeder.PROP_SSL_DISABLE);
if ((mode == 0 && (!disabled) && (!required)) ||
(mode == 1 && (!disabled) && required) ||
(mode == 2 && disabled))

View File

@ -46,9 +46,10 @@ public class ConfigUIHelper extends HelperBase {
return rv;
}
private static final String langs[] = {"de", "en", "es", "fr", "nl", "pt", "ru", "sv", "zh"};
private static final String flags[] = {"de", "us", "es", "fr", "nl", "pt", "ru", "se", "cn"};
private static final String xlangs[] = {_x("German"), _x("English"), _x("Spanish"),_x("French"),
private static final String langs[] = {"ar", "de", "en", "es", "fr", "nl", "pt", "ru", "sv", "zh"};
private static final String flags[] = {"lang_ar", "de", "us", "es", "fr", "nl", "pt", "ru", "se", "cn"};
private static final String xlangs[] = {_x("Arabic"),
_x("German"), _x("English"), _x("Spanish"),_x("French"),
_x("Dutch"), _x("Portuguese"), _x("Russian"),
_x("Swedish"), _x("Chinese")};

View File

@ -19,19 +19,26 @@ public class ContentHelper extends HelperBase {
_startAtBeginning = Boolean.valueOf(""+moo).booleanValue();
}
public void setLang(String l) {
/*****
if((_lang == null || !_lang.equals(l)) && (l != null)) {
//Set language for router console
_lang = l;
TODO - Temporary for 0.8.4
Needed for desktopgui. But there's no nonce protection.
Move the following to CSSHelper setLang(), or disable completely,
See comments in CSSHelper
if(_context == null) {
setContextId(null);
}
//Set language persistently throughout I2P
_context.router().setConfigSetting(Messages.PROP_LANG, _lang);
_context.router().saveConfig();
_context.setProperty(Messages.PROP_LANG, _lang);
if (_context.getBooleanProperty("desktopgui.enabled")) {
//Set language persistently throughout I2P
_context.router().setConfigSetting(Messages.PROP_LANG, _lang);
_context.router().saveConfig();
_context.setProperty(Messages.PROP_LANG, _lang);
}
}
*****/
}
public void setMaxLines(String lines) {

View File

@ -213,10 +213,15 @@ public class PluginUpdateHandler extends UpdateHandler {
if (up.haveKey(pubkey)) {
// the key is already in the TrustedUpdate keyring
// verify the sig and verify that it is signed by the signer in the plugin.config file
// Allow "" as the previously-known signer
String signingKeyName = up.verifyAndGetSigner(f);
if (!signer.equals(signingKeyName)) {
if (!(signer.equals(signingKeyName) || "".equals(signingKeyName))) {
f.delete();
to.delete();
if (signingKeyName == null)
_log.error("Failed to verify plugin signature, corrupt plugin or bad signature, signed by: " + signer);
else
_log.error("Plugin signer \"" + signer + "\" does not match existing signer in plugin.config file \"" + signingKeyName + "\"");
statusDone("<b>" + _("Plugin signature verification of {0} failed", url) + "</b>");
return;
}
@ -226,6 +231,7 @@ public class PluginUpdateHandler extends UpdateHandler {
// bad or duplicate key
f.delete();
to.delete();
_log.error("Bad key or key mismatch - Failed to add plugin key \"" + pubkey + "\" for plugin signer \"" + signer + "\"");
statusDone("<b>" + _("Plugin signature verification of {0} failed", url) + "</b>");
return;
}
@ -235,6 +241,11 @@ public class PluginUpdateHandler extends UpdateHandler {
if (!signer.equals(signingKeyName)) {
f.delete();
to.delete();
if (signingKeyName == null)
_log.error("Failed to verify plugin signature, corrupt plugin or bad signature, signed by: " + signer);
else
// shouldn't happen
_log.error("Plugin signer \"" + signer + "\" does not match new signer in plugin.config file \"" + signingKeyName + "\"");
statusDone("<b>" + _("Plugin signature verification of {0} failed", url) + "</b>");
return;
}

View File

@ -1,6 +1,7 @@
package net.i2p.router.web;
import java.util.ArrayList;
import java.awt.GraphicsEnvironment;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
@ -10,9 +11,10 @@ import java.util.Properties;
import java.util.StringTokenizer;
import net.i2p.I2PAppContext;
import net.i2p.desktopgui.Main;
import net.i2p.apps.systray.SysTray;
import net.i2p.data.Base32;
import net.i2p.data.DataHelper;
import net.i2p.desktopgui.Main;
import net.i2p.router.RouterContext;
import net.i2p.util.FileUtil;
import net.i2p.util.I2PAppThread;
@ -57,7 +59,6 @@ public class RouterConsoleRunner {
static {
System.setProperty("org.mortbay.http.Version.paranoid", "true");
System.setProperty("java.awt.headless", "true");
}
/**
@ -128,10 +129,34 @@ public class RouterConsoleRunner {
}
public static void main(String args[]) {
startTrayApp();
RouterConsoleRunner runner = new RouterConsoleRunner(args);
runner.startConsole();
}
private static void startTrayApp() {
try {
//TODO: move away from routerconsole into a separate application.
//ApplicationManager?
VersionComparator v = new VersionComparator();
boolean recentJava = v.compare(System.getProperty("java.runtime.version"), "1.6") >= 0;
// default false for now
boolean desktopguiEnabled = I2PAppContext.getGlobalContext().getBooleanProperty("desktopgui.enabled");
if (recentJava && desktopguiEnabled) {
//Check if we are in a headless environment, set properties accordingly
System.setProperty("java.awt.headless", Boolean.toString(GraphicsEnvironment.isHeadless()));
String[] args = new String[0];
net.i2p.desktopgui.Main.beginStartup(args);
} else {
// required true for jrobin to work
System.setProperty("java.awt.headless", "true");
SysTray.getInstance();
}
} catch (Throwable t) {
t.printStackTrace();
}
}
public void startConsole() {
File workDir = new SecureDirectory(I2PAppContext.getGlobalContext().getTempDir(), "jetty-work");
boolean workDirRemoved = FileUtil.rmdir(workDir, false);
@ -316,18 +341,6 @@ public class RouterConsoleRunner {
}
}
try {
//TODO: move away from routerconsole into a separate application.
//ApplicationManager?
VersionComparator v = new VersionComparator();
if(v.compare(System.getProperty("java.runtime.version"), "1.6") >= 0) {
String[] args = new String[0];
net.i2p.desktopgui.Main.beginStartup(args);
}
} catch (Throwable t) {
t.printStackTrace();
}
NewsFetcher fetcher = NewsFetcher.getInstance(I2PAppContext.getGlobalContext());
Thread t = new I2PAppThread(fetcher, "NewsFetcher", true);
t.start();

View File

@ -197,9 +197,10 @@ public class StatsGenerator {
buf.append("; ");
}
buf.append(ngettext((int) curRate.getLastEventCount(), "There was 1 event", "There were {0} events"));
buf.append(' ');
buf.append(_("in this period which ended {0} ago.", DataHelper.formatDuration2(now - curRate.getLastCoalesceDate())));
// breaking the sentence like before makes translation in my language impossible.
buf.append(_("There were {0} event(s) in this period", curRate.getLastEventCount()));
// buf.append(' ');
buf.append(_(" which ended {0} ago.", DataHelper.formatDuration2(now - curRate.getLastCoalesceDate())));
} else {
buf.append(" <i>").append(_("No events")).append("</i> ");
}

View File

@ -224,25 +224,21 @@ public class SummaryBarRenderer {
System.setProperty("net.i2p.router.web.UpdateHandler.noncePrev", prev);
System.setProperty("net.i2p.router.web.UpdateHandler.nonce", nonce+"");
String uri = _helper.getRequestURI();
buf.append("<p><form action=\"").append(uri).append("\" method=\"POST\">\n");
buf.append("<form action=\"").append(uri).append("\" method=\"POST\">\n");
buf.append("<input type=\"hidden\" name=\"updateNonce\" value=\"").append(nonce).append("\" >\n");
if (_helper.updateAvailable()) {
buf.append("<button type=\"submit\" name=\"updateAction\" value=\"signed\" >")
.append(_("Download"))
.append(' ')
.append(_helper.getUpdateVersion())
.append(' ')
.append(_("Update"))
.append("</button>\n");
// Note to translators: parameter is a version, e.g. "0.8.4"
.append(_("Download {0} Update", _helper.getUpdateVersion()))
.append("</button><br>\n");
}
if (_helper.unsignedUpdateAvailable()) {
buf.append("<button type=\"submit\" name=\"updateAction\" value=\"Unsigned\" >")
.append(_("Download Unsigned"))
.append("<br>")
.append(_("Update"))
.append(' ')
.append(_helper.getUnsignedUpdateVersion())
.append("</button>\n");
// Note to translators: parameter is a date and time, e.g. "02-Mar 20:34 UTC"
// <br> is optional, to help the browser make the lines even in the button
// If the translation is shorter than the English, you should probably not include <br>
.append(_("Download Unsigned<br>Update {0}", _helper.getUnsignedUpdateVersion()))
.append("</button><br>\n");
}
buf.append("</form>\n");
}
@ -251,10 +247,9 @@ public class SummaryBarRenderer {
buf.append("<p>")
.append(ConfigRestartBean.renderStatus(_helper.getRequestURI(), _helper.getAction(), _helper.getConsoleNonce()))
buf.append(ConfigRestartBean.renderStatus(_helper.getRequestURI(), _helper.getAction(), _helper.getConsoleNonce()))
.append("</p><hr><h3><a href=\"/peers\" target=\"_top\" title=\"")
.append("<hr><h3><a href=\"/peers\" target=\"_top\" title=\"")
.append(_("Show all current peer connections"))
.append("\">")
.append(_("Peers"))
@ -456,4 +451,9 @@ public class SummaryBarRenderer {
private String _(String s) {
return Messages.getString(s, _context);
}
/** translate a string with a parameter */
private String _(String s, Object o) {
return Messages.getString(s, o, _context);
}
}