forked from I2P_Developers/i2p.i2p
i2psnark: Start with minimum tunnel count (ticket #2623)
This commit is contained in:
@ -229,6 +229,34 @@ public class I2PSnarkUtil {
|
||||
for (Map.Entry<String, String> entry : _opts.entrySet() )
|
||||
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)
|
||||
opts.setProperty("inbound.nickname", _baseName.replace("i2psnark", "I2PSnark"));
|
||||
if (opts.getProperty("outbound.nickname") == null)
|
||||
|
@ -29,13 +29,14 @@ class IdleChecker extends SimpleTimer2.TimedEvent {
|
||||
private int _consec;
|
||||
private int _consecNotRunning;
|
||||
private boolean _isIdle;
|
||||
private String _lastIn = "3";
|
||||
private String _lastOut = "3";
|
||||
private String _lastIn = DEFAULT_QTY;
|
||||
private String _lastOut = DEFAULT_QTY;
|
||||
private final Object _lock = new Object();
|
||||
|
||||
private static final long CHECK_TIME = 63*1000;
|
||||
private static final int MAX_CONSEC_IDLE = 4;
|
||||
private static final int MAX_CONSEC_NOT_RUNNING = 20;
|
||||
private static final String DEFAULT_QTY = "2";
|
||||
|
||||
/**
|
||||
* Caller must schedule
|
||||
@ -93,8 +94,8 @@ class IdleChecker extends SimpleTimer2.TimedEvent {
|
||||
_isIdle = false;
|
||||
_consec = 0;
|
||||
_consecNotRunning = 0;
|
||||
_lastIn = "3";
|
||||
_lastOut = "3";
|
||||
_lastIn = DEFAULT_QTY;
|
||||
_lastOut = DEFAULT_QTY;
|
||||
}
|
||||
schedule(CHECK_TIME);
|
||||
}
|
||||
|
Reference in New Issue
Block a user