TunnelPoolSettings constructor tweak

This commit is contained in:
zzz
2014-04-01 13:03:40 +00:00
parent 8a6fb132f5
commit b206665c72
4 changed files with 26 additions and 13 deletions

View File

@ -22,8 +22,8 @@ public class ClientTunnelSettings {
private final TunnelPoolSettings _outboundSettings;
public ClientTunnelSettings(Hash dest) {
_inboundSettings = new TunnelPoolSettings(dest, false, true);
_outboundSettings = new TunnelPoolSettings(dest, false, false);
_inboundSettings = new TunnelPoolSettings(dest, true);
_outboundSettings = new TunnelPoolSettings(dest, false);
}
public TunnelPoolSettings getInboundSettings() { return _inboundSettings; }

View File

@ -79,23 +79,33 @@ public class TunnelPoolSettings {
private static final int MAX_PRIORITY = 25;
private static final int EXPLORATORY_PRIORITY = 30;
public TunnelPoolSettings(Hash dest, boolean isExploratory, boolean isInbound) {
/**
* Exploratory tunnel
*/
public TunnelPoolSettings(boolean isInbound) {
this(null, isInbound);
}
/**
* Client tunnel unless dest == null
*/
public TunnelPoolSettings(Hash dest, boolean isInbound) {
_destination = dest;
_isExploratory = isExploratory;
_isExploratory = dest == null;
_isInbound = isInbound;
_quantity = DEFAULT_QUANTITY;
_backupQuantity = DEFAULT_BACKUP_QUANTITY;
// _rebuildPeriod = DEFAULT_REBUILD_PERIOD;
//_duration = DEFAULT_DURATION;
if (isInbound) {
_length = isExploratory ? DEFAULT_IB_EXPL_LENGTH : DEFAULT_IB_LENGTH;
_lengthVariance = isExploratory ? DEFAULT_IB_EXPL_LENGTH_VARIANCE : DEFAULT_LENGTH_VARIANCE;
_length = _isExploratory ? DEFAULT_IB_EXPL_LENGTH : DEFAULT_IB_LENGTH;
_lengthVariance = _isExploratory ? DEFAULT_IB_EXPL_LENGTH_VARIANCE : DEFAULT_LENGTH_VARIANCE;
} else {
_length = isExploratory ? DEFAULT_OB_EXPL_LENGTH : DEFAULT_OB_LENGTH;
_lengthVariance = isExploratory ? DEFAULT_OB_EXPL_LENGTH_VARIANCE : DEFAULT_LENGTH_VARIANCE;
_length = _isExploratory ? DEFAULT_OB_EXPL_LENGTH : DEFAULT_OB_LENGTH;
_lengthVariance = _isExploratory ? DEFAULT_OB_EXPL_LENGTH_VARIANCE : DEFAULT_LENGTH_VARIANCE;
}
_lengthOverride = -1;
if (isExploratory)
if (_isExploratory)
_allowZeroHop = true;
else
_allowZeroHop = DEFAULT_ALLOW_ZERO_HOP;
@ -189,7 +199,7 @@ public class TunnelPoolSettings {
//public int getDuration() { return _duration; }
//public void setDuration(int ms) { _duration = ms; }
/** what destination is this a tunnel for (or null if none) */
/** what destination is this a client tunnel for (or null if exploratory) */
public Hash getDestination() { return _destination; }
/** random key used for peer ordering */

View File

@ -114,7 +114,10 @@ public class TunnelCreatorConfig implements TunnelInfo {
/** is this an inbound tunnel? */
public boolean isInbound() { return _isInbound; }
/** if this is a client tunnel, what destination is it for? */
/**
* If this is a client tunnel, what destination is it for?
* @return null for exploratory
*/
public Hash getDestination() { return _destination; }
public long getExpiration() { return _expiration; }

View File

@ -62,9 +62,9 @@ public class TunnelPoolManager implements TunnelManagerFacade {
_clientPeerSelector = new ClientPeerSelector(ctx);
ExploratoryPeerSelector selector = new ExploratoryPeerSelector(_context);
TunnelPoolSettings inboundSettings = new TunnelPoolSettings(null, true, true);
TunnelPoolSettings inboundSettings = new TunnelPoolSettings(true);
_inboundExploratory = new TunnelPool(_context, this, inboundSettings, selector);
TunnelPoolSettings outboundSettings = new TunnelPoolSettings(null, true, false);
TunnelPoolSettings outboundSettings = new TunnelPoolSettings(false);
_outboundExploratory = new TunnelPool(_context, this, outboundSettings, selector);
// threads will be started in startup()