* 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
This commit is contained in:
zzz
2009-04-08 01:34:12 +00:00
parent f5614c8a41
commit 0cfbe9c28b
24 changed files with 349 additions and 63 deletions

View File

@@ -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);

View File

@@ -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";

View File

@@ -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();