Port more config properties. (#214)
* ref: Port the "disable link-local addresses" property. * ref: Port the receive buffer size property. * ref: Port the "disable ipv6" property. * ref: Port the "dynamic ports" propertty. * ref: Port the timeout property. * test: Add tests for the new properties.
This commit is contained in:
parent
f8a506ef70
commit
29ae8061ad
@ -138,11 +138,6 @@ public class StackProperties
|
||||
public static final String NOMINATION_TIMER
|
||||
= "org.ice4j.NOMINATION_TIMER";
|
||||
|
||||
/**
|
||||
* The name of the property used to disabled IPv6 support.
|
||||
*/
|
||||
public static final String DISABLE_IPv6 = "org.ice4j.ipv6.DISABLED";
|
||||
|
||||
/**
|
||||
* The name of the allowed interfaces property which specifies the allowed
|
||||
* interfaces for host candidate allocations.
|
||||
@ -167,13 +162,6 @@ public class StackProperties
|
||||
public static final String ALLOWED_ADDRESSES
|
||||
= "org.ice4j.ice.harvest.ALLOWED_ADDRESSES";
|
||||
|
||||
/**
|
||||
* The name of the property which, if set to true, specifies that
|
||||
* link local addresses should not be used for candidate allocations.
|
||||
*/
|
||||
public static final String DISABLE_LINK_LOCAL_ADDRESSES
|
||||
= "org.ice4j.ice.harvest.DISABLE_LINK_LOCAL_ADDRESSES";
|
||||
|
||||
/**
|
||||
* The name of the property which specifies a ";"-separated list of IP
|
||||
* addresses that are not allowed to be used for host candidate allocations.
|
||||
@ -184,19 +172,6 @@ public class StackProperties
|
||||
public static final String BLOCKED_ADDRESSES
|
||||
= "org.ice4j.ice.harvest.BLOCKED_ADDRESSES";
|
||||
|
||||
/**
|
||||
* The name of the property which specifies whether the dynamic port UDP
|
||||
* host harvester should be used by <tt>Agent</tt> instances.
|
||||
*/
|
||||
public static final String USE_DYNAMIC_HOST_HARVESTER
|
||||
= "org.ice4j.ice.harvest.USE_DYNAMIC_HOST_HARVESTER";
|
||||
|
||||
/**
|
||||
* Timeout, in seconds, of how long to wait for an individual harvest before timing out
|
||||
*/
|
||||
public static final String HARVESTING_TIMEOUT
|
||||
= "org.ice4j.ice.harvest.HARVESTING_TIMEOUT";
|
||||
|
||||
/**
|
||||
* The name of the property which specifies whether the per-component
|
||||
* merging socket should be enabled by default (the default value can be
|
||||
|
||||
@ -296,12 +296,6 @@ public class Agent
|
||||
*/
|
||||
private boolean performConsentFreshness = false;
|
||||
|
||||
/**
|
||||
* The flag which specifies whether {@link #hostCandidateHarvester} should
|
||||
* be used or not.
|
||||
*/
|
||||
private Boolean useHostHarvester = null;
|
||||
|
||||
/**
|
||||
* The {@link Logger} used by {@link Agent} instances.
|
||||
*/
|
||||
@ -628,7 +622,7 @@ public class Agent
|
||||
logger.info("Gathering candidates for component " +
|
||||
component.toShortString() +".");
|
||||
|
||||
if (useHostHarvester())
|
||||
if (HarvestConfig.config.useDynamicPorts())
|
||||
{
|
||||
hostCandidateHarvester.harvest(
|
||||
component,
|
||||
@ -2588,34 +2582,6 @@ public class Agent
|
||||
this.performConsentFreshness = performConsentFreshness;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the dynamic host harvester should be used or not.
|
||||
* @return <tt>true</tt> if the dynamic host harvester should be used and
|
||||
* <tt>false</tt> otherwise.
|
||||
*/
|
||||
public boolean useHostHarvester()
|
||||
{
|
||||
if (useHostHarvester == null)
|
||||
{
|
||||
useHostHarvester
|
||||
= StackProperties.getBoolean(
|
||||
StackProperties.USE_DYNAMIC_HOST_HARVESTER,
|
||||
true);
|
||||
}
|
||||
|
||||
return useHostHarvester;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the flag which indicates whether the dynamic host harvester will
|
||||
* be used or not by this <tt>Agent</tt>.
|
||||
* @param useHostHarvester the value to set.
|
||||
*/
|
||||
public void setUseHostHarvester(boolean useHostHarvester)
|
||||
{
|
||||
this.useHostHarvester = useHostHarvester;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the logging level for this {@link Agent} and its components.
|
||||
* @param level the level to set.
|
||||
|
||||
@ -29,6 +29,8 @@ import java.nio.channels.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
|
||||
import static org.ice4j.ice.harvest.HarvestConfig.config;
|
||||
|
||||
/**
|
||||
* An abstract class that binds on a set of sockets and accepts sessions that
|
||||
* start with a STUN Binding Request (preceded by an optional fake SSL
|
||||
@ -283,13 +285,6 @@ public abstract class AbstractTcpListener
|
||||
protected void addLocalAddresses(List<TransportAddress> transportAddresses)
|
||||
throws IOException
|
||||
{
|
||||
boolean useIPv6 = !StackProperties.getBoolean(
|
||||
StackProperties.DISABLE_IPv6,
|
||||
false);
|
||||
boolean useLinkLocalAddresses = !StackProperties.getBoolean(
|
||||
StackProperties.DISABLE_LINK_LOCAL_ADDRESSES,
|
||||
false);
|
||||
|
||||
// White list from the configuration
|
||||
String[] allowedAddressesStr
|
||||
= StackProperties.getStringArray(StackProperties.ALLOWED_ADDRESSES,
|
||||
@ -301,8 +296,7 @@ public abstract class AbstractTcpListener
|
||||
allowedAddresses = new InetAddress[allowedAddressesStr.length];
|
||||
for (int i = 0; i < allowedAddressesStr.length; i++)
|
||||
{
|
||||
allowedAddresses[i]
|
||||
= InetAddress.getByName(allowedAddressesStr[i]);
|
||||
allowedAddresses[i] = InetAddress.getByName(allowedAddressesStr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -332,14 +326,12 @@ public abstract class AbstractTcpListener
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!useIPv6 && (address instanceof Inet6Address))
|
||||
if (!config.useIpv6() && (address instanceof Inet6Address))
|
||||
continue;
|
||||
|
||||
if (!useLinkLocalAddresses
|
||||
&& address.isLinkLocalAddress())
|
||||
if (!config.useLinkLocalAddresses() && address.isLinkLocalAddress())
|
||||
{
|
||||
logger.info("Not using link-local address " + address +" for"
|
||||
+ " TCP candidates.");
|
||||
logger.info("Not using link-local address " + address +" for TCP candidates.");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@ -29,6 +29,8 @@ import java.util.concurrent.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static org.ice4j.ice.harvest.HarvestConfig.config;
|
||||
|
||||
/**
|
||||
* A class which holds a {@link DatagramSocket} and runs a thread
|
||||
* ({@link #thread}) which perpetually reads from it.
|
||||
@ -43,14 +45,6 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
public abstract class AbstractUdpListener
|
||||
{
|
||||
/**
|
||||
* The name of the property which controls the size of the receive buffer
|
||||
* which {@link SinglePortUdpHarvester} will request for the sockets that
|
||||
* it creates.
|
||||
*/
|
||||
public static final String SO_RCVBUF_PNAME
|
||||
= AbstractUdpListener.class.getName() + ".SO_RCVBUF";
|
||||
|
||||
/**
|
||||
* Our class logger.
|
||||
*/
|
||||
@ -229,8 +223,8 @@ public abstract class AbstractUdpListener
|
||||
|
||||
socket = new DatagramSocket( this.localAddress );
|
||||
|
||||
int receiveBufferSize = StackProperties.getInt(SO_RCVBUF_PNAME, -1);
|
||||
if (receiveBufferSize > 0)
|
||||
Integer receiveBufferSize = config.udpReceiveBufferSize();
|
||||
if (receiveBufferSize != null)
|
||||
{
|
||||
socket.setReceiveBufferSize(receiveBufferSize);
|
||||
}
|
||||
@ -238,7 +232,7 @@ public abstract class AbstractUdpListener
|
||||
String logMessage
|
||||
= "Initialized AbstractUdpListener with address " + this.localAddress;
|
||||
logMessage += ". Receive buffer size " + socket.getReceiveBufferSize();
|
||||
if (receiveBufferSize > 0)
|
||||
if (receiveBufferSize != null)
|
||||
{
|
||||
logMessage += " (asked for " + receiveBufferSize + ")";
|
||||
}
|
||||
@ -253,8 +247,7 @@ public abstract class AbstractUdpListener
|
||||
}
|
||||
};
|
||||
|
||||
thread.setName(AbstractUdpListener.class.getName() + " thread for "
|
||||
+ this.localAddress);
|
||||
thread.setName(AbstractUdpListener.class.getName() + " thread for " + this.localAddress);
|
||||
thread.setDaemon(true);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
@ -198,7 +198,7 @@ public class CandidateHarvesterSet
|
||||
{
|
||||
try
|
||||
{
|
||||
future.get(StackProperties.getInt(StackProperties.HARVESTING_TIMEOUT, 15), TimeUnit.SECONDS);
|
||||
future.get(HarvestConfig.config.timeout().toMillis(), TimeUnit.MILLISECONDS);
|
||||
break;
|
||||
}
|
||||
catch (TimeoutException te)
|
||||
|
||||
@ -26,6 +26,8 @@ import org.ice4j.*;
|
||||
import org.ice4j.ice.*;
|
||||
import org.ice4j.socket.*;
|
||||
|
||||
import static org.ice4j.ice.harvest.HarvestConfig.config;
|
||||
|
||||
/**
|
||||
* A <tt>HostCandidateHarvester</tt> gathers host <tt>Candidate</tt>s for a
|
||||
* specified {@link org.ice4j.ice.Component}. Most <tt>CandidateHarvester</tt>s
|
||||
@ -229,13 +231,6 @@ public class HostCandidateHarvester
|
||||
public static List<InetAddress> getAllAllowedAddresses()
|
||||
{
|
||||
List<InetAddress> addresses = new LinkedList<>();
|
||||
boolean isIPv6Disabled = StackProperties.getBoolean(
|
||||
StackProperties.DISABLE_IPv6,
|
||||
false);
|
||||
boolean isLinkLocalAddressesDisabled = StackProperties.getBoolean(
|
||||
StackProperties.DISABLE_LINK_LOCAL_ADDRESSES,
|
||||
false);
|
||||
|
||||
try
|
||||
{
|
||||
for (NetworkInterface iface
|
||||
@ -257,10 +252,9 @@ public class HostCandidateHarvester
|
||||
if (!isAddressAllowed(address))
|
||||
continue;
|
||||
|
||||
if (isIPv6Disabled && address instanceof Inet6Address)
|
||||
if (!config.useIpv6() && address instanceof Inet6Address)
|
||||
continue;
|
||||
if (isLinkLocalAddressesDisabled
|
||||
&& address.isLinkLocalAddress())
|
||||
if (!config.useLinkLocalAddresses() && address.isLinkLocalAddress())
|
||||
continue;
|
||||
|
||||
addresses.add(address);
|
||||
@ -308,21 +302,11 @@ public class HostCandidateHarvester
|
||||
{
|
||||
harvestStatistics.startHarvestTiming();
|
||||
|
||||
Enumeration<NetworkInterface> interfaces
|
||||
= NetworkInterface.getNetworkInterfaces();
|
||||
|
||||
boolean isIPv6Disabled = StackProperties.getBoolean(
|
||||
StackProperties.DISABLE_IPv6,
|
||||
false);
|
||||
|
||||
boolean isLinkLocalAddressesDisabled = StackProperties.getBoolean(
|
||||
StackProperties.DISABLE_LINK_LOCAL_ADDRESSES,
|
||||
false);
|
||||
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
|
||||
|
||||
if(transport != Transport.UDP && transport != Transport.TCP)
|
||||
{
|
||||
throw new IllegalArgumentException(
|
||||
"Transport protocol not supported: " + transport);
|
||||
throw new IllegalArgumentException("Transport protocol not supported: " + transport);
|
||||
}
|
||||
|
||||
boolean boundAtLeastOneSocket = false;
|
||||
@ -352,22 +336,20 @@ public class HostCandidateHarvester
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isLinkLocalAddressesDisabled
|
||||
&& addr.isLinkLocalAddress())
|
||||
if (!config.useLinkLocalAddresses() && addr.isLinkLocalAddress())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
foundAtLeastOneUsableAddress = true;
|
||||
|
||||
if((addr instanceof Inet4Address) || !isIPv6Disabled)
|
||||
if((addr instanceof Inet4Address) || !config.useIpv6())
|
||||
{
|
||||
IceSocketWrapper sock = null;
|
||||
try
|
||||
{
|
||||
if(transport == Transport.UDP)
|
||||
{
|
||||
sock = createDatagramSocket(
|
||||
addr, preferredPort, minPort, maxPort);
|
||||
sock = createDatagramSocket(addr, preferredPort, minPort, maxPort);
|
||||
boundAtLeastOneSocket = true;
|
||||
}
|
||||
else if(transport == Transport.TCP)
|
||||
@ -402,10 +384,8 @@ public class HostCandidateHarvester
|
||||
continue;
|
||||
}
|
||||
|
||||
HostCandidate candidate
|
||||
= new HostCandidate(sock, component, transport);
|
||||
candidate.setVirtual(
|
||||
NetworkUtils.isInterfaceVirtual(iface));
|
||||
HostCandidate candidate = new HostCandidate(sock, component, transport);
|
||||
candidate.setVirtual(NetworkUtils.isInterfaceVirtual(iface));
|
||||
component.addLocalCandidate(candidate);
|
||||
|
||||
if (transport == Transport.TCP)
|
||||
@ -421,8 +401,7 @@ public class HostCandidateHarvester
|
||||
// them as well while harvesting reflexive candidates.
|
||||
createAndRegisterStunSocket(candidate);
|
||||
|
||||
ComponentSocket componentSocket
|
||||
= component.getComponentSocket();
|
||||
ComponentSocket componentSocket = component.getComponentSocket();
|
||||
if (componentSocket != null)
|
||||
{
|
||||
componentSocket.add(sock);
|
||||
@ -445,8 +424,7 @@ public class HostCandidateHarvester
|
||||
+ foundAtLeastOneUsableAddress);
|
||||
}
|
||||
|
||||
this.harvestStatistics
|
||||
.stopHarvestTiming(component.getLocalCandidateCount());
|
||||
this.harvestStatistics.stopHarvestTiming(component.getLocalCandidateCount());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
63
src/main/kotlin/org/ice4j/ice/harvest/HarvestConfig.kt
Normal file
63
src/main/kotlin/org/ice4j/ice/harvest/HarvestConfig.kt
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright @ 2020 - Present, 8x8 Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.ice4j.ice.harvest
|
||||
|
||||
import org.jitsi.metaconfig.config
|
||||
import org.jitsi.metaconfig.optionalconfig
|
||||
import java.time.Duration
|
||||
|
||||
import org.jitsi.config.JitsiConfig.Companion.newConfig as configSource
|
||||
|
||||
class HarvestConfig {
|
||||
val useLinkLocalAddresses: Boolean by config {
|
||||
"org.ice4j.ice.harvest.DISABLE_LINK_LOCAL_ADDRESSES".from(configSource)
|
||||
.transformedBy { !it }
|
||||
"ice4j.harvest.use-link-local-addresses".from(configSource)
|
||||
}
|
||||
fun useLinkLocalAddresses() = useLinkLocalAddresses
|
||||
|
||||
val udpReceiveBufferSize: Int? by optionalconfig {
|
||||
"org.ice4j.ice.harvest.AbstractUdpListener.SO_RCVBUF".from(configSource)
|
||||
"ice4j.harvest.udp.receive-buffer-size".from(configSource)
|
||||
}
|
||||
fun udpReceiveBufferSize() = udpReceiveBufferSize
|
||||
|
||||
val useIpv6: Boolean by config {
|
||||
"org.ice4j.ipv6.DISABLED".from(configSource)
|
||||
.transformedBy { !it }
|
||||
"ice4j.harvest.use-ipv6".from(configSource)
|
||||
}
|
||||
fun useIpv6() = useIpv6
|
||||
|
||||
val useDynamicPorts: Boolean by config {
|
||||
"org.ice4j.ice.harvest.USE_DYNAMIC_HOST_HARVESTER".from(configSource)
|
||||
"ice4j.harvest.udp.use-dynamic-ports".from(configSource)
|
||||
}
|
||||
fun useDynamicPorts() = useDynamicPorts
|
||||
|
||||
val timeout: Duration by config {
|
||||
"org.ice4j.ice.harvest.HARVESTING_TIMEOUT".from(configSource)
|
||||
.convertFrom<Long> { Duration.ofSeconds(it) }
|
||||
"ice4j.harvest.timeout".from(configSource)
|
||||
}
|
||||
fun timeout() = timeout
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val config = HarvestConfig()
|
||||
}
|
||||
}
|
||||
@ -1,25 +1,45 @@
|
||||
ice4j {
|
||||
ice {
|
||||
max-check-list-size = 100
|
||||
# The amount of time that we must wait after ICE processing enters a COMPLETED state before we free candidates
|
||||
# and move into the TERMINATED state.
|
||||
// The amount of time that we must wait after ICE processing enters a COMPLETED state before we free candidates
|
||||
// and move into the TERMINATED state.
|
||||
termination-delay = 3 seconds
|
||||
}
|
||||
|
||||
consent-freshness {
|
||||
# How often a STUN Binding request used for consent freshness check will be sent.
|
||||
// How often a STUN Binding request used for consent freshness check will be sent.
|
||||
interval = 15 seconds
|
||||
# The amount of time without a valid STUN Binding response after which a STUN Binding request is to be
|
||||
# retransmitted according to `STUN Usage for Consent Freshness` (RFC7675).
|
||||
# This is the original value for back-off strategy, while `max-wait-interval` sets the upper limit.
|
||||
// The amount of time without a valid STUN Binding response after which a STUN Binding request is to be
|
||||
// retransmitted according to `STUN Usage for Consent Freshness` (RFC7675).
|
||||
// This is the original value for back-off strategy, while `max-wait-interval` sets the upper limit.
|
||||
original-wait-interval = 500 milliseconds
|
||||
# The amount of time without a valid STUN Binding response after which a STUN Binding request is to be
|
||||
# retransmitted according to `STUN Usage for Consent Freshness` (RFC7675).
|
||||
# This is the final value for the back-off strategy, while `original-wait-interval` defines the initial interval for
|
||||
# the first request sent.
|
||||
// The amount of time without a valid STUN Binding response after which a STUN Binding request is to be
|
||||
// retransmitted according to `STUN Usage for Consent Freshness` (RFC7675).
|
||||
// This is the final value for the back-off strategy, while `original-wait-interval` defines the initial interval for
|
||||
// the first request sent.
|
||||
max-wait-interval = 500 milliseconds
|
||||
# The maximum number of retransmissions of a STUN Binding request without a valid STUN Binding response after which
|
||||
# consent freshness is to be considered unconfirmed according to `STUN Usage for Consent Freshness` (RFC7675).
|
||||
// The maximum number of retransmissions of a STUN Binding request without a valid STUN Binding response after which
|
||||
// consent freshness is to be considered unconfirmed according to `STUN Usage for Consent Freshness` (RFC7675).
|
||||
max-retransmissions = 30
|
||||
}
|
||||
|
||||
// Configuration related to harvesting (aka gathering) of local candidates.
|
||||
harvest {
|
||||
// Whether to harvest IPv6 addresses.
|
||||
use-ipv6 = true
|
||||
// Whether to use link-local addresses when harvesting candidates.
|
||||
use-link-local-addresses = true
|
||||
|
||||
// How long to wait for an individual harvest before timing out.
|
||||
timeout = 15 seconds
|
||||
|
||||
// Configuration for the "single port" UDP harvester.
|
||||
udp {
|
||||
// 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.
|
||||
use-dynamic-ports = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,10 +102,8 @@ public class RoleConflictResolutionTest
|
||||
throws IOException
|
||||
{
|
||||
final Agent agent = new Agent(label, null);
|
||||
agent.setUseHostHarvester(true);
|
||||
agent.setControlling(iceControlling);
|
||||
IceMediaStream iceStream
|
||||
= agent.createMediaStream("media-stream");
|
||||
IceMediaStream iceStream = agent.createMediaStream("media-stream");
|
||||
|
||||
agent.createComponent(
|
||||
iceStream,
|
||||
|
||||
101
src/test/kotlin/org/ice4j/ice/harvest/HarvestConfigTest.kt
Normal file
101
src/test/kotlin/org/ice4j/ice/harvest/HarvestConfigTest.kt
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright @ 2020 - present 8x8, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.ice4j.ice.harvest
|
||||
|
||||
import io.kotest.matchers.shouldBe
|
||||
import org.ice4j.ConfigTest
|
||||
import org.ice4j.ice.harvest.HarvestConfig.Companion.config
|
||||
import org.jitsi.utils.secs
|
||||
|
||||
class HarvestConfigTest : ConfigTest() {
|
||||
init {
|
||||
context("Default values") {
|
||||
config.timeout shouldBe 15.secs
|
||||
config.useDynamicPorts shouldBe true
|
||||
config.useIpv6 shouldBe true
|
||||
config.useLinkLocalAddresses shouldBe true
|
||||
config.udpReceiveBufferSize shouldBe null
|
||||
}
|
||||
context("Setting via legacy config (system properties)") {
|
||||
withLegacyConfig(legacyConfig) {
|
||||
config.timeout shouldBe 555.secs
|
||||
config.useDynamicPorts shouldBe false
|
||||
config.useIpv6 shouldBe false
|
||||
config.useLinkLocalAddresses shouldBe false
|
||||
config.udpReceiveBufferSize shouldBe 555
|
||||
}
|
||||
}
|
||||
context("Setting via new config") {
|
||||
withNewConfig(newConfigNonDefault) {
|
||||
config.timeout shouldBe 666.secs
|
||||
config.useDynamicPorts shouldBe false
|
||||
config.useIpv6 shouldBe false
|
||||
config.useLinkLocalAddresses shouldBe false
|
||||
config.udpReceiveBufferSize shouldBe 666
|
||||
}
|
||||
}
|
||||
context("Legacy config must take precedence") {
|
||||
withLegacyConfig(legacyConfig) {
|
||||
withNewConfig(newConfigDefault) {
|
||||
config.timeout shouldBe 555.secs
|
||||
config.useDynamicPorts shouldBe false
|
||||
config.useIpv6 shouldBe false
|
||||
config.useLinkLocalAddresses shouldBe false
|
||||
config.udpReceiveBufferSize shouldBe 555
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val legacyConfig = mapOf(
|
||||
"org.ice4j.ice.harvest.HARVESTING_TIMEOUT" to "555",
|
||||
"org.ice4j.ice.harvest.USE_DYNAMIC_HOST_HARVESTER" to "false",
|
||||
"org.ice4j.ipv6.DISABLED" to "true",
|
||||
"org.ice4j.ice.harvest.DISABLE_LINK_LOCAL_ADDRESSES" to "true",
|
||||
"org.ice4j.ice.harvest.AbstractUdpListener.SO_RCVBUF" to "555"
|
||||
)
|
||||
|
||||
// New config which overrides the default
|
||||
private val newConfigNonDefault = """
|
||||
ice4j {
|
||||
harvest {
|
||||
timeout = 666 seconds
|
||||
use-ipv6 = false
|
||||
use-link-local-addresses = false
|
||||
udp {
|
||||
receive-buffer-size = 666
|
||||
use-dynamic-ports = false
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
// New config which does not override the defaults (to test precedence).
|
||||
private val newConfigDefault = """
|
||||
ice4j {
|
||||
harvest {
|
||||
timeout = 666 seconds
|
||||
use-ipv6 = true
|
||||
use-link-local-addresses = true
|
||||
udp {
|
||||
receive-buffer-size = 666
|
||||
use-dynamic-ports = true
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
Loading…
x
Reference in New Issue
Block a user