Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce useLoopbackInterface to config #236

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ Default: no interfaces are blocked.
This property can be used to specify a ";"-separated list of interfaces which are
not allowed to be used for candidate allocations.

### ```org.ice4j.ice.harvest.USE_LOOPBACK_INTERFACES```
Default: false

Use (NAT-ed) loopback interfaces for ICE candidate selection.
FreeBSD jails often require this when NAT-ed on the internal lo0 interface with an IPv4 address.

### ```org.ice4j.ice.harvest.ALLOWED_ADDRESSES```
Default: all addresses are allowed.

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/ice4j/ice/harvest/AbstractTcpListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ private static List<TransportAddress> getLocalAddresses(

for (NetworkInterface iface : interfaces)
{
if (NetworkUtils.isInterfaceLoopback(iface)
|| !NetworkUtils.isInterfaceUp(iface)
if (NetworkUtils.isInterfaceLoopback(iface) && !config.useLoopbackInterfaces())
continue;
if (!NetworkUtils.isInterfaceUp(iface)
|| !HostCandidateHarvester.isInterfaceAllowed(iface))
{
//this one is obviously not going to do
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/ice4j/ice/harvest/HostCandidateHarvester.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ public static List<InetAddress> getAllAllowedAddresses()
for (NetworkInterface iface
: Collections.list(NetworkInterface.getNetworkInterfaces()))
{
if (NetworkUtils.isInterfaceLoopback(iface)
|| !NetworkUtils.isInterfaceUp(iface)
|| !isInterfaceAllowed(iface))
if (NetworkUtils.isInterfaceLoopback(iface) && !config.useLoopbackInterfaces())
continue;
if (!NetworkUtils.isInterfaceUp(iface) || !isInterfaceAllowed(iface))
{
continue;
}
Expand Down Expand Up @@ -316,9 +316,9 @@ public void harvest(Component component,
{
NetworkInterface iface = interfaces.nextElement();

if (NetworkUtils.isInterfaceLoopback(iface)
|| !NetworkUtils.isInterfaceUp(iface)
|| !isInterfaceAllowed(iface))
if (NetworkUtils.isInterfaceLoopback(iface) && !config.useLoopbackInterfaces())
continue;
if (!NetworkUtils.isInterfaceUp(iface) || !isInterfaceAllowed(iface))
{
//this one is obviously not going to do
continue;
Expand Down Expand Up @@ -497,7 +497,7 @@ static boolean isInterfaceAllowed(NetworkInterface iface)
*/
static boolean isAddressAllowed(InetAddress address)
{
if (address.isLoopbackAddress())
if (address.isLoopbackAddress() && !config.useLoopbackInterfaces())
{
return false;
}
Expand Down
7 changes: 7 additions & 0 deletions src/main/kotlin/org/ice4j/ice/harvest/HarvestConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ class HarvestConfig {
}
fun useIpv6() = useIpv6

private val useLoopbackInterfaces: Boolean by config {
"org.ice4j.ice.harvest.USE_LOOPBACK_INTERFACES".from(configSource)
.transformedBy { !it }
"ice4j.harvest.use-loopback-interfaces".from(configSource)
}
fun useLoopbackInterfaces() = useLoopbackInterfaces

val useDynamicPorts: Boolean by config {
"org.ice4j.ice.harvest.USE_DYNAMIC_HOST_HARVESTER".from(configSource)
"ice4j.harvest.udp.use-dynamic-ports".from(configSource)
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ ice4j {

// Configuration related to harvesting (aka gathering) of local candidates.
harvest {
// Use loopback (NAT-ed) interfaces for ICE candidate selection.
// FreeBSD jails often require this when NAT-ed on the internal lo0 interface with an IPv4 address.
use-loopback-interfaces = false

// Whether to harvest IPv6 addresses.
use-ipv6 = true
// Whether to use link-local addresses when harvesting candidates.
Expand Down