propagate from branch 'i2p.i2p.zzz.update' (head 1ca3b931ebecd4ec80e7e135b634d085934c092b)

to branch 'i2p.i2p' (head c917793878189c29441f69133e029cfdfe3c0895)
This commit is contained in:
str4d
2012-11-05 10:38:54 +00:00
255 changed files with 20277 additions and 8880 deletions

View File

@@ -558,10 +558,22 @@ public class ConsoleUpdateManager implements UpdateManager {
* Call once for each type/method pair.
*/
public void register(Updater updater, UpdateType type, UpdateMethod method, int priority) {
// DEBUG slow start for snark updates
// For 0.9.4 update, only for dev builds
// For 0.9.5 update, only for dev builds and 1% more
// Remove this in 0.9.6 or 0.9.7
if (method == TORRENT && RouterVersion.BUILD == 0 && _context.random().nextInt(100) != 0) {
if (_log.shouldLog(Log.WARN))
_log.warn("Ignoring torrent registration");
return;
}
RegisteredUpdater ru = new RegisteredUpdater(updater, type, method, priority);
if (_log.shouldLog(Log.INFO))
_log.info("Registering " + ru);
_registeredUpdaters.add(ru);
if (!_registeredUpdaters.add(ru)) {
if (_log.shouldLog(Log.WARN))
_log.warn("Duplicate registration " + ru);
}
}
public void unregister(Updater updater, UpdateType type, UpdateMethod method) {
@@ -575,7 +587,10 @@ public class ConsoleUpdateManager implements UpdateManager {
RegisteredChecker rc = new RegisteredChecker(updater, type, method, priority);
if (_log.shouldLog(Log.INFO))
_log.info("Registering " + rc);
_registeredCheckers.add(rc);
if (!_registeredCheckers.add(rc)) {
if (_log.shouldLog(Log.WARN))
_log.warn("Duplicate registration " + rc);
}
}
public void unregister(Checker updater, UpdateType type, UpdateMethod method) {

View File

@@ -18,15 +18,15 @@ import java.util.TreeMap;
import net.i2p.data.DataHelper;
import net.i2p.data.Hash;
import net.i2p.router.RouterContext;
import net.i2p.router.Shitlist;
import net.i2p.router.Banlist;
/**
* Moved from Shitlist.java
* Moved from Banlist.java
*/
public class ShitlistRenderer {
public class BanlistRenderer {
private final RouterContext _context;
public ShitlistRenderer(RouterContext context) {
public BanlistRenderer(RouterContext context) {
_context = context;
}
@@ -40,9 +40,9 @@ public class ShitlistRenderer {
StringBuilder buf = new StringBuilder(1024);
// move to the jsp
//buf.append("<h2>Banned Peers</h2>");
Map<Hash, Shitlist.Entry> entries = new TreeMap(new HashComparator());
Map<Hash, Banlist.Entry> entries = new TreeMap(new HashComparator());
entries.putAll(_context.shitlist().getEntries());
entries.putAll(_context.banlist().getEntries());
if (entries.isEmpty()) {
buf.append("<i>").append(_("none")).append("</i>");
out.write(buf.toString());
@@ -51,9 +51,9 @@ public class ShitlistRenderer {
buf.append("<ul>");
for (Map.Entry<Hash, Shitlist.Entry> e : entries.entrySet()) {
for (Map.Entry<Hash, Banlist.Entry> e : entries.entrySet()) {
Hash key = e.getKey();
Shitlist.Entry entry = e.getValue();
Banlist.Entry entry = e.getValue();
long expires = entry.expireOn-_context.clock().now();
if (expires <= 0)
continue;

View File

@@ -23,7 +23,6 @@ import org.mortbay.jetty.handler.ContextHandlerCollection;
* Saves changes to clients.config or webapps.config
*/
public class ConfigClientsHandler extends FormHandler {
private Map _settings;
@Override
protected void processForm() {
@@ -171,8 +170,6 @@ public class ConfigClientsHandler extends FormHandler {
}
public void setSettings(Map settings) { _settings = new HashMap(settings); }
private void saveClientChanges() {
List<ClientAppConfig> clients = ClientAppConfig.getClientApps(_context);
for (int cur = 0; cur < clients.size(); cur++) {
@@ -216,15 +213,8 @@ public class ConfigClientsHandler extends FormHandler {
}
ClientAppConfig.writeClientAppConfig(_context, clients);
addFormNotice(_("Client configuration saved successfully - restart required to take effect."));
}
/** curses Jetty for returning arrays */
private String getJettyString(String key) {
String[] arr = (String[]) _settings.get(key);
if (arr == null)
return null;
return arr[0].trim();
addFormNotice(_("Client configuration saved successfully"));
addFormNotice(_("Restart required to take effect"));
}
// STUB for stopClient, not completed yet.
@@ -248,7 +238,7 @@ public class ConfigClientsHandler extends FormHandler {
return;
}
ClientAppConfig ca = clients.get(i);
LoadClientAppsJob.runClient(ca.className, ca.clientName, LoadClientAppsJob.parseArgs(ca.args), _log);
LoadClientAppsJob.runClient(ca.className, ca.clientName, LoadClientAppsJob.parseArgs(ca.args), _context, _log);
addFormNotice(_("Client") + ' ' + _(ca.clientName) + ' ' + _("started") + '.');
}
@@ -264,7 +254,7 @@ public class ConfigClientsHandler extends FormHandler {
}
private void saveWebAppChanges() {
Properties props = RouterConsoleRunner.webAppProperties();
Properties props = RouterConsoleRunner.webAppProperties(_context);
Set keys = props.keySet();
for (Iterator iter = keys.iterator(); iter.hasNext(); ) {
String name = (String)iter.next();
@@ -275,7 +265,7 @@ public class ConfigClientsHandler extends FormHandler {
if (! RouterConsoleRunner.ROUTERCONSOLE.equals(app))
props.setProperty(name, "" + (val != null));
}
RouterConsoleRunner.storeWebAppProperties(props);
RouterConsoleRunner.storeWebAppProperties(_context, props);
addFormNotice(_("WebApp configuration saved."));
}
@@ -416,11 +406,12 @@ public class ConfigClientsHandler extends FormHandler {
if (intfc != null)
changes.put(ClientManagerFacadeImpl.PROP_CLIENT_HOST, intfc);
String user = getJettyString("user");
if (user != null)
changes.put(ConfigClientsHelper.PROP_USER, user);
String pw = getJettyString("pw");
if (pw != null)
changes.put(ConfigClientsHelper.PROP_PW, pw);
if (user != null && pw != null && user.length() > 0 && pw.length() > 0) {
ConsolePasswordManager mgr = new ConsolePasswordManager(_context);
mgr.saveHash(ConfigClientsHelper.PROP_AUTH, user, pw);
addFormNotice(_("Added user {0}", user));
}
String mode = getJettyString("mode");
boolean disabled = "0".equals(mode);
boolean ssl = "2".equals(mode);
@@ -433,9 +424,10 @@ public class ConfigClientsHandler extends FormHandler {
boolean all = "0.0.0.0".equals(intfc) || "0:0:0:0:0:0:0:0".equals(intfc) ||
"::".equals(intfc);
changes.put(ConfigClientsHelper.BIND_ALL_INTERFACES, Boolean.toString(all));
if (_context.router().saveConfig(changes, null))
addFormNotice(_("Interface configuration saved successfully - restart required to take effect."));
else
if (_context.router().saveConfig(changes, null)) {
addFormNotice(_("Interface configuration saved"));
addFormNotice(_("Restart required to take effect"));
} else
addFormError(_("Error saving the configuration (applied but not saved) - please see the error logs"));
}
}

View File

@@ -24,8 +24,6 @@ public class ConfigClientsHelper extends HelperBase {
public static final String PROP_ENABLE_SSL = "i2cp.SSL";
/** from ClientMessageEventListener */
public static final String PROP_AUTH = "i2cp.auth";
public static final String PROP_USER = "i2cp.username";
public static final String PROP_PW = "i2cp.password";
public ConfigClientsHelper() {}
@@ -35,16 +33,6 @@ public class ConfigClientsHelper extends HelperBase {
Integer.toString(ClientManagerFacadeImpl.DEFAULT_PORT));
}
/** @since 0.8.3 */
public String getUser() {
return _context.getProperty(PROP_USER, "");
}
/** @since 0.8.3 */
public String getPw() {
return _context.getProperty(PROP_PW, "");
}
/** @since 0.8.3 */
public String i2cpModeChecked(int mode) {
boolean disabled = _context.getBooleanProperty(PROP_DISABLE_EXTERNAL);
@@ -128,7 +116,7 @@ public class ConfigClientsHelper extends HelperBase {
StringBuilder buf = new StringBuilder(1024);
buf.append("<table>\n");
buf.append("<tr><th align=\"right\">" + _("WebApp") + "</th><th>" + _("Run at Startup?") + "</th><th>" + _("Control") + "</th><th align=\"left\">" + _("Description") + "</th></tr>\n");
Properties props = RouterConsoleRunner.webAppProperties();
Properties props = RouterConsoleRunner.webAppProperties(_context);
Set<String> keys = new TreeSet(props.keySet());
for (Iterator<String> iter = keys.iterator(); iter.hasNext(); ) {
String name = iter.next();

View File

@@ -1,11 +1,9 @@
package net.i2p.router.web;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.Map;
import net.i2p.data.DataHelper;
@@ -16,8 +14,6 @@ import net.i2p.data.DataHelper;
*/
public class ConfigHomeHandler extends FormHandler {
private Map _settings;
@Override
protected void processForm() {
if (_action == null) return;
@@ -106,14 +102,4 @@ public class ConfigHomeHandler extends FormHandler {
addFormError(_("Unsupported"));
}
}
public void setSettings(Map settings) { _settings = new HashMap(settings); }
/** curses Jetty for returning arrays */
private String getJettyString(String key) {
String[] arr = (String[]) _settings.get(key);
if (arr == null)
return null;
return arr[0].trim();
}
}

View File

@@ -280,9 +280,10 @@ 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"));
else
addFormNotice(_("Disabling UPnP, restart required to take effect"));
addFormNotice(_("Disabling UPnP"));
addFormNotice(_("Restart required to take effect"));
}
changes.put(TransportManager.PROP_ENABLE_UPNP, "" + _upnp);

View File

@@ -20,7 +20,7 @@ public class ConfigPeerHandler extends FormHandler {
} else if (_action.equals(_("Ban peer until restart"))) {
Hash h = getHash();
if (h != null) {
_context.shitlist().shitlistRouterForever(h, _("Manually banned via {0}"), "<a href=\"configpeer\">configpeer</a>");
_context.banlist().banlistRouterForever(h, _("Manually banned via {0}"), "<a href=\"configpeer\">configpeer</a>");
addFormNotice(_("Peer") + " " + _peer + " " + _("banned until restart") );
return;
}
@@ -28,8 +28,8 @@ public class ConfigPeerHandler extends FormHandler {
} else if (_action.equals(_("Unban peer"))) {
Hash h = getHash();
if (h != null) {
if (_context.shitlist().isShitlisted(h)) {
_context.shitlist().unshitlistRouter(h);
if (_context.banlist().isBanlisted(h)) {
_context.banlist().unbanlistRouter(h);
addFormNotice(_("Peer") + " " + _peer + " " + _("unbanned") );
} else
addFormNotice(_("Peer") + " " + _peer + " " + _("is not currently banned") );

View File

@@ -11,7 +11,6 @@ import net.i2p.router.networkdb.reseed.Reseeder;
* @since 0.8.3
*/
public class ConfigReseedHandler extends FormHandler {
private Map _settings;
private final Map<String, String> changes = new HashMap();
private final List<String> removes = new ArrayList();
@@ -34,16 +33,6 @@ public class ConfigReseedHandler extends FormHandler {
}
addFormError(_("Unsupported") + ' ' + _action + '.');
}
public void setSettings(Map settings) { _settings = new HashMap(settings); }
/** curses Jetty for returning arrays */
private String getJettyString(String key) {
String[] arr = (String[]) _settings.get(key);
if (arr == null)
return null;
return arr[0].trim();
}
/** @since 0.8.9 */
private void saveString(String config, String param) {

View File

@@ -8,6 +8,7 @@ import net.i2p.apps.systray.UrlLauncher;
import net.i2p.router.Router;
import net.i2p.router.RouterContext;
import net.i2p.router.startup.ClientAppConfig;
import net.i2p.util.PortMapper;
import net.i2p.util.SystemVersion;
import net.i2p.util.VersionComparator;
@@ -257,7 +258,9 @@ public class ConfigServiceHandler extends FormHandler {
}
// releases <= 0.6.5 deleted the entry completely
if (shouldLaunchBrowser && !found) {
ClientAppConfig ca = new ClientAppConfig(UrlLauncher.class.getName(), "consoleBrowser", "http://127.0.0.1:7657", 5, false);
int port = _context.portMapper().getPort(PortMapper.SVC_CONSOLE, RouterConsoleRunner.DEFAULT_LISTEN_PORT);
ClientAppConfig ca = new ClientAppConfig(UrlLauncher.class.getName(), "consoleBrowser",
"http://127.0.0.1:" + port + '/', 5, false);
clients.add(ca);
}
ClientAppConfig.writeClientAppConfig(_context, clients);

View File

@@ -116,9 +116,10 @@ public class ConfigStatsHandler extends FormHandler {
addFormNotice(_("Stat filter and location updated successfully to") + ": " + stats.toString());
if (fullChanged) {
if (_isFull)
addFormNotice(_("Full statistics enabled - restart required to take effect"));
addFormNotice(_("Full statistics enabled"));
else
addFormNotice(_("Full statistics disabled - restart required to take effect"));
addFormNotice(_("Full statistics disabled"));
addFormNotice(_("Restart required to take effect"));
}
if (graphsChanged)
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

@@ -1,12 +1,16 @@
package net.i2p.router.web;
import java.util.ArrayList;
import java.text.Collator;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.StringTokenizer;
import java.util.TreeMap;
import net.i2p.stat.FrequencyStat;
import net.i2p.stat.Rate;
@@ -17,9 +21,9 @@ import net.i2p.util.Log;
public class ConfigStatsHelper extends HelperBase {
private Log _log;
private String _filter;
private Set _filters;
private Set<String> _filters;
/** list of names of stats which are remaining, ordered by nested groups */
private List _stats;
private List<String> _stats;
private String _currentStatName;
private String _currentGraphName;
private String _currentStatDescription;
@@ -43,11 +47,11 @@ public class ConfigStatsHelper extends HelperBase {
_log = _context.logManager().getLog(ConfigStatsHelper.class);
_stats = new ArrayList();
Map groups = _context.statManager().getStatsByGroup();
for (Iterator iter = groups.values().iterator(); iter.hasNext(); ) {
Set stats = (Set)iter.next();
for (Iterator statIter = stats.iterator(); statIter.hasNext(); )
_stats.add(statIter.next());
Map<String, SortedSet<String>> unsorted = _context.statManager().getStatsByGroup();
Map<String, Set<String>> groups = new TreeMap(new AlphaComparator());
groups.putAll(unsorted);
for (Set<String> stats : groups.values()) {
_stats.addAll(stats);
}
_filter = _context.statManager().getStatFilter();
if (_filter == null)
@@ -149,4 +153,16 @@ public class ConfigStatsHelper extends HelperBase {
public boolean getIsFull() {
return _context.getBooleanProperty(StatManager.PROP_STAT_FULL);
}
/**
* Translated sort
* @since 0.9.4
*/
private class AlphaComparator implements Comparator<String> {
public int compare(String lhs, String rhs) {
String lname = _(lhs);
String rname = _(rhs);
return Collator.getInstance().compare(lname, rname);
}
}
}

View File

@@ -1,7 +1,6 @@
package net.i2p.router.web;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
@@ -16,8 +15,6 @@ import net.i2p.data.DataHelper;
* @since 0.9.1
*/
public class ConfigSummaryHandler extends FormHandler {
private Map _settings;
@Override
protected void processForm() {
@@ -144,16 +141,6 @@ public class ConfigSummaryHandler extends FormHandler {
}
}
public void setSettings(Map settings) { _settings = new HashMap(settings); }
/** curses Jetty for returning arrays */
private String getJettyString(String key) {
String[] arr = (String[]) _settings.get(key);
if (arr == null)
return null;
return arr[0].trim();
}
public void setMovingAction() {
for (Object o : _settings.keySet()) {
if (!(o instanceof String))

View File

@@ -13,8 +13,13 @@ public class ConfigUIHandler extends FormHandler {
@Override
protected void processForm() {
if (_shouldSave)
if (_shouldSave) {
saveChanges();
} else if (_action.equals(_("Delete selected"))) {
delUser();
} else if (_action.equals(_("Add user"))) {
addUser();
}
}
public void setShouldsave(String moo) { _shouldSave = true; }
@@ -51,4 +56,48 @@ public class ConfigUIHandler extends FormHandler {
addFormError(_("Error saving the configuration (applied but not saved) - please see the error logs."));
}
}
private void addUser() {
String name = getJettyString("name");
if (name == null || name.length() <= 0) {
addFormError(_("No user name entered"));
return;
}
String pw = getJettyString("pw");
if (pw == null || pw.length() <= 0) {
addFormError(_("No password entered"));
return;
}
ConsolePasswordManager mgr = new ConsolePasswordManager(_context);
// rfc 2617
if (mgr.saveMD5(RouterConsoleRunner.PROP_CONSOLE_PW, RouterConsoleRunner.JETTY_REALM, name, pw)) {
if (!_context.getBooleanProperty(RouterConsoleRunner.PROP_PW_ENABLE))
_context.router().saveConfig(RouterConsoleRunner.PROP_PW_ENABLE, "true");
addFormNotice(_("Added user {0}", name));
addFormNotice(_("Restart required to take effect"));
} else {
addFormError(_("Error saving the configuration (applied but not saved) - please see the error logs."));
}
}
private void delUser() {
ConsolePasswordManager mgr = new ConsolePasswordManager(_context);
boolean success = false;
for (Object o : _settings.keySet()) {
if (!(o instanceof String))
continue;
String k = (String) o;
if (!k.startsWith("delete_"))
continue;
k = k.substring(7);
if (mgr.remove(RouterConsoleRunner.PROP_CONSOLE_PW, k)) {
addFormNotice(_("Removed user {0}", k));
success = true;
} else {
addFormError(_("Error saving the configuration (applied but not saved) - please see the error logs."));
}
}
if (success)
addFormNotice(_("Restart required to take effect"));
}
}

View File

@@ -2,8 +2,9 @@ package net.i2p.router.web;
import java.io.File;
import java.util.Iterator;
import java.util.TreeSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
public class ConfigUIHelper extends HelperBase {
@@ -87,4 +88,38 @@ public class ConfigUIHelper extends HelperBase {
}
return buf.toString();
}
/** @since 0.9.4 */
public String getPasswordForm() {
StringBuilder buf = new StringBuilder(512);
ConsolePasswordManager mgr = new ConsolePasswordManager(_context);
Map<String, String> userpw = mgr.getMD5(RouterConsoleRunner.PROP_CONSOLE_PW);
buf.append("<table>");
if (userpw.isEmpty()) {
buf.append("<tr><td colspan=\"3\">");
buf.append(_("Add a user and password to enable."));
buf.append("</td></tr>");
} else {
buf.append("<tr><th>")
.append(_("Remove"))
.append("</th><th>")
.append(_("User Name"))
.append("</th><th>&nbsp;</th></tr>\n");
for (String name : userpw.keySet()) {
buf.append("<tr><td align=\"center\"><input type=\"checkbox\" class=\"optbox\" name=\"delete_")
.append(name)
.append("\"></td><td colspan=\"2\">")
.append(name)
.append("</td></tr>\n");
}
}
buf.append("<tr><td align=\"center\"><b>")
.append(_("Add")).append(":</b>" +
"</td><td align=\"left\"><input type=\"text\" name=\"name\">" +
"</td><td align=\"left\"><b>");
buf.append(_("Password")).append(":</b> " +
"<input type=\"password\" size=\"40\" name=\"pw\"></td></tr>" +
"</table>\n");
return buf.toString();
}
}

View File

@@ -0,0 +1,213 @@
package net.i2p.router.web;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.i2p.data.Base64;
import net.i2p.data.DataHelper;
import net.i2p.router.Router;
import net.i2p.router.RouterContext;
import net.i2p.router.util.RouterPasswordManager;
//import org.mortbay.jetty.security.UnixCrypt;
/**
* Manage both plaintext and salted/hashed password storage in
* router.config.
*
* @since 0.9.4
*/
public class ConsolePasswordManager extends RouterPasswordManager {
private static final String PROP_MIGRATED = "routerconsole.passwordManager.migrated";
// migrate these to hash
private static final String PROP_CONSOLE_OLD = "consolePassword";
private static final String CONSOLE_USER = "admin";
public ConsolePasswordManager(RouterContext ctx) {
super(ctx);
migrateConsole();
}
/**
* The username is the salt
*
* @param realm e.g. i2cp, routerconsole, etc.
* @param user null or "" for no user, already trimmed
* @param pw plain text, already trimmed
* @return if pw verified
*/
/****
public boolean checkCrypt(String realm, String user, String pw) {
String pfx = realm;
if (user != null && user.length() > 0)
pfx += '.' + user;
String cr = _context.getProperty(pfx + PROP_CRYPT);
if (cr == null)
return false;
return cr.equals(UnixCrypt.crypt(pw, cr));
}
****/
/**
* Straight MD5. Compatible with Jetty.
*
* @param realm e.g. i2cp, routerconsole, etc.
* @param user null or "" for no user, already trimmed
* @param pw plain text, already trimmed
* @return if pw verified
*/
public boolean checkMD5(String realm, String subrealm, String user, String pw) {
String pfx = realm;
if (user != null && user.length() > 0)
pfx += '.' + user;
String hex = _context.getProperty(pfx + PROP_MD5);
if (hex == null)
return false;
return hex.equals(md5Hex(subrealm, user, pw));
}
/**
* Get all MD5 usernames and passwords. Compatible with Jetty.
* Any "null" user is NOT included..
*
* @param realm e.g. i2cp, routerconsole, etc.
* @return Map of usernames to passwords (hex with leading zeros, 32 characters)
*/
public Map<String, String> getMD5(String realm) {
String pfx = realm + '.';
Map<String, String> rv = new HashMap(4);
for (Map.Entry<String, String> e : _context.router().getConfigMap().entrySet()) {
String prop = e.getKey();
if (prop.startsWith(pfx) && prop.endsWith(PROP_MD5)) {
String user = prop.substring(0, prop.length() - PROP_MD5.length()).substring(pfx.length());
String hex = e.getValue();
if (user.length() > 0 && hex.length() == 32)
rv.put(user, hex);
}
}
return rv;
}
/**
* Migrate from plaintext to MD5 hash
* Ref: RFC 2617
*
* @return success or nothing to migrate
*/
private boolean migrateConsole() {
synchronized(ConsolePasswordManager.class) {
if (_context.getBooleanProperty(PROP_MIGRATED))
return true;
// consolePassword
String pw = _context.getProperty(PROP_CONSOLE_OLD);
if (pw != null) {
Map toAdd = new HashMap(2);
if (pw.length() > 0) {
saveMD5(RouterConsoleRunner.PROP_CONSOLE_PW, RouterConsoleRunner.JETTY_REALM,
CONSOLE_USER, pw);
toAdd.put(RouterConsoleRunner.PROP_PW_ENABLE, "true");
}
toAdd.put(PROP_MIGRATED, "true");
List toDel = Collections.singletonList(PROP_CONSOLE_OLD);
return _context.router().saveConfig(toAdd, toDel);
}
return true;
}
}
/**
* This will fail if
* user contains '#' or '=' or starts with '!'
* The user is the salt.
*
* @param realm e.g. i2cp, routerconsole, etc.
* @param user null or "" for no user, already trimmed
* @param pw plain text, already trimmed
* @return success
*/
/****
public boolean saveCrypt(String realm, String user, String pw) {
String pfx = realm;
if (user != null && user.length() > 0)
pfx += '.' + user;
String salt = user != null ? user : "";
String crypt = UnixCrypt.crypt(pw, salt);
Map<String, String> toAdd = Collections.singletonMap(pfx + PROP_CRYPT, crypt);
List<String> toDel = new ArrayList(4);
toDel.add(pfx + PROP_PW);
toDel.add(pfx + PROP_B64);
toDel.add(pfx + PROP_MD5);
toDel.add(pfx + PROP_SHASH);
return _context.router().saveConfig(toAdd, toDel);
}
****/
/**
* Straight MD5, no salt
* Compatible with Jetty and RFC 2617.
*
* @param realm The full realm, e.g. routerconsole.auth.i2prouter, etc.
* @param subrealm to be used in creating the checksum
* @param user non-null, non-empty, already trimmed
* @param pw plain text
* @return if pw verified
*/
public boolean saveMD5(String realm, String subrealm, String user, String pw) {
String pfx = realm;
if (user != null && user.length() > 0)
pfx += '.' + user;
String hex = md5Hex(subrealm, user, pw);
if (hex == null)
return false;
Map<String, String> toAdd = Collections.singletonMap(pfx + PROP_MD5, hex);
List<String> toDel = new ArrayList(4);
toDel.add(pfx + PROP_PW);
toDel.add(pfx + PROP_B64);
toDel.add(pfx + PROP_CRYPT);
toDel.add(pfx + PROP_SHASH);
return _context.router().saveConfig(toAdd, toDel);
}
public static void main(String args[]) {
RouterContext ctx = (new Router()).getContext();
ConsolePasswordManager pm = new ConsolePasswordManager(ctx);
if (!pm.migrate())
System.out.println("Fail 1");
if (!pm.migrateConsole())
System.out.println("Fail 1a");
System.out.println("Test plain");
if (!pm.savePlain("type1", "user1", "pw1"))
System.out.println("Fail 2");
if (!pm.checkPlain("type1", "user1", "pw1"))
System.out.println("Fail 3");
System.out.println("Test B64");
if (!pm.saveB64("type2", "user2", "pw2"))
System.out.println("Fail 4");
if (!pm.checkB64("type2", "user2", "pw2"))
System.out.println("Fail 5");
System.out.println("Test MD5");
if (!pm.saveMD5("type3", "realm", "user3", "pw3"))
System.out.println("Fail 6");
if (!pm.checkMD5("type3", "realm", "user3", "pw3"))
System.out.println("Fail 7");
//System.out.println("Test crypt");
//if (!pm.saveCrypt("type4", "user4", "pw4"))
// System.out.println("Fail 8");
//if (!pm.checkCrypt("type4", "user4", "pw4"))
// System.out.println("Fail 9");
System.out.println("Test hash");
if (!pm.saveHash("type5", "user5", "pw5"))
System.out.println("Fail 10");
if (!pm.checkHash("type5", "user5", "pw5"))
System.out.println("Fail 11");
}
}

View File

@@ -1,7 +1,9 @@
package net.i2p.router.web;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.i2p.router.RouterContext;
import net.i2p.util.Log;
@@ -18,16 +20,14 @@ import net.i2p.util.Log;
public class FormHandler {
protected RouterContext _context;
protected Log _log;
private String _nonce;
protected Map _settings;
private String _nonce, _nonce1, _nonce2;
protected String _action;
protected String _method;
protected String _passphrase;
private final List<String> _errors;
private final List<String> _notices;
private boolean _processed;
private boolean _valid;
private static final String NONCE_SUFFIX = ".nonce";
private static final String PREV_SUFFIX = "Prev";
public FormHandler() {
_errors = new ArrayList();
@@ -52,7 +52,28 @@ public class FormHandler {
public void setNonce(String val) { _nonce = val; }
public void setAction(String val) { _action = val; }
public void setPassphrase(String val) { _passphrase = val; }
/**
* For many forms, it's easiest just to put all the parameters here.
*
* @since 0.9.4 consolidated from numerous FormHandlers
*/
public void setSettings(Map settings) { _settings = new HashMap(settings); }
/**
* setSettings() must have been called previously
* Curses Jetty for returning arrays.
*
* @since 0.9.4 consolidated from numerous FormHandlers
*/
protected String getJettyString(String key) {
if (_settings == null)
return null;
String[] arr = (String[]) _settings.get(key);
if (arr == null)
return null;
return arr[0].trim();
}
/**
* Call this to prevent changes using GET
@@ -61,6 +82,15 @@ public class FormHandler {
* @since 0.8.2
*/
public void storeMethod(String val) { _method = val; }
/**
* The old nonces from the session
* @since 0.9.4
*/
public void storeNonces(String n1, String n2) {
_nonce1 = n1;
_nonce2 = n2;
}
/**
* Override this to perform the final processing (in turn, adding formNotice
@@ -147,35 +177,33 @@ public class FormHandler {
_valid = false;
return;
}
if (_nonce == null) {
//addFormError("You trying to mess with me? Huh? Are you?");
_valid = false;
return;
}
// To prevent actions with GET, jsps must call storeMethod()
if (_method != null && !"POST".equals(_method)) {
addFormError("Invalid form submission, requires POST not " + _method);
_valid = false;
return;
}
// If passwords are turned on, all is assumed good
if (_context.getBooleanProperty(RouterConsoleRunner.PROP_PW_ENABLE)) {
_valid = true;
return;
}
if (_nonce == null) {
//addFormError("You trying to mess with me? Huh? Are you?");
_valid = false;
return;
}
String sharedNonce = System.getProperty("router.consoleNonce");
if ( (sharedNonce != null) && (sharedNonce.equals(_nonce) ) ) {
return;
}
String nonce = System.getProperty(getClass().getName() + NONCE_SUFFIX);
String noncePrev = nonce + PREV_SUFFIX;
if ( ( (nonce == null) || (!_nonce.equals(nonce)) ) &&
( (noncePrev == null) || (!_nonce.equals(noncePrev)) ) ) {
String expected = _context.getProperty("consolePassword");
if ( (expected != null) && (expected.trim().length() > 0) && (expected.equals(_passphrase)) ) {
// ok
} else {
addFormError(_("Invalid form submission, probably because you used the 'back' or 'reload' button on your browser. Please resubmit."));
if (!_nonce.equals(_nonce1) && !_nonce.equals(_nonce2)) {
addFormError(_("Invalid form submission, probably because you used the 'back' or 'reload' button on your browser. Please resubmit.")
+ ' ' +
_("If the problem persists, verify that you have cookies enabled in your browser."));
_valid = false;
}
}
}
@@ -204,18 +232,13 @@ public class FormHandler {
}
/**
* Generate a new nonce, store old and new in the system properties.
* Generate a new nonce.
* Only call once per page!
* @return a new random long as a String
* @since 0.8.5
*/
public String getNewNonce() {
String prop = getClass().getName() + NONCE_SUFFIX;
String prev = System.getProperty(prop);
if (prev != null)
System.setProperty(prop + PREV_SUFFIX, prev);
String rv = Long.toString(_context.random().nextLong());
System.setProperty(prop, rv);
return rv;
}

View File

@@ -29,7 +29,7 @@ public class LogsHelper extends HelperBase {
*/
public String getLogs() {
String str = formatMessages(_context.logManager().getBuffer().getMostRecentMessages());
return _("File location") + ": <b><code>" + _context.logManager().currentFile() + "</code></b><br><br>" + str;
return "<p>" + _("File location") + ": <b><code>" + _context.logManager().currentFile() + "</code></b></p>" + str;
}
/**
@@ -73,10 +73,10 @@ public class LogsHelper extends HelperBase {
File f = wrapperLogFile(_context);
String str = FileUtil.readTextFile(f.getAbsolutePath(), 250, false);
if (str == null)
return _("File not found") + ": <b><code>" + f.getAbsolutePath() + "</code></b>";
return "<p>" + _("File not found") + ": <b><code>" + f.getAbsolutePath() + "</code></b></p>";
else {
str = str.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;");
return _("File location") + ": <b><code>" + f.getAbsolutePath() + "</code></b> <pre>" + str + "</pre>";
return "<p>" + _("File location") + ": <b><code>" + f.getAbsolutePath() + "</code></b></p><pre>" + str + "</pre>";
}
}
@@ -97,6 +97,9 @@ public class LogsHelper extends HelperBase {
buf.append("<ul>");
for (int i = msgs.size() - 1; i >= 0; i--) {
String msg = msgs.get(i);
// don't display the dup message if it is last
if (i == 0 && msg.contains("&darr;"))
break;
msg = msg.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;");
msg = msg.replace("&amp;darr;", "&darr;"); // hack - undo the damage (LogWriter)
// remove last \n that LogRecordFormatter added

View File

@@ -662,7 +662,7 @@ public class PluginStarter implements Runnable {
// quick check, will throw ClassNotFoundException on error
LoadClientAppsJob.testClient(app.className, cl);
// run this guy now
LoadClientAppsJob.runClient(app.className, app.clientName, argVal, log, pluginThreadGroup, cl);
LoadClientAppsJob.runClient(app.className, app.clientName, argVal, ctx, log, pluginThreadGroup, cl);
} else {
// If there is some delay, there may be a really good reason for it.
// Loading a class would be one of them!

View File

@@ -168,7 +168,7 @@ 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 (_context.banlist().isBanlisted(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);

View File

@@ -46,7 +46,7 @@ public class ProfilesHelper extends HelperBase {
renderNavBar();
} catch (IOException ioe) {}
if (_full == 3)
getShitlistSummary();
getBanlistSummary();
else
getProfileSummary();
return "";
@@ -64,9 +64,9 @@ public class ProfilesHelper extends HelperBase {
}
/** @return empty string, writes directly to _out */
public String getShitlistSummary() {
public String getBanlistSummary() {
try {
ShitlistRenderer rend = new ShitlistRenderer(_context);
BanlistRenderer rend = new BanlistRenderer(_context);
rend.renderStatusHTML(_out);
} catch (IOException ioe) {
ioe.printStackTrace();

View File

@@ -23,11 +23,15 @@ import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import net.i2p.I2PAppContext;
import net.i2p.app.ClientAppManager;
import net.i2p.app.ClientAppState;
import static net.i2p.app.ClientAppState.*;
import net.i2p.apps.systray.SysTray;
import net.i2p.data.Base32;
import net.i2p.data.DataHelper;
import net.i2p.router.RouterContext;
import net.i2p.router.update.ConsoleUpdateManager;
import net.i2p.router.app.RouterApp;
import net.i2p.util.Addresses;
import net.i2p.util.FileUtil;
import net.i2p.util.I2PAppThread;
@@ -48,6 +52,7 @@ import org.mortbay.jetty.handler.DefaultHandler;
import org.mortbay.jetty.handler.HandlerCollection;
import org.mortbay.jetty.handler.RequestLogHandler;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.security.Credential.MD5;
import org.mortbay.jetty.security.DigestAuthenticator;
import org.mortbay.jetty.security.HashUserRealm;
import org.mortbay.jetty.security.Constraint;
@@ -65,7 +70,10 @@ import org.mortbay.thread.concurrent.ThreadPool;
/**
* Start the router console.
*/
public class RouterConsoleRunner {
public class RouterConsoleRunner implements RouterApp {
private final RouterContext _context;
private final ClientAppManager _mgr;
private volatile ClientAppState _state = UNINITIALIZED;
private static Server _server;
private String _listenPort;
private String _listenHost;
@@ -74,14 +82,21 @@ public class RouterConsoleRunner {
private String _webAppsDir;
private static final String DEFAULT_WEBAPP_CONFIG_FILENAME = "webapps.config";
// Jetty Auth
private static final DigestAuthenticator authenticator = new DigestAuthenticator();
public static final String JETTY_REALM = "i2prouter";
private static final String JETTY_ROLE = "routerAdmin";
public static final String PROP_CONSOLE_PW = "routerconsole.auth." + JETTY_REALM;
public static final String PROP_PW_ENABLE = "routerconsole.auth.enable";
public static final String ROUTERCONSOLE = "routerconsole";
public static final String PREFIX = "webapps.";
public static final String ENABLED = ".startOnLoad";
private static final String PROP_KEYSTORE_PASSWORD = "routerconsole.keystorePassword";
private static final String DEFAULT_KEYSTORE_PASSWORD = "changeit";
private static final String PROP_KEY_PASSWORD = "routerconsole.keyPassword";
private static final String DEFAULT_LISTEN_PORT = "7657";
public static final int DEFAULT_LISTEN_PORT = 7657;
private static final String DEFAULT_LISTEN_HOST = "127.0.0.1";
private static final String DEFAULT_WEBAPPS_DIR = "./webapps/";
private static final String USAGE = "Bad RouterConsoleRunner arguments, check clientApp.0.args in your clients.config file! " +
@@ -125,10 +140,12 @@ public class RouterConsoleRunner {
* to both, we can't connect to [::1]:7657 for some reason.
* So the wise choice is ::1,127.0.0.1
*/
public RouterConsoleRunner(String args[]) {
public RouterConsoleRunner(RouterContext ctx, ClientAppManager mgr, String args[]) {
_context = ctx;
_mgr = mgr;
if (args.length == 0) {
// _listenHost and _webAppsDir are defaulted below
_listenPort = DEFAULT_LISTEN_PORT;
_listenPort = Integer.toString(DEFAULT_LISTEN_PORT);
} else {
boolean ssl = false;
for (int i = 0; i < args.length; i++) {
@@ -161,14 +178,61 @@ public class RouterConsoleRunner {
System.err.println(USAGE);
throw new IllegalArgumentException(USAGE);
}
_state = INITIALIZED;
}
public static void main(String args[]) {
startTrayApp();
RouterConsoleRunner runner = new RouterConsoleRunner(args);
runner.startConsole();
List<RouterContext> contexts = RouterContext.listContexts();
if (contexts == null || contexts.isEmpty())
throw new IllegalStateException("no router context");
RouterConsoleRunner runner = new RouterConsoleRunner(contexts.get(0), null, args);
runner.startup();
}
/////// ClientApp methods
/** @since 0.9.4 */
public void startup() {
changeState(STARTING);
startTrayApp(_context);
startConsole();
}
/** @since 0.9.4 */
public void shutdown(String[] args) {
changeState(STOPPING);
try {
_server.stop();
} catch (Exception ie) {}
PortMapper portMapper = _context.portMapper();
portMapper.unregister(PortMapper.SVC_CONSOLE);
portMapper.unregister(PortMapper.SVC_HTTPS_CONSOLE);
changeState(STOPPED);
}
/** @since 0.9.4 */
public ClientAppState getState() {
return _state;
}
/** @since 0.9.4 */
public String getName() {
return "console";
}
/** @since 0.9.4 */
public String getDisplayName() {
return "Router Console";
}
/////// end ClientApp methods
private synchronized void changeState(ClientAppState state) {
_state = state;
if (_mgr != null)
_mgr.notify(this, state, null, null);
}
/**
* SInce _server is now static
* @return may be null or stopped perhaps
@@ -178,13 +242,13 @@ public class RouterConsoleRunner {
return _server;
}
private static void startTrayApp() {
private static void startTrayApp(I2PAppContext ctx) {
try {
//TODO: move away from routerconsole into a separate application.
//ApplicationManager?
boolean recentJava = SystemVersion.isJava6();
// default false for now
boolean desktopguiEnabled = I2PAppContext.getGlobalContext().getBooleanProperty("desktopgui.enabled");
boolean desktopguiEnabled = ctx.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()));
@@ -219,7 +283,7 @@ public class RouterConsoleRunner {
*</pre>
*/
public void startConsole() {
File workDir = new SecureDirectory(I2PAppContext.getGlobalContext().getTempDir(), "jetty-work");
File workDir = new SecureDirectory(_context.getTempDir(), "jetty-work");
boolean workDirRemoved = FileUtil.rmdir(workDir, false);
if (!workDirRemoved)
System.err.println("ERROR: Unable to remove Jetty temporary work directory");
@@ -228,7 +292,7 @@ public class RouterConsoleRunner {
System.err.println("ERROR: Unable to create Jetty temporary work directory");
//try {
// Log.setLog(new I2PLogger(I2PAppContext.getGlobalContext()));
// Log.setLog(new I2PLogger(_context));
//} catch (Throwable t) {
// System.err.println("INFO: I2P Jetty logging class not found, logging to wrapper log");
//}
@@ -236,7 +300,7 @@ public class RouterConsoleRunner {
System.setProperty("org.mortbay.log.class", "net.i2p.jetty.I2PLogger");
// so Jetty can find WebAppConfiguration
System.setProperty("jetty.class.path", I2PAppContext.getGlobalContext().getBaseDir() + "/lib/routerconsole.jar");
System.setProperty("jetty.class.path", _context.getBaseDir() + "/lib/routerconsole.jar");
_server = new Server();
_server.setGracefulShutdown(1000);
@@ -259,11 +323,11 @@ public class RouterConsoleRunner {
hColl.addHandler(chColl);
hColl.addHandler(new DefaultHandler());
String log = I2PAppContext.getGlobalContext().getProperty("routerconsole.log");
String log = _context.getProperty("routerconsole.log");
if (log != null) {
File logFile = new File(log);
if (!logFile.isAbsolute())
logFile = new File(I2PAppContext.getGlobalContext().getLogDir(), "logs/" + log);
logFile = new File(_context.getLogDir(), "logs/" + log);
try {
RequestLogHandler rhl = new RequestLogHandler();
rhl.setRequestLog(new NCSARequestLog(logFile.getAbsolutePath()));
@@ -283,7 +347,7 @@ public class RouterConsoleRunner {
// We assume relative to the base install dir for backward compatibility
File app = new File(_webAppsDir);
if (!app.isAbsolute()) {
app = new File(I2PAppContext.getGlobalContext().getBaseDir(), _webAppsDir);
app = new File(_context.getBaseDir(), _webAppsDir);
try {
_webAppsDir = app.getCanonicalPath();
} catch (IOException ioe) {}
@@ -363,7 +427,7 @@ public class RouterConsoleRunner {
}
}
// XXX: what if listenhosts do not include 127.0.0.1? (Should that ever even happen?)
I2PAppContext.getGlobalContext().portMapper().register(PortMapper.SVC_CONSOLE,lport);
_context.portMapper().register(PortMapper.SVC_CONSOLE,lport);
}
// add SSL listeners
@@ -376,8 +440,7 @@ public class RouterConsoleRunner {
System.err.println("Bad routerconsole SSL port " + _sslListenPort);
}
if (sslPort > 0) {
I2PAppContext ctx = I2PAppContext.getGlobalContext();
File keyStore = new File(ctx.getConfigDir(), "keystore/console.ks");
File keyStore = new File(_context.getConfigDir(), "keystore/console.ks");
if (verifyKeyStore(keyStore)) {
StringTokenizer tok = new StringTokenizer(_sslListenHost, " ,");
while (tok.hasMoreTokens()) {
@@ -408,9 +471,9 @@ public class RouterConsoleRunner {
SslSelectChannelConnector sssll = new SslSelectChannelConnector();
// the keystore path and password
sssll.setKeystore(keyStore.getAbsolutePath());
sssll.setPassword(ctx.getProperty(PROP_KEYSTORE_PASSWORD, DEFAULT_KEYSTORE_PASSWORD));
sssll.setPassword(_context.getProperty(PROP_KEYSTORE_PASSWORD, DEFAULT_KEYSTORE_PASSWORD));
// the X.509 cert password (if not present, verifyKeyStore() returned false)
sssll.setKeyPassword(ctx.getProperty(PROP_KEY_PASSWORD, "thisWontWork"));
sssll.setKeyPassword(_context.getProperty(PROP_KEY_PASSWORD, "thisWontWork"));
sssll.setUseDirectBuffers(false); // default true seems to be leaky
ssll = sssll;
} else {
@@ -418,9 +481,9 @@ public class RouterConsoleRunner {
SslSocketConnector sssll = new SslSocketConnector();
// the keystore path and password
sssll.setKeystore(keyStore.getAbsolutePath());
sssll.setPassword(ctx.getProperty(PROP_KEYSTORE_PASSWORD, DEFAULT_KEYSTORE_PASSWORD));
sssll.setPassword(_context.getProperty(PROP_KEYSTORE_PASSWORD, DEFAULT_KEYSTORE_PASSWORD));
// the X.509 cert password (if not present, verifyKeyStore() returned false)
sssll.setKeyPassword(ctx.getProperty(PROP_KEY_PASSWORD, "thisWontWork"));
sssll.setKeyPassword(_context.getProperty(PROP_KEY_PASSWORD, "thisWontWork"));
ssll = sssll;
}
ssll.setHost(host);
@@ -437,7 +500,7 @@ public class RouterConsoleRunner {
System.err.println("You may ignore this warning if the console is still available at https://localhost:" + sslPort);
}
}
I2PAppContext.getGlobalContext().portMapper().register(PortMapper.SVC_HTTPS_CONSOLE,sslPort);
_context.portMapper().register(PortMapper.SVC_HTTPS_CONSOLE,sslPort);
} else {
System.err.println("Unable to create or access keystore for SSL: " + keyStore.getAbsolutePath());
}
@@ -448,7 +511,7 @@ public class RouterConsoleRunner {
return;
}
rootWebApp = new LocaleWebAppHandler(I2PAppContext.getGlobalContext(),
rootWebApp = new LocaleWebAppHandler(_context,
"/", _webAppsDir + ROUTERCONSOLE + ".war");
File tmpdir = new SecureDirectory(workDir, ROUTERCONSOLE + "-" +
(_listenPort != null ? _listenPort : _sslListenPort));
@@ -458,7 +521,7 @@ public class RouterConsoleRunner {
rootWebApp.setSessionHandler(new SessionHandler());
rootServletHandler = new ServletHandler();
rootWebApp.setServletHandler(rootServletHandler);
initialize(rootWebApp);
initialize(_context, rootWebApp);
chColl.addHandler(rootWebApp);
} catch (Exception ioe) {
@@ -495,7 +558,7 @@ public class RouterConsoleRunner {
}
if (error) {
System.err.println("WARNING: Error starting one or more listeners of the Router Console server.\n" +
"If your console is still accessible at http://127.0.0.1:7657/,\n" +
"If your console is still accessible at http://127.0.0.1:" + _listenPort + "/,\n" +
"this may be a problem only with binding to the IPV6 address ::1.\n" +
"If so, you may ignore this error, or remove the\n" +
"\"::1,\" in the \"clientApp.0.args\" line of the clients.config file.");
@@ -517,7 +580,7 @@ public class RouterConsoleRunner {
if (! "false".equals(enabled)) {
try {
String path = new File(dir, fileNames[i]).getCanonicalPath();
WebAppStarter.startWebApp(I2PAppContext.getGlobalContext(), chColl, appName, path);
WebAppStarter.startWebApp(_context, chColl, appName, path);
if (enabled == null) {
// do this so configclients.jsp knows about all apps from reading the config
props.setProperty(PREFIX + appName + ENABLED, "true");
@@ -532,13 +595,15 @@ public class RouterConsoleRunner {
notStarted.add(appName);
}
}
changeState(RUNNING);
}
} else {
System.err.println("ERROR: Router console did not start, not starting webapps");
changeState(START_FAILED);
}
if (rewrite)
storeWebAppProperties(props);
storeWebAppProperties(_context, props);
if (rootServletHandler != null && notStarted.size() > 0) {
// map each not-started webapp to the error page
@@ -565,35 +630,29 @@ public class RouterConsoleRunner {
t.setPriority(Thread.NORM_PRIORITY - 1);
t.start();
List<RouterContext> contexts = RouterContext.listContexts();
if (contexts != null) {
RouterContext ctx = contexts.get(0);
ConsoleUpdateManager um = new ConsoleUpdateManager(ctx);
ConsoleUpdateManager um = new ConsoleUpdateManager(_context);
um.start();
if (PluginStarter.pluginsEnabled(ctx)) {
t = new I2PAppThread(new PluginStarter(ctx), "PluginStarter", true);
if (PluginStarter.pluginsEnabled(_context)) {
t = new I2PAppThread(new PluginStarter(_context), "PluginStarter", true);
t.setPriority(Thread.NORM_PRIORITY - 1);
t.start();
ctx.addShutdownTask(new PluginStopper(ctx));
_context.addShutdownTask(new PluginStopper(_context));
}
// stat summarizer registers its own hook
ctx.addShutdownTask(new ServerShutdown());
ConfigServiceHandler.registerSignalHandler(ctx);
} // else log CRIT ?
_context.addShutdownTask(new ServerShutdown());
ConfigServiceHandler.registerSignalHandler(_context);
}
/**
* @return success if it exists and we have a password, or it was created successfully.
* @since 0.8.3
*/
private static boolean verifyKeyStore(File ks) {
private boolean verifyKeyStore(File ks) {
if (ks.exists()) {
I2PAppContext ctx = I2PAppContext.getGlobalContext();
boolean rv = ctx.getProperty(PROP_KEY_PASSWORD) != null;
boolean rv = _context.getProperty(PROP_KEY_PASSWORD) != null;
if (!rv)
System.err.println("Console SSL error, must set " + PROP_KEY_PASSWORD + " in " + (new File(ctx.getConfigDir(), "router.config")).getAbsolutePath());
System.err.println("Console SSL error, must set " + PROP_KEY_PASSWORD + " in " + (new File(_context.getConfigDir(), "router.config")).getAbsolutePath());
return rv;
}
File dir = ks.getParentFile();
@@ -614,14 +673,13 @@ public class RouterConsoleRunner {
* @return success
* @since 0.8.3
*/
private static boolean createKeyStore(File ks) {
I2PAppContext ctx = I2PAppContext.getGlobalContext();
private boolean createKeyStore(File ks) {
// make a random 48 character password (30 * 8 / 5)
byte[] rand = new byte[30];
ctx.random().nextBytes(rand);
_context.random().nextBytes(rand);
String keyPassword = Base32.encode(rand);
// and one for the cname
ctx.random().nextBytes(rand);
_context.random().nextBytes(rand);
String cname = Base32.encode(rand) + ".console.i2p.net";
String keytool = (new File(System.getProperty("java.home"), "bin/keytool")).getAbsolutePath();
@@ -643,11 +701,10 @@ public class RouterConsoleRunner {
if (success) {
SecureFileOutputStream.setPerms(ks);
try {
RouterContext rctx = (RouterContext) ctx;
Map<String, String> changes = new HashMap();
changes.put(PROP_KEYSTORE_PASSWORD, DEFAULT_KEYSTORE_PASSWORD);
changes.put(PROP_KEY_PASSWORD, keyPassword);
rctx.router().saveConfig(changes, null);
_context.router().saveConfig(changes, null);
} catch (Exception e) {} // class cast exception
}
}
@@ -664,27 +721,42 @@ public class RouterConsoleRunner {
System.err.println(buf.toString());
System.err.println("This is for the Sun/Oracle keytool, others may be incompatible.\n" +
"If you create the keystore manually, you must add " + PROP_KEYSTORE_PASSWORD + " and " + PROP_KEY_PASSWORD +
" to " + (new File(ctx.getConfigDir(), "router.config")).getAbsolutePath());
" to " + (new File(_context.getConfigDir(), "router.config")).getAbsolutePath());
}
return success;
}
static void initialize(WebAppContext context) {
/**
* Set up basic security constraints for the webapp.
* Add all users and passwords.
*/
static void initialize(RouterContext ctx, WebAppContext context) {
SecurityHandler sec = new SecurityHandler();
List<ConstraintMapping> constraints = new ArrayList(4);
String password = getPassword();
if (password != null) {
HashUserRealm realm = new HashUserRealm("i2prouter");
realm.put("admin", password);
realm.addUserToRole("admin", "routerAdmin");
sec.setUserRealm(realm);
sec.setAuthenticator(authenticator);
Constraint constraint = new Constraint("admin", "routerAdmin");
constraint.setAuthenticate(true);
ConstraintMapping cm = new ConstraintMapping();
cm.setConstraint(constraint);
cm.setPathSpec("/");
constraints.add(cm);
ConsolePasswordManager mgr = new ConsolePasswordManager(ctx);
boolean enable = ctx.getBooleanProperty(PROP_PW_ENABLE);
if (enable) {
Map<String, String> userpw = mgr.getMD5(PROP_CONSOLE_PW);
if (userpw.isEmpty()) {
enable = false;
ctx.router().saveConfig(PROP_CONSOLE_PW, "false");
} else {
HashUserRealm realm = new HashUserRealm(JETTY_REALM);
sec.setUserRealm(realm);
sec.setAuthenticator(authenticator);
for (Map.Entry<String, String> e : userpw.entrySet()) {
String user = e.getKey();
String pw = e.getValue();
realm.put(user, MD5.__TYPE + pw);
realm.addUserToRole(user, JETTY_ROLE);
Constraint constraint = new Constraint(user, JETTY_ROLE);
constraint.setAuthenticate(true);
ConstraintMapping cm = new ConstraintMapping();
cm.setConstraint(constraint);
cm.setPathSpec("/");
constraints.add(cm);
}
}
}
// This forces a '403 Forbidden' response for TRACE and OPTIONS unless the
@@ -719,43 +791,25 @@ public class RouterConsoleRunner {
context.setSecurityHandler(sec);
}
static String getPassword() {
List<RouterContext> contexts = RouterContext.listContexts();
if (contexts != null) {
for (int i = 0; i < contexts.size(); i++) {
RouterContext ctx = contexts.get(i);
String password = ctx.getProperty("consolePassword");
if (password != null) {
password = password.trim();
if (password.length() > 0) {
return password;
}
}
}
// no password in any context
return null;
} else {
// no contexts?!
return null;
}
}
/** @since 0.8.8 */
private static class ServerShutdown implements Runnable {
private class ServerShutdown implements Runnable {
public void run() {
try {
_server.stop();
} catch (Exception ie) {}
shutdown(null);
}
}
public static Properties webAppProperties() {
return webAppProperties(I2PAppContext.getGlobalContext().getConfigDir().getAbsolutePath());
private Properties webAppProperties() {
return webAppProperties(_context.getConfigDir().getAbsolutePath());
}
/** @since 0.9.4 */
public static Properties webAppProperties(I2PAppContext ctx) {
return webAppProperties(ctx.getConfigDir().getAbsolutePath());
}
public static Properties webAppProperties(String dir) {
Properties rv = new Properties();
// String webappConfigFile = ctx.getProperty(PROP_WEBAPP_CONFIG_FILENAME, DEFAULT_WEBAPP_CONFIG_FILENAME);
// String webappConfigFile = _context.getProperty(PROP_WEBAPP_CONFIG_FILENAME, DEFAULT_WEBAPP_CONFIG_FILENAME);
String webappConfigFile = DEFAULT_WEBAPP_CONFIG_FILENAME;
File cfgFile = new File(dir, webappConfigFile);
@@ -768,10 +822,10 @@ public class RouterConsoleRunner {
return rv;
}
public static void storeWebAppProperties(Properties props) {
// String webappConfigFile = ctx.getProperty(PROP_WEBAPP_CONFIG_FILENAME, DEFAULT_WEBAPP_CONFIG_FILENAME);
public static void storeWebAppProperties(RouterContext ctx, Properties props) {
// String webappConfigFile = _context.getProperty(PROP_WEBAPP_CONFIG_FILENAME, DEFAULT_WEBAPP_CONFIG_FILENAME);
String webappConfigFile = DEFAULT_WEBAPP_CONFIG_FILENAME;
File cfgFile = new File(I2PAppContext.getGlobalContext().getConfigDir(), webappConfigFile);
File cfgFile = new File(ctx.getConfigDir(), webappConfigFile);
try {
DataHelper.storeProps(props, cfgFile);

View File

@@ -172,6 +172,8 @@ public class SummaryHelper extends HelperBase {
//if (_context.router().getRouterInfo().getCapabilities().indexOf('O') >= 0)
// return _("WARN-Firewalled and Fast");
return _("Firewalled");
case CommSystemFacade.STATUS_DISCONNECTED:
return _("Disconnected - check network cable");
case CommSystemFacade.STATUS_HOSED:
return _("ERR-UDP Port In Use - Set i2np.udp.internalPort=xxxx in advanced config and restart");
case CommSystemFacade.STATUS_UNKNOWN: // fallthrough
@@ -283,11 +285,11 @@ public class SummaryHelper extends HelperBase {
*
*/
/********
public int getShitlistedPeers() {
public int getBanlistedPeers() {
if (_context == null)
return 0;
else
return _context.shitlist().getRouterCount();
return _context.banlist().getRouterCount();
}
********/

View File

@@ -74,7 +74,7 @@ public class WebAppConfiguration implements Configuration {
cp = props.getProperty(RouterConsoleRunner.PREFIX + appName + CLASSPATH);
dir = pluginDir;
} else {
Properties props = RouterConsoleRunner.webAppProperties();
Properties props = RouterConsoleRunner.webAppProperties(i2pContext);
cp = props.getProperty(RouterConsoleRunner.PREFIX + appName + CLASSPATH);
}
if (cp == null)

View File

@@ -6,7 +6,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import net.i2p.I2PAppContext;
import net.i2p.router.RouterContext;
import net.i2p.util.FileUtil;
import net.i2p.util.SecureDirectory;
@@ -51,7 +51,7 @@ public class WebAppStarter {
* adds and starts
* @throws just about anything, caller would be wise to catch Throwable
*/
static void startWebApp(I2PAppContext ctx, ContextHandlerCollection server,
static void startWebApp(RouterContext ctx, ContextHandlerCollection server,
String appName, String warPath) throws Exception {
File tmpdir = new SecureDirectory(ctx.getTempDir(), "jetty-work-" + appName + ctx.random().nextInt());
WebAppContext wac = addWebApp(ctx, server, appName, warPath, tmpdir);
@@ -65,7 +65,7 @@ public class WebAppStarter {
* This is used only by RouterConsoleRunner, which adds all the webapps first
* and then starts all at once.
*/
static WebAppContext addWebApp(I2PAppContext ctx, ContextHandlerCollection server,
static WebAppContext addWebApp(RouterContext ctx, ContextHandlerCollection server,
String appName, String warPath, File tmpdir) throws IOException {
// Jetty will happily load one context on top of another without stopping
@@ -103,7 +103,7 @@ public class WebAppStarter {
wac.setExtractWAR(false);
// this does the passwords...
RouterConsoleRunner.initialize(wac);
RouterConsoleRunner.initialize(ctx, wac);
// see WebAppConfiguration for info
String[] classNames = wac.getConfigurationClasses();

View File

@@ -19,13 +19,10 @@
<%@include file="confignav.jsi" %>
<jsp:useBean class="net.i2p.router.web.ConfigNetHandler" id="formhandler" scope="request" />
<% formhandler.storeMethod(request.getMethod()); %>
<jsp:setProperty name="formhandler" property="*" />
<jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
<jsp:getProperty name="formhandler" property="allMessages" />
<%@include file="formhandler.jsi" %>
<div class="configure">
<form action="" method="POST">
<input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
<input type="hidden" name="nonce" value="<%=pageNonce%>">
<input type="hidden" name="action" value="blah" >
<input type="hidden" name="ratesOnly" value="1" >
<h3><%=intl._("Bandwidth limiter")%></h3><p>

View File

@@ -21,14 +21,11 @@
<%@include file="confignav.jsi" %>
<jsp:useBean class="net.i2p.router.web.ConfigAdvancedHandler" id="formhandler" scope="request" />
<% formhandler.storeMethod(request.getMethod()); %>
<jsp:setProperty name="formhandler" property="*" />
<jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
<jsp:getProperty name="formhandler" property="allMessages" />
<%@include file="formhandler.jsi" %>
<div class="configure">
<div class="wideload">
<form action="" method="POST">
<input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
<input type="hidden" name="action" value="blah" >
<h3><%=intl._("Advanced I2P Configuration")%></h3>
<textarea rows="32" cols="60" name="config" wrap="off" spellcheck="false"><jsp:getProperty name="advancedhelper" property="settings" /></textarea><br><hr>

View File

@@ -25,16 +25,8 @@ input.default { width: 1px; height: 1px; visibility: hidden; }
<%@include file="confignav.jsi" %>
<jsp:useBean class="net.i2p.router.web.ConfigClientsHandler" id="formhandler" scope="request" />
<% formhandler.storeMethod(request.getMethod()); %>
<jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
<jsp:setProperty name="formhandler" property="action" value="<%=request.getParameter(\"action\")%>" />
<jsp:setProperty name="formhandler" property="nonce" value="<%=request.getParameter(\"nonce\")%>" />
<jsp:setProperty name="formhandler" property="settings" value="<%=request.getParameterMap()%>" />
<jsp:getProperty name="formhandler" property="allMessages" />
<%@include file="formhandler.jsi" %>
<div class="configure">
<%
String pageNonce = formhandler.getNewNonce();
%>
<h3><%=intl._("Client Configuration")%></h3><p>
<%=intl._("The Java clients listed below are started by the router and run in the same JVM.")%>
</p><div class="wideload">
@@ -85,9 +77,9 @@ input.default { width: 1px; height: 1px; visibility: hidden; }
<input type="checkbox" class="optbox" name="auth" value="true" <jsp:getProperty name="clientshelper" property="auth" /> >
<%=intl._("Require username and password")%><br>
<%=intl._("Username")%>:
<input name="user" type="text" value="<jsp:getProperty name="clientshelper" property="user" />" ><br>
<input name="user" type="text" value="" /><br>
<%=intl._("Password")%>:
<input name="pw" type="password" value="<jsp:getProperty name="clientshelper" property="pw" />" ><br>
<input name="pw" type="password" value="" /><br>
</p><p><b><%=intl._("The default settings will work for most people.")%></b>
<%=intl._("Any changes made here must also be configured in the external client.")%>
<%=intl._("Many clients do not support SSL or authorization.")%>

View File

@@ -22,14 +22,7 @@ input.default {
<%@include file="confignav.jsi" %>
<jsp:useBean class="net.i2p.router.web.ConfigHomeHandler" id="formhandler" scope="request" />
<% formhandler.storeMethod(request.getMethod()); %>
<jsp:setProperty name="formhandler" property="*" />
<jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
<jsp:setProperty name="formhandler" property="settings" value="<%=request.getParameterMap()%>" />
<jsp:getProperty name="formhandler" property="allMessages" />
<%
String pageNonce = formhandler.getNewNonce();
%>
<%@include file="formhandler.jsi" %>
<jsp:useBean class="net.i2p.router.web.HomeHelper" id="homehelper" scope="request" />
<jsp:setProperty name="homehelper" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />

View File

@@ -15,10 +15,7 @@
<%@include file="confignav.jsi" %>
<jsp:useBean class="net.i2p.router.web.ConfigKeyringHandler" id="formhandler" scope="request" />
<% formhandler.storeMethod(request.getMethod()); %>
<jsp:setProperty name="formhandler" property="*" />
<jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
<jsp:getProperty name="formhandler" property="allMessages" />
<%@include file="formhandler.jsi" %>
<jsp:useBean class="net.i2p.router.web.ConfigKeyringHelper" id="keyringhelper" scope="request" />
<jsp:setProperty name="keyringhelper" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
<div class="configure"><h2><%=intl._("Keyring")%></h2><p>
@@ -29,7 +26,7 @@
</div>
<form action="" method="POST">
<input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
<h3><%=intl._("Manual Keyring Addition")%></h3><p>
<%=intl._("Enter keys for encrypted remote destinations here.")%>
<%=intl._("Keys for local destinations must be entered on the")%> <a href="i2ptunnel/"><%=intl._("I2PTunnel page")%></a>.

View File

@@ -18,13 +18,10 @@
<%@include file="confignav.jsi" %>
<jsp:useBean class="net.i2p.router.web.ConfigLoggingHandler" id="formhandler" scope="request" />
<% formhandler.storeMethod(request.getMethod()); %>
<jsp:setProperty name="formhandler" property="*" />
<jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
<jsp:getProperty name="formhandler" property="allMessages" />
<%@include file="formhandler.jsi" %>
<div class="configure">
<form action="" method="POST">
<input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
<input type="hidden" name="action" value="blah" >
<h3><%=intl._("Configure I2P Logging Options")%></h3>
<div class="wideload">

View File

@@ -18,13 +18,10 @@
<%@include file="confignav.jsi" %>
<jsp:useBean class="net.i2p.router.web.ConfigNetHandler" id="formhandler" scope="request" />
<% formhandler.storeMethod(request.getMethod()); %>
<jsp:setProperty name="formhandler" property="*" />
<jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
<jsp:getProperty name="formhandler" property="allMessages" />
<%@include file="formhandler.jsi" %>
<div class="configure">
<form action="" method="POST">
<input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
<input type="hidden" name="action" value="blah" >
<h3><%=intl._("IP and Transport Configuration")%></h3><p>
<img src="/themes/console/images/itoopie_xsm.png" alt="">
@@ -207,7 +204,7 @@
<p>
This setting causes your router identity to be regenerated every time your IP address
changes. If you have a dynamic IP this option can speed up your reintegration into
the network (since people will have shitlisted your old router identity), and, for
the network (since people will have banned your old router identity), and, for
very weak adversaries, help frustrate trivial
<a href="http://www.i2p.net/how_threatmodel#intersection">intersection
attacks</a> against the NetDB. Your different router identities would only be

View File

@@ -15,13 +15,7 @@
<%@include file="confignav.jsi" %>
<jsp:useBean class="net.i2p.router.web.ConfigPeerHandler" id="formhandler" scope="request" />
<% formhandler.storeMethod(request.getMethod()); %>
<jsp:setProperty name="formhandler" property="*" />
<jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
<jsp:getProperty name="formhandler" property="allMessages" />
<%@include file="formhandler.jsi" %>
<jsp:useBean class="net.i2p.router.web.ConfigPeerHelper" id="peerhelper" scope="request" />
<jsp:setProperty name="peerhelper" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
@@ -31,7 +25,7 @@
%>
<div class="configure">
<form action="configpeer" method="POST">
<input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
<a name="sh"> </a>
<a name="unsh"> </a>
<a name="bonus"> </a>
@@ -61,11 +55,11 @@
<input type="text" size="8" name="capacity" value="<%=capacity%>" />
<input type="submit" name="action" class="add" value="<%=intl._("Adjust peer bonuses")%>" /></p></div>
</form>
<a name="shitlist"> </a><h2><%=intl._("Banned Peers")%></h2>
<a name="banlist"> </a><h2><%=intl._("Banned Peers")%></h2>
<jsp:useBean class="net.i2p.router.web.ProfilesHelper" id="profilesHelper" scope="request" />
<jsp:setProperty name="profilesHelper" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
<% profilesHelper.storeWriter(out); %>
<jsp:getProperty name="profilesHelper" property="shitlistSummary" />
<jsp:getProperty name="profilesHelper" property="banlistSummary" />
<div class="wideload"><h2><%=intl._("Banned IPs")%></h2>
<jsp:getProperty name="peerhelper" property="blocklistSummary" />

View File

@@ -18,14 +18,9 @@
<%@include file="confignav.jsi" %>
<jsp:useBean class="net.i2p.router.web.ConfigReseedHandler" id="formhandler" scope="request" />
<% formhandler.storeMethod(request.getMethod()); %>
<jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
<jsp:setProperty name="formhandler" property="action" value="<%=request.getParameter(\"action\")%>" />
<jsp:setProperty name="formhandler" property="nonce" value="<%=request.getParameter(\"nonce\")%>" />
<jsp:setProperty name="formhandler" property="settings" value="<%=request.getParameterMap()%>" />
<jsp:getProperty name="formhandler" property="allMessages" />
<%@include file="formhandler.jsi" %>
<div class="configure"><form action="" method="POST">
<input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
<h3><%=intl._("Reseeding Configuration")%></h3>
<p><%=intl._("Reseeding is the bootstrapping process used to find other routers when you first install I2P, or when your router has too few router references remaining.")%>
<%=intl._("If reseeding has failed, you should first check your network connection.")%>

View File

@@ -15,13 +15,10 @@
<%@include file="confignav.jsi" %>
<jsp:useBean class="net.i2p.router.web.ConfigServiceHandler" id="formhandler" scope="request" />
<% formhandler.storeMethod(request.getMethod()); %>
<jsp:setProperty name="formhandler" property="*" />
<jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
<jsp:getProperty name="formhandler" property="allMessages" />
<%@include file="formhandler.jsi" %>
<div class="configure">
<form action="" method="POST">
<input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
<h3><%=intl._("Shutdown the router")%></h3>
<p><%=intl._("Graceful shutdown lets the router satisfy the agreements it has already made before shutting down, but may take a few minutes.")%>
<%=intl._("If you need to kill the router immediately, that option is available as well.")%></p>

View File

@@ -22,17 +22,10 @@ input.default {
<%@include file="confignav.jsi" %>
<jsp:useBean class="net.i2p.router.web.ConfigSummaryHandler" id="formhandler" scope="request" />
<% formhandler.storeMethod(request.getMethod()); %>
<jsp:setProperty name="formhandler" property="*" />
<jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
<jsp:setProperty name="formhandler" property="settings" value="<%=request.getParameterMap()%>" />
<%@include file="formhandler.jsi" %>
<%
formhandler.setMovingAction();
%>
<jsp:getProperty name="formhandler" property="allMessages" />
<%
String pageNonce = formhandler.getNewNonce();
%>
<jsp:useBean class="net.i2p.router.web.SummaryHelper" id="summaryhelper" scope="request" />
<jsp:setProperty name="summaryhelper" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />

View File

@@ -66,17 +66,13 @@ function toggleAll(category)
<%@include file="confignav.jsi" %>
<jsp:useBean class="net.i2p.router.web.ConfigStatsHandler" id="formhandler" scope="request" />
<% formhandler.storeMethod(request.getMethod()); %>
<jsp:setProperty name="formhandler" property="*" />
<jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
<jsp:getProperty name="formhandler" property="allMessages" />
<%@include file="formhandler.jsi" %>
<jsp:useBean class="net.i2p.router.web.ConfigStatsHelper" id="statshelper" scope="request" />
<jsp:setProperty name="statshelper" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
<div class="configure">
<form id="statsForm" name="statsForm" action="" method="POST">
<input type="hidden" name="action" value="foo" >
<input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
<h3><%=intl._("Configure I2P Stat Collection")%></h3>
<p><%=intl._("Enable full stats?")%>
<input type="checkbox" class="optbox" name="isFull" value="true" <%
@@ -101,7 +97,7 @@ Warning - Log with care, stat file grows without limit.<br>
while (statshelper.groupRequired()) { %>
<tr class="tablefooter">
<td align="left" colspan="3" id=<%=statshelper.getCurrentGroupName()%>>
<b><%=statshelper.getCurrentGroupName()%></b>
<b><%=intl._(statshelper.getCurrentGroupName())%></b>
(<a href="javascript:void(null);" onclick="toggleAll('<%=statshelper.getCurrentGroupName()%>')"><%=intl._("toggle all")%></a>)
</td></tr>
<tr class="tablefooter">

View File

@@ -17,13 +17,7 @@
<div class="main" id="main">
<%@include file="confignav.jsi" %>
<jsp:useBean class="net.i2p.router.web.ConfigTunnelsHandler" id="formhandler" scope="request" />
<% formhandler.storeMethod(request.getMethod()); %>
<jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
<jsp:setProperty name="formhandler" property="shouldsave" value="<%=request.getParameter(\"shouldsave\")%>" />
<jsp:setProperty name="formhandler" property="action" value="<%=request.getParameter(\"action\")%>" />
<jsp:setProperty name="formhandler" property="nonce" value="<%=request.getParameter(\"nonce\")%>" />
<jsp:setProperty name="formhandler" property="settings" value="<%=request.getParameterMap()%>" />
<jsp:getProperty name="formhandler" property="allMessages" />
<%@include file="formhandler.jsi" %>
<div class="configure"><p>
<%=intl._("NOTE")%>:
<%=intl._("The default settings work for most people.")%>
@@ -33,7 +27,7 @@
<%=intl._("Change these settings with care, and adjust them if you have problems.")%>
<div class="wideload">
<form action="" method="POST">
<input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
<input type="hidden" name="action" value="blah" >
<jsp:getProperty name="tunnelshelper" property="form" />
<%=intl._("Note")%>: <%=intl._("Exploratory tunnel setting changes are stored in the router.config file.")%>

View File

@@ -6,6 +6,13 @@
<html><head>
<%@include file="css.jsi" %>
<%=intl.title("config UI")%>
<style type='text/css'>
input.default {
width: 1px;
height: 1px;
visibility: hidden;
}
</style>
<script src="/js/ajax.js" type="text/javascript"></script>
<%@include file="summaryajax.jsi" %>
</head><body onload="initAjax()">
@@ -21,10 +28,7 @@
<%@include file="confignav.jsi" %>
<jsp:useBean class="net.i2p.router.web.ConfigUIHandler" id="formhandler" scope="request" />
<% formhandler.storeMethod(request.getMethod()); %>
<jsp:setProperty name="formhandler" property="*" />
<jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
<jsp:getProperty name="formhandler" property="allMessages" />
<%@include file="formhandler.jsi" %>
<div class="configure"><div class="topshimten"><h3><%=uihelper._("Router Console Theme")%></h3></div>
<form action="" method="POST">
<%
@@ -36,7 +40,7 @@
}
%>
<input type="hidden" name="consoleNonce" value="<%=consoleNonce%>" >
<input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
<input type="hidden" name="action" value="blah" >
<%
String userAgent = request.getHeader("User-Agent");
@@ -54,5 +58,17 @@
</p><hr><div class="formaction">
<input type="reset" class="cancel" value="<%=intl._("Cancel")%>" >
<input type="submit" name="shouldsave" class="accept" value="<%=intl._("Apply")%>" >
</div></form></div>
</div></form>
<h3><%=uihelper._("Router Console Password")%></h3>
<form action="" method="POST">
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
<jsp:getProperty name="uihelper" property="passwordForm" />
<div class="formaction">
<input type="submit" name="action" class="default" value="<%=intl._("Add user")%>" >
<input type="submit" name="action" class="delete" value="<%=intl._("Delete selected")%>" >
<input type="reset" class="cancel" value="<%=intl._("Cancel")%>" >
<input type="submit" name="action" class="add" value="<%=intl._("Add user")%>" >
</div>
</form></div>
</div></body></html>

View File

@@ -16,17 +16,14 @@
<%@include file="confignav.jsi" %>
<jsp:useBean class="net.i2p.router.web.ConfigUpdateHandler" id="formhandler" scope="request" />
<% formhandler.storeMethod(request.getMethod()); %>
<jsp:setProperty name="formhandler" property="*" />
<jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
<jsp:getProperty name="formhandler" property="allMessages" />
<%@include file="formhandler.jsi" %>
<jsp:useBean class="net.i2p.router.web.ConfigUpdateHelper" id="updatehelper" scope="request" />
<jsp:setProperty name="updatehelper" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
<div class="messages">
<jsp:getProperty name="updatehelper" property="newsStatus" /></div>
<div class="configure">
<form action="" method="POST">
<input type="hidden" name="nonce" value="<jsp:getProperty name="formhandler" property="newNonce" />" >
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
<% /* set hidden default */ %>
<input type="submit" name="action" value="" style="display:none" >
<% if (updatehelper.canInstall()) { %>

View File

@@ -0,0 +1,43 @@
<%
/*
* Does the standard setup for all form handlers, then
* displays the message box (which drives the form processing).
*
* Included ~15 times, keep whitespace to a minimum
*
* Include this directly after the line:
* <jsp:useBean class="net.i2p.router.web.xxxHandler" id="formhandler" scope="request" />
*/
// This initializes the RouterContext - must be the first thing
formhandler.setContextId((String)session.getAttribute("i2p.contextId"));
// Prevents any saves via GET
formhandler.storeMethod(request.getMethod());
// Store the nonces for verification
String klass = formhandler.getClass().getName();
String nonceAttr1 = klass + ".nonce";
String nonceAttr2 = nonceAttr1 + "Prev";
String nonce1 = (String) session.getAttribute(nonceAttr1);
String nonce2 = (String) session.getAttribute(nonceAttr2);
formhandler.storeNonces(nonce1, nonce2);
// Put all the params in the map, some handlers use this instead of individual setters
// We also call all of the setters below.
formhandler.setSettings(request.getParameterMap());
%>
<jsp:setProperty name="formhandler" property="*" />
<jsp:getProperty name="formhandler" property="allMessages" />
<%
// Only call this once per page, do not getProperty("newNonce") elsewhere,
// use the variable instead.
// This shuffles down the nonces, so it must be after getAllMessages() above,
// since it does the form validation.
String pageNonce = formhandler.getNewNonce();
session.setAttribute(nonceAttr2, nonce1);
session.setAttribute(nonceAttr1, pageNonce);
%>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -15,8 +15,8 @@ msgid ""
msgstr ""
"Project-Id-Version: I2P\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-10-12 00:46+0000\n"
"PO-Revision-Date: 2012-10-12 00:44+0000\n"
"POT-Creation-Date: 2012-10-15 17:57+0000\n"
"PO-Revision-Date: 2012-10-12 00:50+0000\n"
"Last-Translator: BadCluster <badcluster@i2pmail.org>\n"
"Language-Team: Italian (http://www.transifex.com/projects/p/I2P/language/"
"it/)\n"
@@ -361,7 +361,7 @@ msgstr "Quanto è passato dall'inizio di questa connessione"
#: ../../../router/java/src/net/i2p/router/transport/TransportManager.java:540
#: ../../../router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java:756
#: ../../../router/java/src/net/i2p/router/transport/udp/UDPTransport.java:2188
#: ../java/src/net/i2p/router/web/SummaryHelper.java:835
#: ../java/src/net/i2p/router/web/SummaryHelper.java:836
msgid "Up"
msgstr "Su"
@@ -722,7 +722,7 @@ msgstr "Bannato"
#: ../../../router/java/src/net/i2p/router/transport/udp/UDPTransport.java:2310
msgid "backlogged"
msgstr ""
msgstr "ritardi"
#. buf.append("<tr><td colspan=\"16\"><hr></td></tr>\n");
#: ../../../router/java/src/net/i2p/router/transport/udp/UDPTransport.java:2390
@@ -2134,7 +2134,7 @@ msgstr "Cancella"
#: ../java/src/net/i2p/router/web/ConfigHomeHandler.java:25
#: ../java/src/net/i2p/router/web/ConfigSummaryHandler.java:26
#: ../java/src/net/i2p/router/web/SummaryHelper.java:855
#: ../java/src/net/i2p/router/web/SummaryHelper.java:856
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/confighome_jsp.java:419
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/confighome_jsp.java:439
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/confighome_jsp.java:455
@@ -2143,7 +2143,7 @@ msgstr "Elimina selezionati"
#: ../java/src/net/i2p/router/web/ConfigHomeHandler.java:26
#: ../java/src/net/i2p/router/web/ConfigSummaryHandler.java:27
#: ../java/src/net/i2p/router/web/SummaryHelper.java:874
#: ../java/src/net/i2p/router/web/SummaryHelper.java:875
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/confighome_jsp.java:417
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/confighome_jsp.java:425
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/confighome_jsp.java:437
@@ -2294,7 +2294,7 @@ msgstr "WARN"
#: ../java/src/net/i2p/router/web/ConfigLoggingHelper.java:88
#: ../java/src/net/i2p/router/web/HomeHelper.java:192
#: ../java/src/net/i2p/router/web/SummaryHelper.java:809
#: ../java/src/net/i2p/router/web/SummaryHelper.java:810
msgid "Remove"
msgstr "Rimuovi"
@@ -2448,12 +2448,12 @@ msgstr "Aggiornamento porta TCP a {0}"
#: ../java/src/net/i2p/router/web/ConfigNetHandler.java:224
#: ../java/src/net/i2p/router/web/ConfigNetHandler.java:249
msgid "Warning - ports less than 1024 are not recommended"
msgstr ""
msgstr "Attenzione - è meglio non utilizzare le porte da 0 a 1024!"
#: ../java/src/net/i2p/router/web/ConfigNetHandler.java:228
#: ../java/src/net/i2p/router/web/ConfigNetHandler.java:255
msgid "Invalid port"
msgstr ""
msgstr "Porta non valida"
#: ../java/src/net/i2p/router/web/ConfigNetHandler.java:233
msgid "Updating inbound TCP port to auto"
@@ -2462,7 +2462,7 @@ msgstr "Aggiornando le porte TCP entranti a automatiche"
#: ../java/src/net/i2p/router/web/ConfigNetHandler.java:247
#, java-format
msgid "Updating UDP port to {0}"
msgstr ""
msgstr "Aggiornamento porta UDP a {0}"
#: ../java/src/net/i2p/router/web/ConfigNetHandler.java:272
msgid "Gracefully restarting into Hidden Router Mode"
@@ -2502,7 +2502,7 @@ msgstr "Introduttori SSU richiesti"
#: ../java/src/net/i2p/router/web/ConfigNetHandler.java:369
msgid "Invalid address"
msgstr ""
msgstr "Indirizzo non valido"
#: ../java/src/net/i2p/router/web/ConfigNetHandler.java:374
#, java-format
@@ -2745,11 +2745,11 @@ msgstr "La console non verrà mostrata all'avvio"
#: ../java/src/net/i2p/router/web/ConfigServiceHandler.java:221
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configservice_jsp.java:457
msgid "Force GC"
msgstr ""
msgstr "Forza GC"
#: ../java/src/net/i2p/router/web/ConfigServiceHandler.java:223
msgid "Full garbage collection requested"
msgstr ""
msgstr "Richieste totali"
#: ../java/src/net/i2p/router/web/ConfigServiceHandler.java:232
msgid "Service installed"
@@ -3468,7 +3468,7 @@ msgstr ""
"Il tuo browser non è configurato correttamente per usare il proxy HTTP al {0}"
#: ../java/src/net/i2p/router/web/HomeHelper.java:194
#: ../java/src/net/i2p/router/web/SummaryHelper.java:811
#: ../java/src/net/i2p/router/web/SummaryHelper.java:812
msgid "Name"
msgstr "Nome"
@@ -3477,7 +3477,7 @@ msgid "URL"
msgstr "URL"
#: ../java/src/net/i2p/router/web/HomeHelper.java:214
#: ../java/src/net/i2p/router/web/SummaryHelper.java:857
#: ../java/src/net/i2p/router/web/SummaryHelper.java:858
msgid "Add"
msgstr "Aggiungi"
@@ -4135,37 +4135,37 @@ msgstr "Bannato fino al riavvio o in {0}"
msgid "unban now"
msgstr "riammissione istantanea"
#: ../java/src/net/i2p/router/web/StatSummarizer.java:314
#: ../java/src/net/i2p/router/web/StatSummarizer.java:312
msgid "Bandwidth usage"
msgstr "Utilizzo di larghezza di banda"
#: ../java/src/net/i2p/router/web/StatSummarizer.java:324
#: ../java/src/net/i2p/router/web/StatSummarizer.java:322
msgid "Outbound Bytes/sec"
msgstr "Bytes/s In Uscita"
#. def.line(sendName, Color.BLUE, "Outbound bytes/sec", 3);
#: ../java/src/net/i2p/router/web/StatSummarizer.java:326
#: ../java/src/net/i2p/router/web/StatSummarizer.java:324
msgid "Inbound Bytes/sec"
msgstr "Bytes/s In Entrata"
#: ../java/src/net/i2p/router/web/StatSummarizer.java:327
#: ../java/src/net/i2p/router/web/StatSummarizer.java:328
#: ../java/src/net/i2p/router/web/StatSummarizer.java:329
#: ../java/src/net/i2p/router/web/StatSummarizer.java:330
#: ../java/src/net/i2p/router/web/StatSummarizer.java:331
#: ../java/src/net/i2p/router/web/StatSummarizer.java:332
msgid "Bps"
msgstr "Bps"
#: ../java/src/net/i2p/router/web/StatSummarizer.java:329
#: ../java/src/net/i2p/router/web/StatSummarizer.java:327
msgid "Out average"
msgstr "Media In Uscita"
#: ../java/src/net/i2p/router/web/StatSummarizer.java:328
#: ../java/src/net/i2p/router/web/StatSummarizer.java:330
#: ../java/src/net/i2p/router/web/StatSummarizer.java:332
#: ../java/src/net/i2p/router/web/SummaryRenderer.java:155
msgid "max"
msgstr "massimo"
#: ../java/src/net/i2p/router/web/StatSummarizer.java:331
#: ../java/src/net/i2p/router/web/StatSummarizer.java:329
msgid "In average"
msgstr "Media In Entrata"
@@ -4678,13 +4678,13 @@ msgstr "Costruendo i tunnel"
#. 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
#: ../java/src/net/i2p/router/web/SummaryHelper.java:462
#: ../java/src/net/i2p/router/web/SummaryHelper.java:459
#: ../java/strings/Strings.java:36
msgid "shared clients"
msgstr "client condivisi"
#. Note to translators: parameter is a version, e.g. "0.8.4"
#: ../java/src/net/i2p/router/web/SummaryHelper.java:676
#: ../java/src/net/i2p/router/web/SummaryHelper.java:677
#, java-format
msgid "Download {0} Update"
msgstr "Scaricamento {0} Aggiornamento"
@@ -4692,40 +4692,40 @@ msgstr "Scaricamento {0} Aggiornamento"
#. 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>
#: ../java/src/net/i2p/router/web/SummaryHelper.java:684
#: ../java/src/net/i2p/router/web/SummaryHelper.java:685
#, java-format
msgid "Download Unsigned<br>Update {0}"
msgstr "Scaricamento Aggiornamento {0} Non Firmato<br>"
#: ../java/src/net/i2p/router/web/SummaryHelper.java:709
#: ../java/src/net/i2p/router/web/SummaryHelper.java:710
msgid "Help with firewall configuration"
msgstr "Aiuto con la configurazione del firewall"
#: ../java/src/net/i2p/router/web/SummaryHelper.java:711
#: ../java/src/net/i2p/router/web/SummaryHelper.java:712
msgid "Check network connection and NAT/firewall"
msgstr "Controlla la connessione di rete e il NAT/firewall"
#: ../java/src/net/i2p/router/web/SummaryHelper.java:730
#: ../java/src/net/i2p/router/web/SummaryHelper.java:731
msgid "Reseed"
msgstr "Reseed"
#: ../java/src/net/i2p/router/web/SummaryHelper.java:813
#: ../java/src/net/i2p/router/web/SummaryHelper.java:814
msgid "Order"
msgstr "Ordine"
#: ../java/src/net/i2p/router/web/SummaryHelper.java:830
#: ../java/src/net/i2p/router/web/SummaryHelper.java:831
msgid "Top"
msgstr "Sopra"
#: ../java/src/net/i2p/router/web/SummaryHelper.java:843
#: ../java/src/net/i2p/router/web/SummaryHelper.java:844
msgid "Down"
msgstr "Sotto"
#: ../java/src/net/i2p/router/web/SummaryHelper.java:848
#: ../java/src/net/i2p/router/web/SummaryHelper.java:849
msgid "Bottom"
msgstr "Basso"
#: ../java/src/net/i2p/router/web/SummaryHelper.java:860
#: ../java/src/net/i2p/router/web/SummaryHelper.java:861
msgid "Select a section to add"
msgstr "Seleziona una sezione da aggiungere"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff