I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit aca56179 authored by zzz's avatar zzz
Browse files

i2psnark: Start with minimum tunnel count (ticket #2623)

parent e44a7c50
No related branches found
No related tags found
No related merge requests found
...@@ -229,6 +229,34 @@ public class I2PSnarkUtil { ...@@ -229,6 +229,34 @@ public class I2PSnarkUtil {
for (Map.Entry<String, String> entry : _opts.entrySet() ) for (Map.Entry<String, String> entry : _opts.entrySet() )
opts.setProperty(entry.getKey(), entry.getValue()); opts.setProperty(entry.getKey(), entry.getValue());
} }
// override preference and start with two tunnels. IdleChecker will ramp up/down as necessary
String sin = opts.getProperty("inbound.quantity");
if (sin != null) {
int in;
try {
in = Integer.parseInt(sin);
} catch (NumberFormatException nfe) {
in = 3;
}
if (in > 2)
opts.setProperty("inbound.quantity", "2");
}
String sout = opts.getProperty("outbound.quantity");
if (sout != null) {
int out;
try {
out = Integer.parseInt(sout);
} catch (NumberFormatException nfe) {
out = 3;
}
if (out > 2)
opts.setProperty("outbound.quantity", "2");
}
if (opts.containsKey("inbound.backupQuantity"))
opts.setProperty("inbound.backupQuantity", "0");
if (opts.containsKey("outbound.backupQuantity"))
opts.setProperty("outbound.backupQuantity", "0");
if (opts.getProperty("inbound.nickname") == null) if (opts.getProperty("inbound.nickname") == null)
opts.setProperty("inbound.nickname", _baseName.replace("i2psnark", "I2PSnark")); opts.setProperty("inbound.nickname", _baseName.replace("i2psnark", "I2PSnark"));
if (opts.getProperty("outbound.nickname") == null) if (opts.getProperty("outbound.nickname") == null)
......
...@@ -29,13 +29,14 @@ class IdleChecker extends SimpleTimer2.TimedEvent { ...@@ -29,13 +29,14 @@ class IdleChecker extends SimpleTimer2.TimedEvent {
private int _consec; private int _consec;
private int _consecNotRunning; private int _consecNotRunning;
private boolean _isIdle; private boolean _isIdle;
private String _lastIn = "3"; private String _lastIn = DEFAULT_QTY;
private String _lastOut = "3"; private String _lastOut = DEFAULT_QTY;
private final Object _lock = new Object(); private final Object _lock = new Object();
private static final long CHECK_TIME = 63*1000; private static final long CHECK_TIME = 63*1000;
private static final int MAX_CONSEC_IDLE = 4; private static final int MAX_CONSEC_IDLE = 4;
private static final int MAX_CONSEC_NOT_RUNNING = 20; private static final int MAX_CONSEC_NOT_RUNNING = 20;
private static final String DEFAULT_QTY = "2";
/** /**
* Caller must schedule * Caller must schedule
...@@ -93,8 +94,8 @@ class IdleChecker extends SimpleTimer2.TimedEvent { ...@@ -93,8 +94,8 @@ class IdleChecker extends SimpleTimer2.TimedEvent {
_isIdle = false; _isIdle = false;
_consec = 0; _consec = 0;
_consecNotRunning = 0; _consecNotRunning = 0;
_lastIn = "3"; _lastIn = DEFAULT_QTY;
_lastOut = "3"; _lastOut = DEFAULT_QTY;
} }
schedule(CHECK_TIME); schedule(CHECK_TIME);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment