From 471f91b364c5fa996f12973554b2fd72e61b445c Mon Sep 17 00:00:00 2001 From: boris Date: Tue, 2 Jun 2015 12:22:14 +0000 Subject: [PATCH] Automatically adds a mapping for TCP when running on EC2. --- src/org/ice4j/ice/harvest/AwsCandidateHarvester.java | 2 +- .../ice/harvest/MultiplexingTcpHostHarvester.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/org/ice4j/ice/harvest/AwsCandidateHarvester.java b/src/org/ice4j/ice/harvest/AwsCandidateHarvester.java index 3577804..d07d46f 100644 --- a/src/org/ice4j/ice/harvest/AwsCandidateHarvester.java +++ b/src/org/ice4j/ice/harvest/AwsCandidateHarvester.java @@ -210,7 +210,7 @@ public class AwsCandidateHarvester * @return true if there appear to be decent chances for this * machine to be an AWS EC2 and false otherwise. */ - public static boolean smellsLikeAnEC2() + public synchronized static boolean smellsLikeAnEC2() { if (RUNNING_ON_EC2 == null) { diff --git a/src/org/ice4j/ice/harvest/MultiplexingTcpHostHarvester.java b/src/org/ice4j/ice/harvest/MultiplexingTcpHostHarvester.java index 05774d9..387a31d 100644 --- a/src/org/ice4j/ice/harvest/MultiplexingTcpHostHarvester.java +++ b/src/org/ice4j/ice/harvest/MultiplexingTcpHostHarvester.java @@ -628,6 +628,17 @@ public class MultiplexingTcpHostHarvester serverSocketChannels.add(channel); } + // Automatically add a mapping if we're on EC2 + TransportAddress ec2Face = AwsCandidateHarvester.getFace(); + TransportAddress ec2Mask; + if (ec2Face != null && + (ec2Mask = AwsCandidateHarvester.getMask()) != null) + { + addMappedAddress(ec2Mask.getAddress(), ec2Face.getAddress()); + logger.info("Adding an EC2 mapping for TCP: " + + ec2Face + "->" + ec2Mask); + } + acceptThread = new AcceptThread(); acceptThread.start();