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();