forked from I2P_Developers/i2p.i2p
* TunnelPeerSelector: Cleanups
This commit is contained in:
@@ -212,7 +212,7 @@ public abstract class TunnelPeerSelector {
|
||||
if (caps != null)
|
||||
peers.addAll(caps);
|
||||
}
|
||||
if (filterSlow(ctx, isInbound, isExploratory)) {
|
||||
if (filterSlow(isInbound, isExploratory)) {
|
||||
// NOTE: filterSlow always returns true
|
||||
Log log = ctx.logManager().getLog(TunnelPeerSelector.class);
|
||||
char excl[] = getExcludeCaps(ctx);
|
||||
@@ -434,34 +434,28 @@ public abstract class TunnelPeerSelector {
|
||||
private static final String PROP_INBOUND_EXPLORATORY_EXCLUDE_UNREACHABLE = "router.inboundExploratoryExcludeUnreachable";
|
||||
private static final String PROP_INBOUND_CLIENT_EXCLUDE_UNREACHABLE = "router.inboundClientExcludeUnreachable";
|
||||
|
||||
private static final String DEFAULT_OUTBOUND_EXPLORATORY_EXCLUDE_UNREACHABLE = "false";
|
||||
private static final String DEFAULT_OUTBOUND_CLIENT_EXCLUDE_UNREACHABLE = "false";
|
||||
private static final boolean DEFAULT_OUTBOUND_EXPLORATORY_EXCLUDE_UNREACHABLE = false;
|
||||
private static final boolean DEFAULT_OUTBOUND_CLIENT_EXCLUDE_UNREACHABLE = false;
|
||||
// see comments at getExclude() above
|
||||
private static final String DEFAULT_INBOUND_EXPLORATORY_EXCLUDE_UNREACHABLE = "true";
|
||||
private static final String DEFAULT_INBOUND_CLIENT_EXCLUDE_UNREACHABLE = "true";
|
||||
private static final boolean DEFAULT_INBOUND_EXPLORATORY_EXCLUDE_UNREACHABLE = true;
|
||||
private static final boolean DEFAULT_INBOUND_CLIENT_EXCLUDE_UNREACHABLE = true;
|
||||
|
||||
/**
|
||||
* do we want to skip peers who haven't been up for long?
|
||||
* @return true for inbound, false for outbound, unless configured otherwise
|
||||
*/
|
||||
protected boolean filterUnreachable(boolean isInbound, boolean isExploratory) {
|
||||
boolean def = false;
|
||||
String val = null;
|
||||
|
||||
if (isExploratory)
|
||||
if (isExploratory) {
|
||||
if (isInbound)
|
||||
val = ctx.getProperty(PROP_INBOUND_EXPLORATORY_EXCLUDE_UNREACHABLE, DEFAULT_INBOUND_EXPLORATORY_EXCLUDE_UNREACHABLE);
|
||||
return ctx.getProperty(PROP_INBOUND_EXPLORATORY_EXCLUDE_UNREACHABLE, DEFAULT_INBOUND_EXPLORATORY_EXCLUDE_UNREACHABLE);
|
||||
else
|
||||
val = ctx.getProperty(PROP_OUTBOUND_EXPLORATORY_EXCLUDE_UNREACHABLE, DEFAULT_OUTBOUND_EXPLORATORY_EXCLUDE_UNREACHABLE);
|
||||
else
|
||||
return ctx.getProperty(PROP_OUTBOUND_EXPLORATORY_EXCLUDE_UNREACHABLE, DEFAULT_OUTBOUND_EXPLORATORY_EXCLUDE_UNREACHABLE);
|
||||
} else {
|
||||
if (isInbound)
|
||||
val = ctx.getProperty(PROP_INBOUND_CLIENT_EXCLUDE_UNREACHABLE, DEFAULT_INBOUND_CLIENT_EXCLUDE_UNREACHABLE);
|
||||
return ctx.getProperty(PROP_INBOUND_CLIENT_EXCLUDE_UNREACHABLE, DEFAULT_INBOUND_CLIENT_EXCLUDE_UNREACHABLE);
|
||||
else
|
||||
val = ctx.getProperty(PROP_OUTBOUND_CLIENT_EXCLUDE_UNREACHABLE, DEFAULT_OUTBOUND_CLIENT_EXCLUDE_UNREACHABLE);
|
||||
|
||||
boolean rv = (val != null ? Boolean.parseBoolean(val) : def);
|
||||
//System.err.println("Filter unreachable? " + rv + " (inbound? " + isInbound + ", exploratory? " + isExploratory);
|
||||
return rv;
|
||||
return ctx.getProperty(PROP_OUTBOUND_CLIENT_EXCLUDE_UNREACHABLE, DEFAULT_OUTBOUND_CLIENT_EXCLUDE_UNREACHABLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -474,56 +468,50 @@ public abstract class TunnelPeerSelector {
|
||||
* do we want to skip peers that are slow?
|
||||
* @return true unless configured otherwise
|
||||
*/
|
||||
protected boolean filterSlow(RouterContext ctx, boolean isInbound, boolean isExploratory) {
|
||||
boolean def = true;
|
||||
String val = null;
|
||||
|
||||
if (isExploratory)
|
||||
protected boolean filterSlow(boolean isInbound, boolean isExploratory) {
|
||||
if (isExploratory) {
|
||||
if (isInbound)
|
||||
val = ctx.getProperty(PROP_INBOUND_EXPLORATORY_EXCLUDE_SLOW);
|
||||
return ctx.getProperty(PROP_INBOUND_EXPLORATORY_EXCLUDE_SLOW, true);
|
||||
else
|
||||
val = ctx.getProperty(PROP_OUTBOUND_EXPLORATORY_EXCLUDE_SLOW);
|
||||
else
|
||||
return ctx.getProperty(PROP_OUTBOUND_EXPLORATORY_EXCLUDE_SLOW, true);
|
||||
} else {
|
||||
if (isInbound)
|
||||
val = ctx.getProperty(PROP_INBOUND_CLIENT_EXCLUDE_SLOW);
|
||||
return ctx.getProperty(PROP_INBOUND_CLIENT_EXCLUDE_SLOW, true);
|
||||
else
|
||||
val = ctx.getProperty(PROP_OUTBOUND_CLIENT_EXCLUDE_SLOW);
|
||||
|
||||
boolean rv = (val != null ? Boolean.parseBoolean(val) : def);
|
||||
//System.err.println("Filter unreachable? " + rv + " (inbound? " + isInbound + ", exploratory? " + isExploratory);
|
||||
return rv;
|
||||
return ctx.getProperty(PROP_OUTBOUND_CLIENT_EXCLUDE_SLOW, true);
|
||||
}
|
||||
}
|
||||
|
||||
/****
|
||||
private static final String PROP_OUTBOUND_EXPLORATORY_EXCLUDE_UPTIME = "router.outboundExploratoryExcludeUptime";
|
||||
private static final String PROP_OUTBOUND_CLIENT_EXCLUDE_UPTIME = "router.outboundClientExcludeUptime";
|
||||
private static final String PROP_INBOUND_EXPLORATORY_EXCLUDE_UPTIME = "router.inboundExploratoryExcludeUptime";
|
||||
private static final String PROP_INBOUND_CLIENT_EXCLUDE_UPTIME = "router.inboundClientExcludeUptime";
|
||||
****/
|
||||
|
||||
/**
|
||||
* do we want to skip peers who haven't been up for long?
|
||||
* @return true unless configured otherwise
|
||||
*/
|
||||
protected boolean filterUptime(RouterContext ctx, boolean isInbound, boolean isExploratory) {
|
||||
boolean def = true;
|
||||
String val = null;
|
||||
|
||||
if (isExploratory)
|
||||
/****
|
||||
protected boolean filterUptime(boolean isInbound, boolean isExploratory) {
|
||||
if (isExploratory) {
|
||||
if (isInbound)
|
||||
val = ctx.getProperty(PROP_INBOUND_EXPLORATORY_EXCLUDE_UPTIME);
|
||||
return ctx.getProperty(PROP_INBOUND_EXPLORATORY_EXCLUDE_UPTIME, true);
|
||||
else
|
||||
val = ctx.getProperty(PROP_OUTBOUND_EXPLORATORY_EXCLUDE_UPTIME);
|
||||
else
|
||||
return ctx.getProperty(PROP_OUTBOUND_EXPLORATORY_EXCLUDE_UPTIME, true);
|
||||
} else {
|
||||
if (isInbound)
|
||||
val = ctx.getProperty(PROP_INBOUND_CLIENT_EXCLUDE_UPTIME);
|
||||
return ctx.getProperty(PROP_INBOUND_CLIENT_EXCLUDE_UPTIME, true);
|
||||
else
|
||||
val = ctx.getProperty(PROP_OUTBOUND_CLIENT_EXCLUDE_UPTIME);
|
||||
|
||||
boolean rv = (val != null ? Boolean.parseBoolean(val) : def);
|
||||
//System.err.println("Filter unreachable? " + rv + " (inbound? " + isInbound + ", exploratory? " + isExploratory);
|
||||
return rv;
|
||||
return ctx.getProperty(PROP_OUTBOUND_CLIENT_EXCLUDE_UPTIME, true);
|
||||
}
|
||||
}
|
||||
****/
|
||||
|
||||
/** see HashComparator */
|
||||
protected void orderPeers(List rv, Hash hash) {
|
||||
if (rv.size() > 1)
|
||||
Collections.sort(rv, new HashComparator(hash));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user