From 610f1f7dd45b6e8daa435eddbf7692981c627f57 Mon Sep 17 00:00:00 2001 From: jrandom Date: Wed, 1 Dec 2004 22:31:55 +0000 Subject: [PATCH] * 2004-12-01 0.4.2.1 released 2004-12-01 jrandom * Strip out any of the Accept-* HTTP header lines, and always make sure to include the forged User-agent header. * Adjust the default read timeout on the eepproxy to 60s, unless overridden. * Minor tweak on stream shutdown. --- .../i2p/i2ptunnel/I2PTunnelHTTPClient.java | 38 ++++++++++++++++++- .../net/i2p/client/streaming/Connection.java | 8 +++- history.txt | 11 +++++- installer/install.xml | 2 +- .../src/net/i2p/router/RouterVersion.java | 6 +-- 5 files changed, 57 insertions(+), 8 deletions(-) diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java index b2c047b27..da713ae49 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java @@ -19,6 +19,7 @@ import java.util.Properties; import net.i2p.I2PAppContext; import net.i2p.I2PException; import net.i2p.client.streaming.I2PSocket; +import net.i2p.client.streaming.I2PSocketOptions; import net.i2p.data.DataFormatException; import net.i2p.data.Destination; import net.i2p.util.Clock; @@ -143,6 +144,33 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable return proxy; } } + + private static final int DEFAULT_READ_TIMEOUT = 60*1000; + + /** + * create the default options (using the default timeout, etc) + * + */ + protected I2PSocketOptions getDefaultOptions() { + I2PSocketOptions opts = super.getDefaultOptions(); + Properties defaultOpts = getTunnel().getClientOptions(); + if (!defaultOpts.contains(I2PSocketOptions.PROP_READ_TIMEOUT)) + opts.setReadTimeout(DEFAULT_READ_TIMEOUT); + return opts; + } + + /** + * create the default options (using the default timeout, etc) + * + */ + protected I2PSocketOptions getDefaultOptions(Properties overrides) { + I2PSocketOptions opts = super.getDefaultOptions(overrides); + Properties defaultOpts = getTunnel().getClientOptions(); + defaultOpts.putAll(overrides); + if (!defaultOpts.containsKey(I2PSocketOptions.PROP_READ_TIMEOUT)) + opts.setConnectTimeout(DEFAULT_READ_TIMEOUT); + return opts; + } private static long __requestId = 0; protected void clientConnectionRun(Socket s) { @@ -295,7 +323,14 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable if (_log.shouldLog(Log.INFO)) _log.info(getPrefix(requestId) + "Setting host = " + host); } else if (line.startsWith("User-Agent: ")) { - line = "User-Agent: MYOB/6.66 (AN/ON)"; + // always stripped, added back at the end + line = null; + continue; + } else if (line.startsWith("Accept")) { + // strip the accept-blah headers, as they vary dramatically from + // browser to browser + line = null; + continue; } else if (line.startsWith("Referer: ")) { // Shouldn't we be more specific, like accepting in-site referers ? //line = "Referer: i2p"; @@ -313,6 +348,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable } if (line.length() == 0) { + newRequest.append("User-Agent: MYOB/6.66 (AN/ON)"); newRequest.append("Connection: close\r\n\r\n"); break; } else { diff --git a/apps/streaming/java/src/net/i2p/client/streaming/Connection.java b/apps/streaming/java/src/net/i2p/client/streaming/Connection.java index d17465a10..b6558f252 100644 --- a/apps/streaming/java/src/net/i2p/client/streaming/Connection.java +++ b/apps/streaming/java/src/net/i2p/client/streaming/Connection.java @@ -337,8 +337,12 @@ public class Connection { void resetReceived() { _resetReceived = true; - _outputStream.streamErrorOccurred(new IOException("Reset received")); - _inputStream.streamErrorOccurred(new IOException("Reset received")); + MessageOutputStream mos = _outputStream; + MessageInputStream mis = _inputStream; + if (mos != null) + mos.streamErrorOccurred(new IOException("Reset received")); + if (mis != null) + mis.streamErrorOccurred(new IOException("Reset received")); _connectionError = "Connection reset"; synchronized (_connectLock) { _connectLock.notifyAll(); } } diff --git a/history.txt b/history.txt index 293a69a55..86fce2247 100644 --- a/history.txt +++ b/history.txt @@ -1,4 +1,13 @@ -$Id: history.txt,v 1.89 2004/11/29 18:24:50 jrandom Exp $ +$Id: history.txt,v 1.90 2004/11/30 18:41:52 jrandom Exp $ + +* 2004-12-01 0.4.2.1 released + +2004-12-01 jrandom + * Strip out any of the Accept-* HTTP header lines, and always make sure to + include the forged User-agent header. + * Adjust the default read timeout on the eepproxy to 60s, unless + overridden. + * Minor tweak on stream shutdown. 2004-11-30 jrandom * Render the burst rate fields on /config.jsp properly (thanks ugha!) diff --git a/installer/install.xml b/installer/install.xml index cab202f91..4ecb5d679 100644 --- a/installer/install.xml +++ b/installer/install.xml @@ -4,7 +4,7 @@ i2p - 0.4.2 + 0.4.2.1 diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 6cfff7f0b..e2173aa8b 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -15,9 +15,9 @@ import net.i2p.CoreVersion; * */ public class RouterVersion { - public final static String ID = "$Revision: 1.94 $ $Date: 2004/11/29 18:24:49 $"; - public final static String VERSION = "0.4.2"; - public final static long BUILD = 7; + public final static String ID = "$Revision: 1.95 $ $Date: 2004/11/30 18:41:51 $"; + public final static String VERSION = "0.4.2.1"; + public final static long BUILD = 0; public static void main(String args[]) { System.out.println("I2P Router version: " + VERSION); System.out.println("Router ID: " + RouterVersion.ID);