diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigNavHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigNavHelper.java index c97647fc9..cdc7caeb7 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigNavHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigNavHelper.java @@ -12,12 +12,12 @@ public class ConfigNavHelper extends HelperBase { private static final String pages[] = {"", "ui", "service", "update", "tunnels", "clients", "peer", "keyring", "logging", "stats", - "advanced" }; + "reseed", "advanced" }; private static final String titles[] = {_x("Network"), _x("UI"), _x("Service"), _x("Update"), _x("Tunnels"), _x("Clients"), _x("Peers"), _x("Keyring"), _x("Logging"), _x("Stats"), - _x("Advanced") }; + _x("Reseeding"), _x("Advanced") }; public void renderNavBar(String requestURI) throws IOException { StringBuilder buf = new StringBuilder(1024); diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigReseedHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigReseedHandler.java new file mode 100644 index 000000000..1e07d9d24 --- /dev/null +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigReseedHandler.java @@ -0,0 +1,68 @@ +package net.i2p.router.web; + +import java.util.HashMap; +import java.util.Map; + +import net.i2p.router.networkdb.reseed.Reseeder; + +/** + * @since 0.8.3 + */ +public class ConfigReseedHandler extends FormHandler { + private Map _settings; + + @Override + protected void processForm() { + + if (_action.equals(_("Save Configuration and Reseed Now"))) { + saveChanges(); + boolean reseedInProgress = Boolean.valueOf(System.getProperty("net.i2p.router.web.ReseedHandler.reseedInProgress")).booleanValue(); + if (reseedInProgress) { + addFormError(_("Reseeding is already in progress")); + } else { + // skip the nonce checking in ReseedHandler + addFormNotice(_("Starting reseed process")); + (new ReseedHandler(_context)).requestReseed(); + } + return; + } + if (_action.equals(_("Save Configuration"))) { + saveChanges(); + return; + } + 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(); + } + + private void saveChanges() { + String port = getJettyString("port"); + if (port != null) + _context.router().setConfigSetting(Reseeder.PROP_PROXY_PORT, port); + String host = getJettyString("host"); + if (host != null) + _context.router().setConfigSetting(Reseeder.PROP_PROXY_HOST, host); + String url = getJettyString("reseedURL"); + if (url != null) + _context.router().setConfigSetting(Reseeder.PROP_RESEED_URL, url.trim().replace("\r\n", ",").replace("\n", ",")); + String mode = getJettyString("mode"); + boolean req = "1".equals(mode); + boolean disabled = "2".equals(mode); + _context.router().setConfigSetting(Reseeder.PROP_SSL_REQUIRED, + Boolean.toString(req)); + _context.router().setConfigSetting(Reseeder.PROP_SSL_DISABLE, + Boolean.toString(disabled)); + boolean proxy = getJettyString("enable") != null; + _context.router().setConfigSetting(Reseeder.PROP_PROXY_ENABLE, Boolean.toString(proxy)); + _context.router().saveConfig(); + addFormNotice(_("Configuration saved successfully.")); + } +} diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigReseedHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigReseedHelper.java new file mode 100644 index 000000000..ec5337cc5 --- /dev/null +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigReseedHelper.java @@ -0,0 +1,58 @@ +package net.i2p.router.web; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.StringTokenizer; + +import net.i2p.router.networkdb.reseed.Reseeder; + +/** + * @since 0.8.3 + */ +public class ConfigReseedHelper extends HelperBase { + + public String getPort() { + return _context.getProperty(Reseeder.PROP_PROXY_PORT, ""); + } + + public String getHost() { + return _context.getProperty(Reseeder.PROP_PROXY_HOST, ""); + } + + public String modeChecked(int mode) { + boolean required = _context.getBooleanProperty(Reseeder.PROP_SSL_REQUIRED); + boolean disabled = _context.getBooleanProperty(Reseeder.PROP_SSL_DISABLE); + if ((mode == 0 && (!disabled) && (!required)) || + (mode == 1 && (!disabled) && required) || + (mode == 2 && disabled)) + return "checked=\"true\""; + return ""; + } + + public String getEnable() { + boolean enabled = _context.getBooleanProperty(Reseeder.PROP_PROXY_ENABLE); + if (enabled) + return "checked=\"true\""; + return ""; + } + + public String getReseedURL() { + String urls = _context.getProperty(Reseeder.PROP_RESEED_URL, Reseeder.DEFAULT_SEED_URL + ',' + Reseeder.DEFAULT_SSL_SEED_URL); + StringTokenizer tok = new StringTokenizer(urls, " ,\r\n"); + List URLList = new ArrayList(16); + while (tok.hasMoreTokens()) { + String s = tok.nextToken().trim(); + if (s.length() > 0) + URLList.add(s); + } + Collections.sort(URLList); + StringBuilder buf = new StringBuilder(); + for (String s : URLList) { + if (buf.length() > 0) + buf.append('\n'); + buf.append(s); + } + return buf.toString(); + } +} diff --git a/apps/routerconsole/jsp/configreseed.jsp b/apps/routerconsole/jsp/configreseed.jsp new file mode 100644 index 000000000..1aedb4f53 --- /dev/null +++ b/apps/routerconsole/jsp/configreseed.jsp @@ -0,0 +1,59 @@ +<%@page contentType="text/html"%> +<%@page pageEncoding="UTF-8"%> + + + +<%@include file="css.jsi" %> +<%=intl.title("config reseeding")%> + + +<%@include file="summary.jsi" %> + + +" /> +

<%=intl._("I2P Reseeding Configuration")%>

+
+<%@include file="confignav.jsi" %> + + +<% formhandler.storeMethod(request.getMethod()); %> +" /> +" /> +" /> + + +
+<% String prev = System.getProperty("net.i2p.router.web.ConfigReseedHandler.nonce"); + if (prev != null) System.setProperty("net.i2p.router.web.ConfigReseedHandler.noncePrev", prev); + System.setProperty("net.i2p.router.web.ConfigReseedHandler.nonce", new java.util.Random().nextLong()+""); %> +" > +

<%=intl._("Reseeding Configuration")%>

+

<%=intl._("Reeseeding 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.")%> +

<%=intl._("The default settings will work for most people.")%> +<%=intl._("Change these only if HTTP is blocked by a restrictive firewall, reseed has failed, and you have access to an HTTP proxy.")%> +<%=intl._("See {0} for instructions on reseeding manually.", "" + intl._("the FAQ") + "")%> +

+
+ + + + + + + + + + + +
<%=intl._("Reseed URL Selection")%> > +<%=intl._("Try SSL first then non-SSL")%> + > +<%=intl._("Use SSL only")%> + > +<%=intl._("Use non-SSL only")%>
<%=intl._("Reseed URLs")%>
<%=intl._("Enable HTTP proxy (not used for SSL)")%> >
<%=intl._("HTTP Proxy Host")%>:" >
<%=intl._("HTTP Proxy Port")%>:" >
+
+" /> +" /> +" /> +
diff --git a/history.txt b/history.txt index 97bb2ea54..7f59ca67d 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,9 @@ +2010-12-29 zzz + * Console: Add 500 error page + * Reseed: + - Add new configreseed page + - Add StartCom CA cert required for www.i2pbote.net + 2010-12-27 zzz * Crypto: Cleanups and fixups * Console: diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 282c18b42..0725033fa 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 2; + public final static long BUILD = 3; /** for example "-test" */ public final static String EXTRA = ""; diff --git a/router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java b/router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java index cecec359d..4f225ec97 100644 --- a/router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java +++ b/router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java @@ -40,12 +40,12 @@ public class Reseeder { // Reject unreasonably big files, because we download into a ByteArrayOutputStream. private static final long MAX_RESEED_RESPONSE_SIZE = 1024 * 1024; - private static final String DEFAULT_SEED_URL = + public static final String DEFAULT_SEED_URL = "http://a.netdb.i2p2.de/,http://b.netdb.i2p2.de/,http://c.netdb.i2p2.de/," + "http://reseed.i2p-projekt.de/,http://www.i2pbote.net/netDb/,http://r31453.ovh.net/static_media/files/netDb/"; /** @since 0.8.2 */ - private static final String DEFAULT_SSL_SEED_URL = + public static final String DEFAULT_SSL_SEED_URL = "https://a.netdb.i2p2.de/,https://c.netdb.i2p2.de/," + "https://www.i2pbote.net/netDb/," + "https://r31453.ovh.net/static_media/files/netDb/"; @@ -63,11 +63,8 @@ public class Reseeder { public static final String PROP_SSL_DISABLE = "router.reseedSSLDisable"; /** @since 0.8.2 */ public static final String PROP_SSL_REQUIRED = "router.reseedSSLRequired"; - - private static final String RESEED_TIPS = - _x("Ensure that nothing blocks outbound HTTP, check logs " + - "and if nothing helps, read the FAQ about reseeding manually."); - + /** @since 0.8.3 */ + public static final String PROP_RESEED_URL = "i2p.reseedURL"; public Reseeder(RouterContext ctx) { _context = ctx; @@ -128,7 +125,9 @@ public class Reseeder { System.out.println( "Ensure that nothing blocks outbound HTTP, check the logs, " + "and if nothing helps, read the FAQ about reseeding manually."); - System.setProperty(PROP_ERROR, _("Reseed failed.") + ' ' + _(RESEED_TIPS)); + System.setProperty(PROP_ERROR, _("Reseed failed.") + ' ' + + _("See {0} for help.", + "" + _("reseed configuration page") + "")); } System.setProperty(PROP_INPROGRESS, "false"); System.clearProperty(PROP_STATUS); @@ -165,7 +164,7 @@ public class Reseeder { */ private int reseed(boolean echoStatus) { List URLList = new ArrayList(); - String URLs = _context.getProperty("i2p.reseedURL"); + String URLs = _context.getProperty(PROP_RESEED_URL); boolean defaulted = URLs == null; boolean SSLDisable = _context.getBooleanProperty(PROP_SSL_DISABLE); if (defaulted) { @@ -369,6 +368,11 @@ public class Reseeder { return Translate.getString(key, _context, BUNDLE_NAME); } + /** translate */ + private String _(String s, Object o) { + return Translate.getString(s, o, _context, BUNDLE_NAME); + } + /** translate */ private String _(String s, Object o, Object o2) { return Translate.getString(s, o, o2, _context, BUNDLE_NAME);