fix: Fix creating STUN harvesters when no local addresses are allowed. (#265)
This commit is contained in:
parent
28a23e1859
commit
76e8a1968d
@ -220,17 +220,14 @@ public class MappingCandidateHarvesters
|
|||||||
|
|
||||||
List<Callable<StunMappingCandidateHarvester>> tasks = new LinkedList<>();
|
List<Callable<StunMappingCandidateHarvester>> tasks = new LinkedList<>();
|
||||||
|
|
||||||
// Create a StunMappingCandidateHarvester for each local:remote address
|
// Create a StunMappingCandidateHarvester for each local:remote address pair.
|
||||||
// pair.
|
List<InetAddress> localAddresses = HostCandidateHarvester.getAllAllowedAddresses();
|
||||||
List<InetAddress> localAddresses
|
|
||||||
= HostCandidateHarvester.getAllAllowedAddresses();
|
|
||||||
for (String stunServer : stunServers)
|
for (String stunServer : stunServers)
|
||||||
{
|
{
|
||||||
String[] addressAndPort = stunServer.split(":");
|
String[] addressAndPort = stunServer.split(":");
|
||||||
if (addressAndPort.length < 2)
|
if (addressAndPort.length < 2)
|
||||||
{
|
{
|
||||||
logger.severe("Failed to parse STUN server address: "
|
logger.severe("Failed to parse STUN server address: " + stunServer);
|
||||||
+ stunServer);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int port;
|
int port;
|
||||||
@ -259,15 +256,12 @@ public class MappingCandidateHarvesters
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransportAddress localAddress
|
TransportAddress localAddress = new TransportAddress(localInetAddress, 0, Transport.UDP);
|
||||||
= new TransportAddress(localInetAddress, 0, Transport.UDP);
|
|
||||||
|
|
||||||
logger.info("Using " + remoteAddress + " for StunMappingCandidateHarvester (localAddress="
|
logger.info("Using " + remoteAddress + " for StunMappingCandidateHarvester (localAddress="
|
||||||
+ localAddress + ").");
|
+ localAddress + ").");
|
||||||
final StunMappingCandidateHarvester stunHarvester
|
final StunMappingCandidateHarvester stunHarvester
|
||||||
= new StunMappingCandidateHarvester(
|
= new StunMappingCandidateHarvester(localAddress, remoteAddress);
|
||||||
localAddress,
|
|
||||||
remoteAddress);
|
|
||||||
|
|
||||||
Callable<StunMappingCandidateHarvester> task = () ->
|
Callable<StunMappingCandidateHarvester> task = () ->
|
||||||
{
|
{
|
||||||
@ -278,8 +272,14 @@ public class MappingCandidateHarvesters
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now run discover() on all created harvesters in parallel and pick
|
if (tasks.isEmpty())
|
||||||
// the ones which succeeded.
|
{
|
||||||
|
logger.warning("STUN mapping harvesters are configured, but no allowed local addresses were found." +
|
||||||
|
" Not using STUN.");
|
||||||
|
return stunHarvesters;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now run discover() on all created harvesters in parallel and pick the ones which succeeded.
|
||||||
ExecutorService es = ExecutorFactory.createFixedThreadPool(tasks.size(), "ice4j.Harvester-executor-");
|
ExecutorService es = ExecutorFactory.createFixedThreadPool(tasks.size(), "ice4j.Harvester-executor-");
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user