feat: Allow useDynamicPorts to be set per-Agent.

This commit is contained in:
Boris Grozev 2021-12-29 15:29:03 -06:00 committed by bgrozev
parent 2e43ba1b3e
commit fc1498ef7e
2 changed files with 16 additions and 2 deletions

View File

@ -301,6 +301,11 @@ public class Agent
*/
private final Logger logger;
/**
* Whether this {@link Agent} should use dynamic ports. Can be overridden via {@link #setUseDynamicPorts(boolean)}.
*/
private boolean useDynamicPorts = HarvestConfig.config.useDynamicPorts();
/**
* Creates an empty <tt>Agent</tt> with no streams, and no address.
*/
@ -574,6 +579,14 @@ public class Agent
return new CandidatePair(local, remote);
}
/**
* Sets the flag for whether this {@link Agent} instance should use dynamic ports.
*/
public void setUseDynamicPorts(boolean value)
{
useDynamicPorts = value;
}
/**
* Uses all <tt>CandidateHarvester</tt>s currently registered with this
* <tt>Agent</tt> to obtain whatever addresses they can discover.
@ -607,7 +620,7 @@ public class Agent
logger.info("Gathering candidates for component " +
component.toShortString() +".");
if (HarvestConfig.config.useDynamicPorts())
if (useDynamicPorts)
{
hostCandidateHarvester.harvest(
component,

View File

@ -38,7 +38,8 @@ ice4j {
// The size in bytes to set on the UDP socket (SO_RCVBUF). If not specified, the default from the OS will be used.
#receive-buffer-size = 10485760
// Whether to allocate ephemeral ports for local candidates.
// Whether to allocate ephemeral ports for local candidates. This is the default value, and can be overridden
// for Agent instances.
use-dynamic-ports = true
}