Tunnels: getUnknownOptions() is non-null

one more TunnelId fixup
This commit is contained in:
zzz
2020-11-07 13:53:44 +00:00
parent 5bafdd05a9
commit a2fd817915
4 changed files with 15 additions and 12 deletions

View File

@ -277,6 +277,9 @@ public class TunnelPoolSettings {
*/
public int getPriority() { return _priority; }
/**
* @return non-null
*/
public Properties getUnknownOptions() { return _unknownOptions; }
/**

View File

@ -76,13 +76,13 @@ public abstract class BuildMessageGenerator {
Hash peer = cfg.getPeer(hop);
long recvTunnelId = -1;
if (cfg.isInbound() || (hop > 0))
recvTunnelId = hopConfig.getReceiveTunnel().getTunnelId();
recvTunnelId = hopConfig.getReceiveTunnelId();
else
recvTunnelId = 0;
long nextTunnelId = -1;
Hash nextPeer = null;
if (hop + 1 < cfg.getLength()) {
nextTunnelId = cfg.getConfig(hop+1).getReceiveTunnel().getTunnelId();
nextTunnelId = cfg.getConfig(hop+1).getReceiveTunnelId();
nextPeer = cfg.getPeer(hop+1);
} else {
if ( (replyTunnel >= 0) && (replyRouter != null) ) {

View File

@ -47,6 +47,9 @@ class PooledTunnelCreatorConfig extends TunnelCreatorConfig {
return rv;
}
/**
* @return non-null
*/
@Override
public Properties getOptions() {
return _pool.getSettings().getUnknownOptions();

View File

@ -104,14 +104,12 @@ public abstract class TunnelPeerSelector extends ConnectChecker {
protected boolean shouldSelectExplicit(TunnelPoolSettings settings) {
if (settings.isExploratory()) return false;
Properties opts = settings.getUnknownOptions();
if (opts != null) {
String peers = opts.getProperty("explicitPeers");
if (peers == null)
peers = ctx.getProperty("explicitPeers");
// only one out of 4 times so we don't break completely if peer doesn't build one
if (peers != null && ctx.random().nextInt(4) == 0)
return true;
}
String peers = opts.getProperty("explicitPeers");
if (peers == null)
peers = ctx.getProperty("explicitPeers");
// only one out of 4 times so we don't break completely if peer doesn't build one
if (peers != null && ctx.random().nextInt(4) == 0)
return true;
return false;
}
@ -123,8 +121,7 @@ public abstract class TunnelPeerSelector extends ConnectChecker {
protected List<Hash> selectExplicit(TunnelPoolSettings settings, int length) {
String peers = null;
Properties opts = settings.getUnknownOptions();
if (opts != null)
peers = opts.getProperty("explicitPeers");
peers = opts.getProperty("explicitPeers");
if (peers == null)
peers = ctx.getProperty("explicitPeers");