From 4c812c7bffd5c96662b3d2620bea005b1eec6ded Mon Sep 17 00:00:00 2001 From: zzz Date: Sun, 29 Nov 2009 18:49:28 +0000 Subject: [PATCH] * HTTP Proxy: Don't send proxy.i2p to the naming service, it was making the error pages load slowly --- .../i2p/i2ptunnel/I2PTunnelHTTPClient.java | 28 ++++++++++++------- history.txt | 8 ++++++ .../src/net/i2p/router/RouterVersion.java | 2 +- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java index b729b659b..ce62a23f0 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java @@ -245,6 +245,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable OutputStream out = null; String targetRequest = null; boolean usingWWWProxy = false; + boolean usingInternalServer = false; String currentProxy = null; long requestId = ++__requestId; try { @@ -271,6 +272,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable int pos = line.indexOf(" "); if (pos == -1) break; method = line.substring(0, pos); + // TODO use Java URL class to make all this simpler and more robust String request = line.substring(pos + 1); if (request.startsWith("/") && getTunnel().getClientOptions().getProperty("i2ptunnel.noproxy") != null) { request = "http://i2p" + request; @@ -316,8 +318,11 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable } } - // Quick hack for foo.bar.i2p - if (host.toLowerCase().endsWith(".i2p")) { + if (host.toLowerCase().equals("proxy.i2p")) { + // so we don't do any naming service lookups + destination = "proxy.i2p"; + usingInternalServer = true; + } else if (host.toLowerCase().endsWith(".i2p")) { // Destination gets the host name destination = host; // Host becomes the destination key @@ -454,15 +459,15 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable } destination = request.substring(0, pos); line = method + " " + request.substring(pos); - } + } // end host name processing - boolean isValid = usingWWWProxy || isSupportedAddress(host, protocol); + boolean isValid = usingWWWProxy || usingInternalServer || isSupportedAddress(host, protocol); if (!isValid) { if (_log.shouldLog(Log.INFO)) _log.info(getPrefix(requestId) + "notValid(" + host + ")"); method = null; destination = null; break; - } else if (!usingWWWProxy) { + } else if ((!usingWWWProxy) && (!usingInternalServer)) { if (_log.shouldLog(Log.INFO)) _log.info(getPrefix(requestId) + "host=getHostName(" + destination + ")"); host = getHostName(destination); // hide original host } @@ -473,7 +478,9 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable _log.debug(getPrefix(requestId) + "HOST :" + host + ":"); _log.debug(getPrefix(requestId) + "DEST :" + destination + ":"); } - + + // end first line processing + } else { if (lowercaseLine.startsWith("host: ") && !usingWWWProxy) { line = "Host: " + host; @@ -505,14 +512,14 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable continue; // completely strip the line } } - + if (line.length() == 0) { String ok = getTunnel().getClientOptions().getProperty("i2ptunnel.gzip"); boolean gzip = DEFAULT_GZIP; if (ok != null) gzip = Boolean.valueOf(ok).booleanValue(); - if (gzip) { + if (gzip && !usingInternalServer) { // according to rfc2616 s14.3, this *should* force identity, even if // an explicit q=0 for gzip doesn't. tested against orion.i2p, and it // seems to work. @@ -526,7 +533,8 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable } else { newRequest.append(line).append("\r\n"); // HTTP spec } - } + } // end header processing + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix(requestId) + "NewRequest header: [" + newRequest.toString() + "]"); @@ -548,7 +556,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable // Serve local proxy files (images, css linked from error pages) // Ignore all the headers - if (destination.equals("proxy.i2p")) { + if (usingInternalServer) { serveLocalFile(out, method, targetRequest); s.close(); return; diff --git a/history.txt b/history.txt index 79bb5b2a1..62af66cba 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,11 @@ +2009-11-29 zzz + * config.jsp: Comment out unused stuff better + * profiles.jsp: Hide non-ff from ff table + * HTTP Proxy: Don't send proxy.i2p to the naming service, + it was making the error pages load slowly + * SOCKS Proxy: Fix an error message + * Transport: Fix the default inbound burst + 2009-11-29 sponge * net.i2p.router.transport.udp deadwood code cleanup. * documented rare NPE in InboundEstablishState.java. diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 7de969bf4..458d45df4 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 = 23; + public final static long BUILD = 24; /** for example "-test" */ public final static String EXTRA = ""; public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;