diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java index 164948d8a..08f9db34c 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java @@ -286,7 +286,7 @@ public class I2PTunnelConnectClient extends I2PTunnelHTTPClientBase implements R } } newRequest.append("\r\n"); // HTTP spec - s.setSoTimeout(0); + s.setSoTimeout(BROWSER_READ_TIMEOUT); // do it break; } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java index 3b7b248b3..243702ffc 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java @@ -1102,7 +1102,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn newRequest.append("\r\n"); else newRequest.append("Connection: close\r\n\r\n"); - s.setSoTimeout(0); + s.setSoTimeout(BROWSER_READ_TIMEOUT); break; } else { newRequest.append(line).append("\r\n"); // HTTP spec diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientBase.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientBase.java index 0609a0b39..64196c196 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientBase.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientBase.java @@ -77,6 +77,12 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem */ protected static final int INITIAL_SO_TIMEOUT = 15*1000; + /** + * Failsafe + * @since 0.9.42 + */ + protected static final int BROWSER_READ_TIMEOUT = 4*60*60*1000; + private static final String ERR_AUTH1 = "HTTP/1.1 407 Proxy Authentication Required\r\n" + "Content-Type: text/html; charset=UTF-8\r\n" + diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java index c4685d686..1b9791c4f 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java @@ -92,6 +92,11 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer { // We set it to forever so that it won't timeout when sending a large response. // The server will presumably have its own timeout implemented for POST private static final long DEFAULT_HTTP_READ_TIMEOUT = -1; + // Set a relatively short timeout for GET/HEAD, + // and a long failsafe timeout for POST/CONNECT, since the user + // could be POSTing a massive file + private static final int SERVER_READ_TIMEOUT_GET = 5*60*1000; + private static final int SERVER_READ_TIMEOUT_POST = 4*60*60*1000; private long _startedOn = 0L; private ConnThrottler _postThrottler; @@ -556,6 +561,14 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer { String modifiedHeader = formatHeaders(headers, command); if (_log.shouldLog(Log.DEBUG)) _log.debug("Modified header: [" + modifiedHeader + "]"); + + // Set a relatively short timeout for GET/HEAD, + // and a long failsafe timeout for POST/CONNECT, since the user + // could be POSTing a massive file + if (modifiedHeader.startsWith("GET ") || modifiedHeader.startsWith("HEAD ")) + s.setSoTimeout(SERVER_READ_TIMEOUT_GET); + else + s.setSoTimeout(SERVER_READ_TIMEOUT_POST); Runnable t; if (allowGZIP && useGZIP) { diff --git a/history.txt b/history.txt index 4e443dd4a..4b5c1c536 100644 --- a/history.txt +++ b/history.txt @@ -1,5 +1,16 @@ +2019-08-05 zzz + * i2ptunnel: + - Add configs to override user agent + - Add failsafe timeouts for local sockets (ticket #2568) + * Reseed: Send network ID in query string (proposal 147) + * Transports: Implement cross-network detection (proposal 147) + 2019-08-04 zzz + * i2psnark: + - Add checks for dup data dirs (ticket #2291) + - Fix autostart to only start torrents running previously (ticket #2120) * SSU: Fix stall when higher-priority message is queued (ticket #2582) + * Streaming: Reduce immediate ack delay (ticket #2584) 2019-08-03 zzz * Transport: Allow local addresses when configured diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index c10128fe6..fecba78d6 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 = 6; + public final static long BUILD = 7; /** for example "-test" */ public final static String EXTRA = "";