From 0cfbe9c28bee462f0daf137cc262332c6c85a5d4 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Wed, 8 Apr 2009 01:34:12 +0000 Subject: [PATCH] * IPV6/localhost: - Enable IPv6 stack in the JVM, hopefully won't break anything - Patch Jetty to support binding to IPv6 addresses - Allow multiple bind addresses for the router console in the clients.config file; for new installs the default is now "127.0.0.1,::1" - Change most instances of "localhost" to "127.0.0.1" throughout the code * Router: - Move some classes to private static inner --- .../java/src/addressbook/Daemon.java | 2 +- .../src/org/klomp/snark/SnarkManager.java | 4 +- .../src/net/i2p/i2ptunnel/web/EditBean.java | 2 +- .../src/org/mortbay/util/InetAddrPort.java | 253 ++++++++++++++++++ .../streaming/I2PSocketManagerFactory.java | 2 +- .../i2p/router/web/ConfigServiceHandler.java | 2 +- .../i2p/router/web/ConfigUpdateHandler.java | 2 +- .../i2p/router/web/RouterConsoleRunner.java | 35 ++- apps/routerconsole/jsp/configservice.jsp | 2 +- apps/routerconsole/jsp/nav.jsp | 2 +- .../src/src/i2p/susi/webmail/WebMail.java | 2 +- .../src/net/i2p/apps/systray/SysTray.java | 4 +- .../src/net/i2p/apps/systray/UrlLauncher.java | 2 +- .../src/net/i2p/client/I2PSessionImpl.java | 2 +- core/java/src/net/i2p/util/EepGet.java | 8 +- .../resources/ahelper-conflict-header.ht | 6 +- installer/resources/clients.config | 6 +- installer/resources/dnf-header.ht | 6 +- installer/resources/dnfb-header.ht | 6 +- installer/resources/dnfh-header.ht | 10 +- installer/resources/dnfp-header.ht | 10 +- installer/resources/eepsite_index.html | 20 +- installer/resources/startconsole.html | 4 +- router/java/src/net/i2p/router/Router.java | 20 +- 24 files changed, 349 insertions(+), 63 deletions(-) create mode 100644 apps/jetty/java/src/org/mortbay/util/InetAddrPort.java diff --git a/apps/addressbook/java/src/addressbook/Daemon.java b/apps/addressbook/java/src/addressbook/Daemon.java index 7b690eb172..a1b1ae18a3 100644 --- a/apps/addressbook/java/src/addressbook/Daemon.java +++ b/apps/addressbook/java/src/addressbook/Daemon.java @@ -133,7 +133,7 @@ public class Daemon { } Map defaultSettings = new HashMap(); - defaultSettings.put("proxy_host", "localhost"); + defaultSettings.put("proxy_host", "127.0.0.1"); defaultSettings.put("proxy_port", "4444"); defaultSettings.put("master_addressbook", "../userhosts.txt"); defaultSettings.put("router_addressbook", "../hosts.txt"); diff --git a/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java b/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java index 01a93a58c1..60c44f3d59 100644 --- a/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java +++ b/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java @@ -135,13 +135,13 @@ public class SnarkManager implements Snark.CompleteListener { } // now add sane defaults if (!_config.containsKey(PROP_I2CP_HOST)) - _config.setProperty(PROP_I2CP_HOST, "localhost"); + _config.setProperty(PROP_I2CP_HOST, "127.0.0.1"); if (!_config.containsKey(PROP_I2CP_PORT)) _config.setProperty(PROP_I2CP_PORT, "7654"); if (!_config.containsKey(PROP_I2CP_OPTS)) _config.setProperty(PROP_I2CP_OPTS, "inbound.length=2 inbound.lengthVariance=0 outbound.length=2 outbound.lengthVariance=0 inbound.quantity=3 outbound.quantity=3"); if (!_config.containsKey(PROP_EEP_HOST)) - _config.setProperty(PROP_EEP_HOST, "localhost"); + _config.setProperty(PROP_EEP_HOST, "127.0.0.1"); if (!_config.containsKey(PROP_EEP_PORT)) _config.setProperty(PROP_EEP_PORT, "4444"); if (!_config.containsKey(PROP_UPLOADERS_TOTAL)) diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java index 004114b568..0a909c62ec 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java @@ -206,7 +206,7 @@ public class EditBean extends IndexBean { if (tun != null) return tun.getI2CPHost(); else - return "localhost"; + return "127.0.0.1"; } public String getI2CPPort(int tunnel) { diff --git a/apps/jetty/java/src/org/mortbay/util/InetAddrPort.java b/apps/jetty/java/src/org/mortbay/util/InetAddrPort.java new file mode 100644 index 0000000000..7f0968798c --- /dev/null +++ b/apps/jetty/java/src/org/mortbay/util/InetAddrPort.java @@ -0,0 +1,253 @@ +// ======================================================================== +// $Id: InetAddrPort.java,v 1.7 2004/10/23 09:03:22 gregwilkins Exp $ +// Copyright 1996-2004 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ======================================================================== + +package org.mortbay.util; + +import java.io.Serializable; +import java.net.InetAddress; + +/* ======================================================================== */ +/** InetAddress and Port. + */ +public class InetAddrPort implements Serializable +{ + /* ------------------------------------------------------------ */ + public final static String __0_0_0_0 = "0.0.0.0"; + + /* ------------------------------------------------------------ */ + private InetAddress _addr=null; + private boolean _addrIsHost=false; + private int _port=0; + + /* ------------------------------------------------------------------- */ + public InetAddrPort() + {} + + /* ------------------------------------------------------------ */ + /** Constructor for a port on all local host address. + * @param port + */ + public InetAddrPort(int port) + { + _port=port; + } + + /* ------------------------------------------------------------ */ + /** Constructor. + * @param addr + * @param port + */ + public InetAddrPort(InetAddress addr, int port) + { + _addr=addr; + _port=port; + } + + /* ------------------------------------------------------------ */ + /** Constructor. + * @param host + * @param port + */ + public InetAddrPort(String host, int port) + throws java.net.UnknownHostException + { + setHost(host); + setPort(port); + } + + /* ------------------------------------------------------------ */ + /** Constructor. + * Patched to support [::1]:port for I2P + * + * @param inetAddrPort String of the form "addr:port" + */ + public InetAddrPort(String inetAddrPort) + throws java.net.UnknownHostException + { + int b = inetAddrPort.indexOf('['); + if (b>0) + throw new java.net.UnknownHostException("Bad [] syntax"); + if (b==0) // IPV6 + { + int b2 = inetAddrPort.indexOf(']'); + if (b2<2) + throw new java.net.UnknownHostException("Bad [] syntax"); + String addr=inetAddrPort.substring(1,b2); + if (addr.indexOf('/')>0) + addr=addr.substring(addr.indexOf('/')+1); + inetAddrPort=inetAddrPort.substring(b2+1); + int c = inetAddrPort.indexOf(':'); + if (c>0) + throw new java.net.UnknownHostException("Bad [] syntax"); + if (c==0) + inetAddrPort=inetAddrPort.substring(1); + + if (addr.length()>0 && ! __0_0_0_0.equals(addr)) + { + _addrIsHost=!Character.isDigit((addr.charAt(0))); + this._addr=InetAddress.getByName(addr); + } + } else { // IPV4 + int c = inetAddrPort.indexOf(':'); + if (c>=0) + { + String addr=inetAddrPort.substring(0,c); + if (addr.indexOf('/')>0) + addr=addr.substring(addr.indexOf('/')+1); + inetAddrPort=inetAddrPort.substring(c+1); + + if (addr.length()>0 && ! __0_0_0_0.equals(addr)) + { + _addrIsHost=!Character.isDigit((addr.charAt(0))); + this._addr=InetAddress.getByName(addr); + } + } + } + + _port = Integer.parseInt(inetAddrPort); + } + + /* ------------------------------------------------------------ */ + /** Constructor. + * @param address InetAddrPort top copy. + */ + public InetAddrPort(InetAddrPort address) + { + if (address!=null) + { + _addr=address._addr; + _port=address._port; + } + } + + /* ------------------------------------------------------------ */ + /** Get the Host. + * @return The IP address + */ + public String getHost() + { + if (_addr==null) + return __0_0_0_0; + + return _addrIsHost?_addr.getHostName():_addr.getHostAddress(); + } + + /* ------------------------------------------------------------ */ + /** Set the Host. + * @param host + * @exception java.net.UnknownHostException + */ + public void setHost(String host) + throws java.net.UnknownHostException + { + _addr=null; + if (host!=null) + { + if (host.indexOf('/')>0) + host=host.substring(0,host.indexOf('/')); + _addrIsHost=!Character.isDigit((host.charAt(0))); + _addr=InetAddress.getByName(host); + } + } + + /* ------------------------------------------------------------ */ + /** Get the IP address. + * @return The IP address + */ + public InetAddress getInetAddress() + { + return _addr; + } + + /* ------------------------------------------------------------ */ + /** Set the IP address. + * @param addr The IP address + */ + public void setInetAddress(InetAddress addr) + { + _addrIsHost=false; + _addr=addr; + } + + /* ------------------------------------------------------------ */ + /** Get the port. + * @return The port number + */ + public int getPort() + { + return _port; + } + + /* ------------------------------------------------------------ */ + /** Set the port. + * @param port The port number + */ + public void setPort(int port) + { + _port=port; + } + + + /* ------------------------------------------------------------------- */ + public String toString() + { + return getHost()+':'+_port; + } + + /* ------------------------------------------------------------ */ + /** Clone the InetAddrPort. + * @return A new instance. + */ + public Object clone() + { + return new InetAddrPort(this); + } + + /* ------------------------------------------------------------ */ + /** Hash Code. + * @return hash Code. + */ + public int hashCode() + { + return _port+((_addr==null)?0:_addr.hashCode()); + } + + /* ------------------------------------------------------------ */ + /** Equals. + * @param o + * @return True if is the same address and port. + */ + public boolean equals(Object o) + { + if (o==null) + return false; + if (o==this) + return true; + if (o instanceof InetAddrPort) + { + InetAddrPort addr=(InetAddrPort)o; + return addr._port==_port && + ( addr._addr==_addr || + addr._addr!=null && addr._addr.equals(_addr)); + } + return false; + } +} + + + + + + diff --git a/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManagerFactory.java b/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManagerFactory.java index 33477a4a80..0370ab16be 100644 --- a/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManagerFactory.java +++ b/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManagerFactory.java @@ -196,7 +196,7 @@ public class I2PSocketManagerFactory { } private static String getHost() { - return System.getProperty(I2PClient.PROP_TCP_HOST, "localhost"); + return System.getProperty(I2PClient.PROP_TCP_HOST, "127.0.0.1"); } private static int getPort() { int i2cpPort = 7654; diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigServiceHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigServiceHandler.java index 8d3e5725ce..0dc4d1e62b 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigServiceHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigServiceHandler.java @@ -155,7 +155,7 @@ 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://localhost:7657", 5, false); + ClientAppConfig ca = new ClientAppConfig(UrlLauncher.class.getName(), "consoleBrowser", "http://127.0.0.1:7657", 5, false); clients.add(ca); } ClientAppConfig.writeClientAppConfig(_context, clients); diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHandler.java index 3c6e1692c7..1729a209be 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHandler.java @@ -27,7 +27,7 @@ public class ConfigUpdateHandler extends FormHandler { public static final String PROP_SHOULD_PROXY = "router.updateThroughProxy"; public static final String DEFAULT_SHOULD_PROXY = Boolean.TRUE.toString(); public static final String PROP_PROXY_HOST = "router.updateProxyHost"; - public static final String DEFAULT_PROXY_HOST = "localhost"; + public static final String DEFAULT_PROXY_HOST = "127.0.0.1"; public static final String PROP_PROXY_PORT = "router.updateProxyPort"; public static final String DEFAULT_PROXY_PORT = "4444"; diff --git a/apps/routerconsole/java/src/net/i2p/router/web/RouterConsoleRunner.java b/apps/routerconsole/java/src/net/i2p/router/web/RouterConsoleRunner.java index ae11e55fbf..862902b1f8 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/RouterConsoleRunner.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/RouterConsoleRunner.java @@ -5,6 +5,7 @@ import java.io.FilenameFilter; import java.io.IOException; import java.util.List; import java.util.Properties; +import java.util.StringTokenizer; import net.i2p.I2PAppContext; import net.i2p.apps.systray.SysTray; @@ -36,6 +37,14 @@ public class RouterConsoleRunner { System.setProperty("java.awt.headless", "true"); } + /** + * @param args second arg may be a comma-separated list of bind addresses, + * for example ::1,127.0.0.1 + * On XP, the other order (127.0.0.1,::1) fails the IPV6 bind, + * because 127.0.0.1 will bind ::1 also. But even though it's bound + * 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[]) { if (args.length == 3) { _listenPort = args[0].trim(); @@ -66,7 +75,24 @@ public class RouterConsoleRunner { rewrite = true; } try { - _server.addListener(_listenHost + ':' + _listenPort); + StringTokenizer tok = new StringTokenizer(_listenHost, " ,"); + int boundAddresses = 0; + while (tok.hasMoreTokens()) { + String host = tok.nextToken().trim(); + try { + if (host.indexOf(":") >= 0) // IPV6 - requires patched Jetty 5 + _server.addListener('[' + host + "]:" + _listenPort); + else + _server.addListener(host + ':' + _listenPort); + boundAddresses++; + } catch (IOException ioe) { // this doesn't seem to work, exceptions don't happen until start() below + System.err.println("Unable to bind routerconsole to " + host + " port " + _listenPort + ' ' + ioe); + } + } + if (boundAddresses <= 0) { + System.err.println("Unable to bind routerconsole to any address on port " + _listenPort); + return; + } _server.setRootWebApp(ROUTERCONSOLE); WebApplicationContext wac = _server.addWebApplication("/", _webAppsDir + ROUTERCONSOLE + ".war"); initialize(wac); @@ -100,7 +126,12 @@ public class RouterConsoleRunner { try { _server.start(); } catch (Exception me) { - me.printStackTrace(); + 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" + + "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.\n" + + "Exception: " + me); } try { SysTray tray = SysTray.getInstance(); diff --git a/apps/routerconsole/jsp/configservice.jsp b/apps/routerconsole/jsp/configservice.jsp index 59dfc3e755..4a720afeeb 100644 --- a/apps/routerconsole/jsp/configservice.jsp +++ b/apps/routerconsole/jsp/configservice.jsp @@ -71,7 +71,7 @@ <h4>Launch browser on router startup?</h4> <p>I2P's main configuration interface is this web console, so for your convenience I2P can launch a web browser pointing at - <a href="http://localhost:7657/index.jsp">http://localhost:7657/index.jsp</a> whenever + <a href="http://127.0.0.1:7657/index.jsp">http://127.0.0.1:7657/index.jsp</a> whenever the router starts up.</p> <input type="submit" name="action" value="View console on startup" /> <input type="submit" name="action" value="Do not view console on startup" /> diff --git a/apps/routerconsole/jsp/nav.jsp b/apps/routerconsole/jsp/nav.jsp index 22bb8ec245..914371c78d 100644 --- a/apps/routerconsole/jsp/nav.jsp +++ b/apps/routerconsole/jsp/nav.jsp @@ -25,7 +25,7 @@ <a href="susidns/index.jsp">SusiDNS</a> | <!-- <a href="syndie/">Syndie</a> | --> <a href="i2psnark/">I2PSnark</a> | - <a href="http://localhost:7658/">My Eepsite</a> <br> + <a href="http://127.0.0.1:7658/">My Eepsite</a> <br> <a href="i2ptunnel/index.jsp">I2PTunnel</a> | <a href="tunnels.jsp">Tunnels</a> | <a href="profiles.jsp">Profiles</a> | diff --git a/apps/susimail/src/src/i2p/susi/webmail/WebMail.java b/apps/susimail/src/src/i2p/susi/webmail/WebMail.java index a80fdc5914..6e9fad1c5e 100644 --- a/apps/susimail/src/src/i2p/susi/webmail/WebMail.java +++ b/apps/susimail/src/src/i2p/susi/webmail/WebMail.java @@ -76,7 +76,7 @@ public class WebMail extends HttpServlet private static final int BUFSIZE = 4096; - private static final String DEFAULT_HOST = "localhost"; + private static final String DEFAULT_HOST = "127.0.0.1"; private static final int DEFAULT_POP3PORT = 7660; private static final int DEFAULT_SMTPPORT = 7659; diff --git a/apps/systray/java/src/net/i2p/apps/systray/SysTray.java b/apps/systray/java/src/net/i2p/apps/systray/SysTray.java index 4a635fd080..652ff66771 100644 --- a/apps/systray/java/src/net/i2p/apps/systray/SysTray.java +++ b/apps/systray/java/src/net/i2p/apps/systray/SysTray.java @@ -132,7 +132,7 @@ public class SysTray implements SysTrayMenuListener { public void iconLeftClicked(SysTrayMenuEvent e) {} public void iconLeftDoubleClicked(SysTrayMenuEvent e) { - openRouterConsole("http://localhost:" + _portString + "/index.jsp"); + openRouterConsole("http://127.0.0.1:" + _portString + "/index.jsp"); } public void menuItemSelected(SysTrayMenuEvent e) { @@ -153,7 +153,7 @@ public class SysTray implements SysTrayMenuListener { if (!(browser = promptForBrowser("Select browser")).equals("nullnull")) setBrowser(browser); } else if (e.getActionCommand().equals("openconsole")) { - openRouterConsole("http://localhost:" + _portString + "/index.jsp"); + openRouterConsole("http://127.0.0.1:" + _portString + "/index.jsp"); } } diff --git a/apps/systray/java/src/net/i2p/apps/systray/UrlLauncher.java b/apps/systray/java/src/net/i2p/apps/systray/UrlLauncher.java index 5487f5faf5..c7524054e7 100644 --- a/apps/systray/java/src/net/i2p/apps/systray/UrlLauncher.java +++ b/apps/systray/java/src/net/i2p/apps/systray/UrlLauncher.java @@ -163,7 +163,7 @@ public class UrlLauncher { if (args.length > 0) launcher.openUrl(args[0]); else - launcher.openUrl("http://localhost:7657/index.jsp"); + launcher.openUrl("http://127.0.0.1:7657/index.jsp"); } catch (Exception e) {} } } diff --git a/core/java/src/net/i2p/client/I2PSessionImpl.java b/core/java/src/net/i2p/client/I2PSessionImpl.java index 5b7603fdd6..9e42eef5fa 100644 --- a/core/java/src/net/i2p/client/I2PSessionImpl.java +++ b/core/java/src/net/i2p/client/I2PSessionImpl.java @@ -162,7 +162,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa protected void loadConfig(Properties options) { _options = new Properties(); _options.putAll(filter(options)); - _hostname = _options.getProperty(I2PClient.PROP_TCP_HOST, "localhost"); + _hostname = _options.getProperty(I2PClient.PROP_TCP_HOST, "127.0.0.1"); String portNum = _options.getProperty(I2PClient.PROP_TCP_PORT, LISTEN_PORT + ""); try { _portNum = Integer.parseInt(portNum); diff --git a/core/java/src/net/i2p/util/EepGet.java b/core/java/src/net/i2p/util/EepGet.java index 4abdc6fd4d..5f0e8d5e9f 100644 --- a/core/java/src/net/i2p/util/EepGet.java +++ b/core/java/src/net/i2p/util/EepGet.java @@ -18,7 +18,7 @@ import net.i2p.I2PAppContext; import net.i2p.data.DataHelper; /** - * EepGet [-p localhost:4444] + * EepGet [-p 127.0.0.1:4444] * [-n #retries] * [-o outputFile] * [-m markSize lineLen] @@ -123,11 +123,11 @@ public class EepGet { } /** - * EepGet [-p localhost:4444] [-n #retries] [-e etag] [-o outputFile] [-m markSize lineLen] url + * EepGet [-p 127.0.0.1:4444] [-n #retries] [-e etag] [-o outputFile] [-m markSize lineLen] url * */ public static void main(String args[]) { - String proxyHost = "localhost"; + String proxyHost = "127.0.0.1"; int proxyPort = 4444; int numRetries = 5; int markSize = 1024; @@ -212,7 +212,7 @@ public class EepGet { } private static void usage() { - System.err.println("EepGet [-p localhost:4444] [-n #retries] [-o outputFile] [-m markSize lineLen] [-t timeout] url"); + System.err.println("EepGet [-p 127.0.0.1:4444] [-n #retries] [-o outputFile] [-m markSize lineLen] [-t timeout] url"); } public static interface StatusListener { diff --git a/installer/resources/ahelper-conflict-header.ht b/installer/resources/ahelper-conflict-header.ht index 3b80e582fe..7f34d21cc3 100644 --- a/installer/resources/ahelper-conflict-header.ht +++ b/installer/resources/ahelper-conflict-header.ht @@ -6,7 +6,7 @@ Proxy-Connection: close <html><head> <title>Destination key conflict</title> -<link rel="shortcut icon" href="http://localhost:7657/favicon.ico" /> +<link rel="shortcut icon" href="http://127.0.0.1:7657/favicon.ico" /> <style type='text/css'> div.warning { margin: 0em 1em 1em 224px; @@ -32,8 +32,8 @@ div.logo { </head> <body> <div class=logo> - <a href="http://localhost:7657/index.jsp" title="Router Console"><img src="http://localhost:7657/i2plogo.png" alt="Router Console" width="187" height="35" border="0"/></a><br /> - [<a href="http://localhost:7657/config.jsp">configuration</a> | <a href="http://localhost:7657/help.jsp">help</a>] + <a href="http://127.0.0.1:7657/index.jsp" title="Router Console"><img src="http://127.0.0.1:7657/i2plogo.png" alt="Router Console" width="187" height="35" border="0"/></a><br /> + [<a href="http://127.0.0.1:7657/config.jsp">configuration</a> | <a href="http://127.0.0.1:7657/help.jsp">help</a>] </div> <div class=warning id=warning> The addresshelper link you followed specifies a different destination key diff --git a/installer/resources/clients.config b/installer/resources/clients.config index 5245e3bfc1..9d0c1b583e 100644 --- a/installer/resources/clients.config +++ b/installer/resources/clients.config @@ -1,5 +1,5 @@ # fire up the web console -clientApp.0.args=7657 127.0.0.1 ./webapps/ +clientApp.0.args=7657 ::1,127.0.0.1 ./webapps/ clientApp.0.main=net.i2p.router.web.RouterConsoleRunner clientApp.0.name=webConsole clientApp.0.onBoot=true @@ -8,7 +8,7 @@ clientApp.0.startOnLoad=true # SAM bridge clientApp.1.main=net.i2p.sam.SAMBridge clientApp.1.name=SAMBridge -clientApp.1.args=sam.keys 127.0.0.1 7656 i2cp.tcp.host=localhost i2cp.tcp.port=7654 +clientApp.1.args=sam.keys 127.0.0.1 7656 i2cp.tcp.host=127.0.0.1 i2cp.tcp.port=7654 clientApp.1.startOnLoad=false # poke the i2ptunnels defined in i2ptunnel.config @@ -27,7 +27,7 @@ clientApp.3.startOnLoad=true # load a browser pointing at the web console whenever we start up clientApp.4.main=net.i2p.apps.systray.UrlLauncher clientApp.4.name=consoleBrowser -clientApp.4.args=http://localhost:7657/index.jsp +clientApp.4.args=http://127.0.0.1:7657/index.jsp clientApp.4.delay=5 clientApp.4.startOnLoad=true diff --git a/installer/resources/dnf-header.ht b/installer/resources/dnf-header.ht index 1d4f6ff7f0..2293d938c8 100644 --- a/installer/resources/dnf-header.ht +++ b/installer/resources/dnf-header.ht @@ -6,7 +6,7 @@ Proxy-Connection: close <html><head> <title>Eepsite not reachable</title> -<link rel="shortcut icon" href="http://localhost:7657/favicon.ico" /> +<link rel="shortcut icon" href="http://127.0.0.1:7657/favicon.ico" /> <style type='text/css'> div.warning { margin: 0em 1em 1em 224px; @@ -32,8 +32,8 @@ div.logo { </head> <body> <div class=logo> - <a href="http://localhost:7657/index.jsp" title="Router Console"><img src="http://localhost:7657/i2plogo.png" alt="Router Console" width="187" height="35" border="0"/></a><br /> - [<a href="http://localhost:7657/config.jsp">configuration</a> | <a href="http://localhost:7657/help.jsp">help</a>] + <a href="http://127.0.0.1:7657/index.jsp" title="Router Console"><img src="http://127.0.0.1:7657/i2plogo.png" alt="Router Console" width="187" height="35" border="0"/></a><br /> + [<a href="http://127.0.0.1:7657/config.jsp">configuration</a> | <a href="http://127.0.0.1:7657/help.jsp">help</a>] </div> <div class=warning id=warning> The eepsite was not reachable. diff --git a/installer/resources/dnfb-header.ht b/installer/resources/dnfb-header.ht index 39e56000ee..51f9c63ad1 100644 --- a/installer/resources/dnfb-header.ht +++ b/installer/resources/dnfb-header.ht @@ -6,7 +6,7 @@ Proxy-Connection: close <html><head> <title>Invalid eepsite destination</title> -<link rel="shortcut icon" href="http://localhost:7657/favicon.ico" /> +<link rel="shortcut icon" href="http://127.0.0.1:7657/favicon.ico" /> <style type='text/css'> div.warning { margin: 0em 1em 1em 224px; @@ -32,8 +32,8 @@ div.logo { </head> <body> <div class=logo> - <a href="http://localhost:7657/index.jsp" title="Router Console"><img src="http://localhost:7657/i2plogo.png" alt="Router Console" width="187" height="35" border="0"/></a><br /> - [<a href="http://localhost:7657/config.jsp">configuration</a> | <a href="http://localhost:7657/help.jsp">help</a>] + <a href="http://127.0.0.1:7657/index.jsp" title="Router Console"><img src="http://127.0.0.1:7657/i2plogo.png" alt="Router Console" width="187" height="35" border="0"/></a><br /> + [<a href="http://127.0.0.1:7657/config.jsp">configuration</a> | <a href="http://127.0.0.1:7657/help.jsp">help</a>] </div> <div class=warning id=warning> The eepsite destination specified was not valid, or was diff --git a/installer/resources/dnfh-header.ht b/installer/resources/dnfh-header.ht index ff6195ca97..eea94252e1 100644 --- a/installer/resources/dnfh-header.ht +++ b/installer/resources/dnfh-header.ht @@ -6,7 +6,7 @@ Proxy-Connection: close <html><head> <title>Eepsite unknown</title> -<link rel="shortcut icon" href="http://localhost:7657/favicon.ico" /> +<link rel="shortcut icon" href="http://127.0.0.1:7657/favicon.ico" /> <style type='text/css'> div.warning { margin: 0em 1em 1em 224px; @@ -32,16 +32,16 @@ div.logo { </head> <body> <div class=logo> - <a href="http://localhost:7657/index.jsp" title="Router Console"><img src="http://localhost:7657/i2plogo.png" alt="Router Console" width="187" height="35" border="0"/></a><br /> - [<a href="http://localhost:7657/config.jsp">configuration</a> | <a href="http://localhost:7657/help.jsp">help</a>] + <a href="http://127.0.0.1:7657/index.jsp" title="Router Console"><img src="http://127.0.0.1:7657/i2plogo.png" alt="Router Console" width="187" height="35" border="0"/></a><br /> + [<a href="http://127.0.0.1:7657/config.jsp">configuration</a> | <a href="http://127.0.0.1:7657/help.jsp">help</a>] </div> <div class=warning id=warning> The eepsite was not found in your router's addressbook. Check the link or find a BASE64 address. If you have the BASE64 address, paste it into your userhosts.txt using -<a href="http://localhost:7657/susidns/addressbook.jsp?book=master">SusiDNS</a>, +<a href="http://127.0.0.1:7657/susidns/addressbook.jsp?book=master">SusiDNS</a>, use a BASE64 address helper, or use a jump service link below. Seeing this page often? See <a href="http://www.i2p2.i2p/faq.html#subscriptions">the FAQ</a> -for help in <a href="http://localhost:7657/susidns/config.jsp">adding some subscriptions</a> +for help in <a href="http://127.0.0.1:7657/susidns/config.jsp">adding some subscriptions</a> to your addressbook. <BR><BR>Could not find the following destination:<BR><BR> diff --git a/installer/resources/dnfp-header.ht b/installer/resources/dnfp-header.ht index 9108889fcb..40358c3eb4 100644 --- a/installer/resources/dnfp-header.ht +++ b/installer/resources/dnfp-header.ht @@ -6,7 +6,7 @@ Proxy-Connection: close <html><head> <title>Outproxy Not Found</title> -<link rel="shortcut icon" href="http://localhost:7657/favicon.ico" /> +<link rel="shortcut icon" href="http://127.0.0.1:7657/favicon.ico" /> <style type='text/css'> div.warning { margin: 0em 1em 1em 224px; @@ -33,8 +33,8 @@ div.logo { </head> <body> <div class=logo> - <a href="http://localhost:7657/index.jsp" title="Router Console"><img src="http://localhost:7657/i2plogo.png" alt="Router Console" width="187" height="35" border="0"/></a><br /> - [<a href="http://localhost:7657/config.jsp">configuration</a> | <a href="http://localhost:7657/help.jsp">help</a>] + <a href="http://127.0.0.1:7657/index.jsp" title="Router Console"><img src="http://127.0.0.1:7657/i2plogo.png" alt="Router Console" width="187" height="35" border="0"/></a><br /> + [<a href="http://127.0.0.1:7657/config.jsp">configuration</a> | <a href="http://127.0.0.1:7657/help.jsp">help</a>] </div> <div class=warning id=warning> The WWW Outproxy was not found. @@ -43,8 +43,8 @@ or your router is not yet well-integrated with peers. You may want to <a href="javascript: parent.window.location.reload()">retry</a> as this will randomly reselect an outproxy from the pool you have defined -<a href="http://localhost:7657/i2ptunnel/index.jsp">here</a> +<a href="http://127.0.0.1:7657/i2ptunnel/index.jsp">here</a> (if you have more than one configured). If you continue to have trouble you may want to edit your outproxy list -<a href="http://localhost:7657/i2ptunnel/edit.jsp?tunnel=0">here</a>. +<a href="http://127.0.0.1:7657/i2ptunnel/edit.jsp?tunnel=0">here</a>. <BR><BR>Could not find the following destination:<BR><BR> diff --git a/installer/resources/eepsite_index.html b/installer/resources/eepsite_index.html index 2fe80c8c12..2d8d5f1924 100644 --- a/installer/resources/eepsite_index.html +++ b/installer/resources/eepsite_index.html @@ -11,11 +11,11 @@ In I2P, eepsites are addressed using a 'key', which is represented as a really long Base64 string. (The 'key' is somewhat analogous to an IP address, and is shown on the eepsite's I2PTunnel - <a href="http://localhost:7657/i2ptunnel/edit.jsp?tunnel=3">configuration page</a>). + <a href="http://127.0.0.1:7657/i2ptunnel/edit.jsp?tunnel=3">configuration page</a>). The instructions below detail how to assign a name like "mysite.i2p" to your key and start up your eepsite.</p> <p>You can reach your eepsite locally through - <a href="http://localhost:7658/">http://localhost:7658/</a>. + <a href="http://127.0.0.1:7658/">http://127.0.0.1:7658/</a>. </p> <h2>Step-by-step instructions for starting your new eepsite and announcing it to the I2P community</h2> @@ -27,24 +27,24 @@ <ul> <li>Pick a name for your eepsite (<i>something</i>.i2p). Use all lower-case. You may wish to check first in your own router's address book - <a href="http://localhost:7657/susidns/addressbook.jsp?book=router&filter=none">here</a>, + <a href="http://127.0.0.1:7657/susidns/addressbook.jsp?book=router&filter=none">here</a>, or the file i2p/hosts.txt to see if your name is already taken. Enter the new name for your eepsite on the - <a href="http://localhost:7657/i2ptunnel/edit.jsp?tunnel=3">eepsite i2ptunnel configuration page</a> + <a href="http://127.0.0.1:7657/i2ptunnel/edit.jsp?tunnel=3">eepsite i2ptunnel configuration page</a> where it says "Website name". This will replace the default "mysite.i2p". Also, check the "Auto Start" box. Your eepsite will now start every time you start your router. Be sure and click "Save". <li>Click the start button for your eepsite on the - <a href="http://localhost:7657/i2ptunnel/index.jsp">main i2ptunnel configuration page</a>. + <a href="http://127.0.0.1:7657/i2ptunnel/index.jsp">main i2ptunnel configuration page</a>. You should now see "eepsite" listed under "Local Destinations" on the left side of the - <a href="http://localhost:7657/index.jsp">I2P Router Console</a>. + <a href="http://127.0.0.1:7657/index.jsp">I2P Router Console</a>. Your eepsite is now running. <li>Highlight the entire "Local destination" key on the - <a href="http://localhost:7657/i2ptunnel/edit.jsp?tunnel=3">eepsite i2ptunnel configuration page</a>. + <a href="http://127.0.0.1:7657/i2ptunnel/edit.jsp?tunnel=3">eepsite i2ptunnel configuration page</a>. and copy it for later pasting. Make sure you get the whole thing - it's over 500 characters and it must end in "AAAA". <li>Enter the name and paste in the destination key into your - <a href="http://localhost:7657/susidns/addressbook.jsp?book=master">master address book</a>. + <a href="http://127.0.0.1:7657/susidns/addressbook.jsp?book=master">master address book</a>. Click "Add" to add the destination to your address book. <li>In your browser, enter in your eepsite name (<i>something</i>.i2p) and you should be right back here. Hopefully it worked. @@ -57,14 +57,14 @@ your eepsite name and key into a web interface on one or more of these sites. Here is <a href="http://stats.i2p/i2p/addkey.html">the key entry form at stats.i2p</a>. Again, your key is the entire "Local destination" key on the - <a href="http://localhost:7657/i2ptunnel/edit.jsp?tunnel=3">eepsite i2ptunnel configuration page</a>. + <a href="http://127.0.0.1:7657/i2ptunnel/edit.jsp?tunnel=3">eepsite i2ptunnel configuration page</a>. Be sure you get the whole thing, ending with "AAAA". Don't forget to click "add a key". Check to see if it reports the key was added. Since many routers periodically get address book updates from these sites, within several hours others will be able to find your website by simply typing <i>something</i>.i2p into their browser. <li>Speaking of address book updates, this would be a good time to add some more addressbooks - to your own subscription list. Go to your <a href="http://localhost:7657/susidns/subscriptions.jsp">subscriptions configuration page</a> + to your own subscription list. Go to your <a href="http://127.0.0.1:7657/susidns/subscriptions.jsp">subscriptions configuration page</a> and add a couple of these - <a href="http://tino.i2p/hosts.txt">http://tino.i2p/hosts.txt</a>, <a href="http://stats.i2p/cgi-bin/newhosts.txt">http://stats.i2p/cgi-bin/newhosts.txt</a>, diff --git a/installer/resources/startconsole.html b/installer/resources/startconsole.html index bd60c4673c..adaf4d8d52 100644 --- a/installer/resources/startconsole.html +++ b/installer/resources/startconsole.html @@ -1,6 +1,6 @@ <html><body> -<meta http-equiv="Refresh" CONTENT="0;URL=http://localhost:7657/index.jsp" /> -Continue to your <a href="http://localhost:7657/index.jsp">I2P Router console</a>. +<meta http-equiv="Refresh" CONTENT="0;URL=http://127.0.0.1:7657/index.jsp" /> +Continue to your <a href="http://127.0.0.1:7657/index.jsp">I2P Router console</a>. If that page does not load, please make sure I2P is running, or review the file wrapper.log for critical errors. </body></html> diff --git a/router/java/src/net/i2p/router/Router.java b/router/java/src/net/i2p/router/Router.java index 13e801458c..37215f6c4b 100644 --- a/router/java/src/net/i2p/router/Router.java +++ b/router/java/src/net/i2p/router/Router.java @@ -90,8 +90,6 @@ public class Router { System.setProperty("sun.net.inetaddr.negative.ttl", DNS_CACHE_TIME); System.setProperty("networkaddress.cache.ttl", DNS_CACHE_TIME); System.setProperty("networkaddress.cache.negative.ttl", DNS_CACHE_TIME); - // until we handle restricted routes and/or all peers support v6, try v4 first - System.setProperty("java.net.preferIPv4Stack", "true"); System.setProperty("http.agent", "I2P"); // (no need for keepalive) System.setProperty("http.keepAlive", "false"); @@ -135,7 +133,9 @@ public class Router { envProps.setProperty(k, v); } } - + // This doesn't work, guess it has to be in the static block above? + // if (Boolean.valueOf(envProps.getProperty("router.disableIPv6")).booleanValue()) + // System.setProperty("java.net.preferIPv4Stack", "true"); _context = new RouterContext(this, envProps); _routerInfo = null; @@ -1206,13 +1206,13 @@ public class Router { return Math.max(send, recv); } -} +/* following classes are now private static inner classes, didn't bother to reindent */ /** * coalesce the stats framework every minute * */ -class CoalesceStatsEvent implements SimpleTimer.TimedEvent { +private static class CoalesceStatsEvent implements SimpleTimer.TimedEvent { private RouterContext _ctx; public CoalesceStatsEvent(RouterContext ctx) { _ctx = ctx; @@ -1278,7 +1278,7 @@ class CoalesceStatsEvent implements SimpleTimer.TimedEvent { * This is done here because we want to make sure the key is updated before anyone * uses it. */ -class UpdateRoutingKeyModifierJob extends JobImpl { +private static class UpdateRoutingKeyModifierJob extends JobImpl { private Log _log; private Calendar _cal = new GregorianCalendar(TimeZone.getTimeZone("GMT")); public UpdateRoutingKeyModifierJob(RouterContext ctx) { @@ -1310,7 +1310,7 @@ class UpdateRoutingKeyModifierJob extends JobImpl { } } -class MarkLiveliness implements Runnable { +private static class MarkLiveliness implements Runnable { private RouterContext _context; private Router _router; private File _pingFile; @@ -1342,7 +1342,7 @@ class MarkLiveliness implements Runnable { } } -class ShutdownHook extends Thread { +private static class ShutdownHook extends Thread { private RouterContext _context; private static int __id = 0; private int _id; @@ -1359,7 +1359,7 @@ class ShutdownHook extends Thread { } /** update the router.info file whenever its, er, updated */ -class PersistRouterInfoJob extends JobImpl { +private static class PersistRouterInfoJob extends JobImpl { private Log _log; public PersistRouterInfoJob(RouterContext ctx) { super(ctx); @@ -1389,3 +1389,5 @@ class PersistRouterInfoJob extends JobImpl { } } } + +} -- GitLab