forked from I2P_Developers/i2p.i2p
i2ptunnel: Add failsafe timeouts for local sockets (ticket #2568)
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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" +
|
||||
|
@ -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;
|
||||
@ -557,6 +562,14 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
||||
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) {
|
||||
t = new CompressedRequestor(s, socket, modifiedHeader, getTunnel().getContext(), _log);
|
||||
|
11
history.txt
11
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
|
||||
|
@ -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 = "";
|
||||
|
Reference in New Issue
Block a user