I2CP: Reduce session limit to 50

Set limit to 0 if vmCommSystem
i2ptunnel: Do not retry if session limit exceeded
This commit is contained in:
zzz
2023-01-01 13:08:25 -05:00
parent 6bcc866f38
commit edfc9b1454
4 changed files with 11 additions and 3 deletions

View File

@ -489,7 +489,9 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
else
msg = "Unable to connect to the router at " + getTunnel().host + ':' + portNum +
" and build tunnels for the client";
if (++retries < MAX_RETRIES) {
String exmsg = ise.getMessage();
boolean fail = exmsg != null && exmsg.contains("session limit exceeded");
if (!fail && ++retries < MAX_RETRIES) {
if (log != null)
log.log(msg + ", retrying in " + (RETRY_DELAY / 1000) + " seconds");
_log.error(msg + ", retrying in " + (RETRY_DELAY / 1000) + " seconds", ise);

View File

@ -380,7 +380,9 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
else
msg = "Unable to connect to the router at " + getTunnel().host + ':' + portNum +
" and build tunnels for the server at " + remoteHost.getHostAddress() + ':' + remotePort;
if (++retries < MAX_RETRIES) {
String exmsg = ise.getMessage();
boolean fail = exmsg != null && exmsg.contains("session limit exceeded");
if (!fail && ++retries < MAX_RETRIES) {
msg += ", retrying in " + (RETRY_DELAY / 1000) + " seconds";
this.l.log(msg);
_log.error(msg);

View File

@ -835,6 +835,8 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2
msg = "Failed to bind to the router on " + _options.getProperty(PROP_DOMAIN_SOCKET) + " and build tunnels";
else
msg = "Cannot connect to the router on " + _hostname + ':' + _portNum + " and build tunnels";
if (ioe.getMessage() != null)
msg += " - " + ioe.getMessage();
throw new I2PSessionException(getPrefix() + msg, ioe);
} finally {
if (success) {

View File

@ -89,7 +89,7 @@ class ClientManager {
/** 2 bytes, save 65535 for unknown */
private static final int MAX_SESSION_ID = 65534;
private static final String PROP_MAX_SESSIONS = "i2cp.maxSessions";
private static final int DEFAULT_MAX_SESSIONS = 100;
private static final int DEFAULT_MAX_SESSIONS = 50;
/** 65535 */
public static final SessionId UNKNOWN_SESSION_ID = new SessionId(MAX_SESSION_ID + 1);
@ -431,6 +431,8 @@ class ClientManager {
* @since 0.9.12
*/
private SessionId locked_getNextSessionId() {
if (_ctx.commSystem().isDummy())
return null;
int max = Math.max(1, Math.min(2048, _ctx.getProperty(PROP_MAX_SESSIONS, DEFAULT_MAX_SESSIONS)));
if (_runnerSessionIds.size() >= max) {
_log.logAlways(Log.WARN, "Session refused, max is " + max + ", increase " + PROP_MAX_SESSIONS);