Adds an property to disable the use of IPv6 link local addresses for candidate allocation.

This commit is contained in:
boris 2014-10-03 12:29:38 +00:00
parent 707d258084
commit 9eca04ecad
3 changed files with 31 additions and 0 deletions

View File

@ -161,6 +161,13 @@ 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 IPv6
* 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.

View File

@ -141,6 +141,10 @@ public class HostCandidateHarvester
StackProperties.DISABLE_IPv6,
false);
boolean isIPv6LinkLocalDisabled = StackProperties.getBoolean(
StackProperties.DISABLE_LINK_LOCAL_ADDRESSES,
false);
if(transport != Transport.UDP && transport != Transport.TCP)
{
throw new IllegalArgumentException(
@ -172,6 +176,13 @@ public class HostCandidateHarvester
continue;
}
if (isIPv6LinkLocalDisabled
&& (addr instanceof Inet6Address)
&& addr.isLinkLocalAddress())
{
continue;
}
if((addr instanceof Inet4Address) || !isIPv6Disabled)
{
IceSocketWrapper sock = null;

View File

@ -289,6 +289,10 @@ public class MultiplexingTcpHostHarvester
StackProperties.DISABLE_IPv6,
false);
boolean useIPv6LinkLocal = !StackProperties.getBoolean(
StackProperties.DISABLE_LINK_LOCAL_ADDRESSES,
false);
// White list from the configuration
String[] allowedAddressesStr
= StackProperties.getStringArray(StackProperties.ALLOWED_ADDRESSES,
@ -332,6 +336,15 @@ public class MultiplexingTcpHostHarvester
if (!useIPv6 && (address instanceof Inet6Address))
continue;
if (!useIPv6LinkLocal
&& (address instanceof Inet6Address)
&& address.isLinkLocalAddress())
{
logger.info("Not using link-local address " + address +" for"
+ " TCP candidates.");
continue;
}
if (allowedAddresses != null)
{
boolean found = false;