Port more config properties to AgentConfig (#254)
* test: Disable config caching for tests. * feat: Port SOFTWARE to AgentConfig. * feat: Port USE_COMPONENT_SOCKET to AgentConfig.
This commit is contained in:
parent
2baae57d53
commit
32a8aadae8
@ -86,12 +86,6 @@ public class StackProperties
|
||||
public static final String MAX_CTRAN_RETRANSMISSIONS
|
||||
= "org.ice4j.MAX_RETRANSMISSIONS";
|
||||
|
||||
/**
|
||||
* The value of the SOFTWARE attribute that ice4j should include in all
|
||||
* outgoing messages.
|
||||
*/
|
||||
public static final String SOFTWARE = "org.ice4j.SOFTWARE";
|
||||
|
||||
/**
|
||||
* The name of the property that tells the stack whether or not it should
|
||||
* let the application see retransmissions of incoming requests.
|
||||
@ -172,18 +166,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 per-component
|
||||
* merging socket should be enabled by default (the default value can be
|
||||
* overridden with {@link Agent#createComponent(IceMediaStream, Transport,
|
||||
* int, int, int, KeepAliveStrategy, boolean)}.
|
||||
* If enabled, the user of the library must use the socket instance provided
|
||||
* by {@link Component#getSocket()}. Otherwise, the socket instance from the
|
||||
* desired {@link CandidatePair} must be used.
|
||||
*/
|
||||
public static final String USE_COMPONENT_SOCKET
|
||||
= "org.ice4j.ice.USE_COMPONENT_SOCKET";
|
||||
|
||||
/**
|
||||
* Returns the String value of the specified property (minus all
|
||||
* encompassing whitespaces)and null in case no property value was mapped
|
||||
|
||||
@ -349,11 +349,6 @@ public class Agent
|
||||
//add the FINGERPRINT attribute to all messages.
|
||||
System.setProperty(StackProperties.ALWAYS_SIGN, "true");
|
||||
|
||||
//add the software attribute to all messages
|
||||
if (StackProperties.getString(StackProperties.SOFTWARE) == null)
|
||||
System.setProperty(StackProperties.SOFTWARE, "ice4j.org");
|
||||
|
||||
|
||||
password
|
||||
= ensureIceAttributeLength(
|
||||
new BigInteger(128, random).toString(32),
|
||||
@ -447,7 +442,7 @@ public class Agent
|
||||
stream,
|
||||
preferredPort, minPort, maxPort,
|
||||
KeepAliveStrategy.SELECTED_ONLY,
|
||||
StackProperties.getBoolean(StackProperties.USE_COMPONENT_SOCKET, true));
|
||||
config.getUseComponentSocket());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1063,8 +1063,7 @@ public class Component
|
||||
componentID,
|
||||
mediaStream,
|
||||
KeepAliveStrategy.SELECTED_ONLY,
|
||||
StackProperties.getBoolean(
|
||||
StackProperties.USE_COMPONENT_SOCKET, true),
|
||||
AgentConfig.config.getUseComponentSocket(),
|
||||
parentLogger
|
||||
);
|
||||
}
|
||||
|
||||
@ -170,7 +170,7 @@ public class IceMediaStream
|
||||
* @param keepAliveStrategy the keep-alive strategy, which dictates which
|
||||
* candidates pairs are going to be kept alive.
|
||||
* @param useComponentSocket whether the "component socket" should be used
|
||||
* or not. See {@link StackProperties#USE_COMPONENT_SOCKET}.
|
||||
* or not. See {@link AgentConfig#getUseComponentSocket()}.
|
||||
*
|
||||
* @return the newly created stream <tt>Component</tt> after adding it to
|
||||
* the stream first.
|
||||
|
||||
@ -22,6 +22,7 @@ import java.util.logging.*;
|
||||
|
||||
import org.ice4j.*;
|
||||
import org.ice4j.attribute.*;
|
||||
import org.ice4j.ice.*;
|
||||
import org.ice4j.stack.*;
|
||||
|
||||
/**
|
||||
@ -1020,7 +1021,7 @@ public abstract class Message
|
||||
|
||||
//add a SOFTWARE attribute if the user said so, and unless they did it
|
||||
//themselves.
|
||||
String software = System.getProperty(StackProperties.SOFTWARE);
|
||||
String software = AgentConfig.config.getSoftware();
|
||||
|
||||
if (getAttribute(Attribute.SOFTWARE) == null
|
||||
&& software != null && software.length() > 0)
|
||||
|
||||
@ -55,6 +55,23 @@ class AgentConfig {
|
||||
"ice4j.ice.max-check-list-size".from(configSource)
|
||||
}
|
||||
|
||||
/** The value of the SOFTWARE attribute that ice4j should include in all outgoing messages. */
|
||||
val software: String? by config {
|
||||
"org.ice4j.SOFTWARE".from(configSource)
|
||||
"ice4j.software".from(configSource)
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the per-component merging socket should be enabled by default (the default value can be
|
||||
* overridden with the [Agent] API).
|
||||
* If enabled, the user of the library must use the socket instance provided by [Component.getSocket]. Otherwise,
|
||||
* the socket instance from the desired [CandidatePair] must be used.
|
||||
*/
|
||||
val useComponentSocket: Boolean by config {
|
||||
"org.ice4j.ice.USE_COMPONENT_SOCKET".from(configSource)
|
||||
"ice4j.use-component-socket".from(configSource)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val config = AgentConfig()
|
||||
|
||||
@ -6,6 +6,16 @@ ice4j {
|
||||
termination-delay = 3 seconds
|
||||
}
|
||||
|
||||
// The value of the SOFTWARE attribute that ice4j should include in all outgoing messages. Set to the empty string to
|
||||
// not include a SOFTWARE attribute.
|
||||
software = "ice4j.org"
|
||||
|
||||
// Whether the per-component merging socket should be enabled by default (the default value can be
|
||||
// overridden with the [Agent] API).
|
||||
// If enabled, the user of the library must use the socket instance provided by [Component.getSocket]. Otherwise,
|
||||
// the socket instance from the desired [CandidatePair] must be used.
|
||||
use-component-socket = true
|
||||
|
||||
consent-freshness {
|
||||
// How often a STUN Binding request used for consent freshness check will be sent.
|
||||
interval = 15 seconds
|
||||
|
||||
47
src/test/java/org/ice4j/TestExecutionListener.java
Normal file
47
src/test/java/org/ice4j/TestExecutionListener.java
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* ice4j, the OpenSource Java Solution for NAT and Firewall Traversal.
|
||||
*
|
||||
* Copyright @ 2015 Atlassian Pty Ltd
|
||||
*
|
||||
* 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;
|
||||
|
||||
import org.jitsi.metaconfig.*;
|
||||
import org.junit.platform.launcher.*;
|
||||
|
||||
public class TestExecutionListener implements org.junit.platform.launcher.TestExecutionListener {
|
||||
private static boolean initialized = false;
|
||||
|
||||
private static void beforeAll()
|
||||
{
|
||||
// Disable config caching.
|
||||
MetaconfigSettings.Companion.setCacheEnabled(false);
|
||||
}
|
||||
|
||||
public TestExecutionListener()
|
||||
{}
|
||||
|
||||
@Override
|
||||
public void executionStarted(TestIdentifier testIdentifier)
|
||||
{
|
||||
synchronized (TestExecutionListener.class)
|
||||
{
|
||||
if (!initialized)
|
||||
{
|
||||
beforeAll();
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -22,10 +22,27 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.ice4j.*;
|
||||
import org.ice4j.attribute.*;
|
||||
import org.ice4j.stack.*;
|
||||
import org.jitsi.config.*;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
public class MessageTest
|
||||
{
|
||||
|
||||
@BeforeAll
|
||||
public static void setupConfig()
|
||||
{
|
||||
System.clearProperty(StackProperties.ALWAYS_SIGN);
|
||||
System.setProperty("ice4j.software", "");
|
||||
JitsiConfig.Companion.reloadNewConfig();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void resetConfig()
|
||||
{
|
||||
System.clearProperty("ice4j.software");
|
||||
JitsiConfig.Companion.reloadNewConfig();
|
||||
}
|
||||
|
||||
private Message bindingRequest = null;
|
||||
private Message bindingResponse = null;
|
||||
|
||||
@ -45,8 +62,6 @@ public class MessageTest
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
System.clearProperty(StackProperties.ALWAYS_SIGN);
|
||||
System.clearProperty(StackProperties.SOFTWARE);
|
||||
msgFixture = new MsgFixture();
|
||||
|
||||
stunStack = new StunStack();
|
||||
|
||||
@ -26,6 +26,7 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.ice4j.*;
|
||||
import org.ice4j.message.*;
|
||||
import org.ice4j.socket.*;
|
||||
import org.jitsi.config.*;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
/**
|
||||
@ -35,6 +36,21 @@ import org.junit.jupiter.api.*;
|
||||
*/
|
||||
public class ShallowStackTest
|
||||
{
|
||||
@BeforeAll
|
||||
public static void setupConfig()
|
||||
{
|
||||
System.clearProperty(StackProperties.ALWAYS_SIGN);
|
||||
System.setProperty("ice4j.software", "");
|
||||
JitsiConfig.Companion.reloadNewConfig();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void resetConfig()
|
||||
{
|
||||
System.clearProperty("ice4j.software");
|
||||
JitsiConfig.Companion.reloadNewConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* The <tt>Logger</tt> used by the <tt>ShallowStackTest<tt> class and its
|
||||
* instances for logging output.
|
||||
@ -66,9 +82,6 @@ public class ShallowStackTest
|
||||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
System.clearProperty(StackProperties.ALWAYS_SIGN);
|
||||
System.clearProperty(StackProperties.SOFTWARE);
|
||||
|
||||
msgFixture = new MsgFixture();
|
||||
|
||||
//init the stack
|
||||
|
||||
@ -0,0 +1 @@
|
||||
org.ice4j.TestExecutionListener
|
||||
Loading…
x
Reference in New Issue
Block a user