diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientBase.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientBase.java
index cb5af0f2a..88a1b29be 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientBase.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientBase.java
@@ -110,7 +110,7 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
"
I2P ERROR: No outproxy found
"+
"Your request was for a site outside of I2P, but you have no "+
"outproxy configured. Please configure an outproxy in I2PTunnel";
-
+
protected final static String ERR_DESTINATION_UNKNOWN =
"HTTP/1.1 503 Service Unavailable\r\n" +
"Content-Type: text/html; charset=iso-8859-1\r\n" +
@@ -162,7 +162,7 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
// SSL proxy config is parsed on the fly;
// allow both to be changed and store the SSL proxy list.
// TODO should track more than one failed proxy
-
+
/**
* Simple random selection, with caching by hostname,
* and avoidance of the last one to fail.
@@ -243,7 +243,7 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
_log.info("Selected SSL proxy for " + host + ": " + rv);
return rv;
}
-
+
/**
* Update the cache and note if failed.
*
@@ -290,11 +290,11 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
* so that large POSTs won't timeout on the read side
*/
protected static final int DEFAULT_READ_TIMEOUT = -1;
-
+
protected static final AtomicLong __requestId = new AtomicLong();
- public I2PTunnelHTTPClientBase(int localPort, boolean ownDest, Logging l,
- EventDispatcher notifyThis, String handlerName,
+ public I2PTunnelHTTPClientBase(int localPort, boolean ownDest, Logging l,
+ EventDispatcher notifyThis, String handlerName,
I2PTunnel tunnel) throws IllegalArgumentException {
super(localPort, ownDest, l, notifyThis, handlerName, tunnel);
// force connect delay and bulk profile
@@ -579,6 +579,7 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
* @since 0.9.4
*/
private String getNonce() {
+ tidyNonces();
byte[] b = new byte[DataHelper.DATE_LENGTH + PROXYNONCE_BYTES];
byte[] n = new byte[NONCE_BYTES];
long now = _context.clock().now();
@@ -642,6 +643,18 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
}
}
+ /**
+ * Check if the nonce map is larger than the MAX_NONCE_COUNT and clean it if so.
+ * @since 0.9.71
+ */
+ private void tidyNonces() {
+ if (_nonces == null)
+ return;
+ if (_nonces.size() > MAX_NONCE_COUNT) {
+ cleanNonces();
+ }
+ }
+
/**
* What to send if digest auth fails
* @since 0.9.4