public Socket establishSourceSideConnection(final String targetId, final Socket controlConnection)
throws IOException {
Socket result = null;
logger.debug("Trying to connect to {}", targetId); //$NON-NLS-1$
// this.connectToMediator(mediatorAddress);
final Token token = new Token(UUID.randomUUID());
this.sendConnectionRequest(controlConnection, targetId, token);
final Message receivedMessage = this.receiveMessage(controlConnection);
// if (this.isForwardedEndpointsMessage(receivedMessage)) {
logger.debug("Received forwarding endpoints message"); //$NON-NLS-1$
final List<XorMappedAddress> addresses = receivedMessage.getAttributes(XorMappedAddress.class);
final BlockingQueue<Socket> socketQueue = new ArrayBlockingQueue<Socket>(1);
final InetSocketAddress localAddress = (InetSocketAddress) controlConnection.getLocalSocketAddress();
final ConnectionListener connectionListener = new ConnectionListener(localAddress.getAddress(),
localAddress.getPort());
logger.debug("Starting hole puncher"); //$NON-NLS-1$
final SourceConnectionAuthenticator authentification = new SourceConnectionAuthenticator(token.getToken());
final HolePuncher hp = new HolePuncher(connectionListener, localAddress, socketQueue);
this.startHolePunching(addresses, authentification, hp);
boolean interrupted = false;
try {
while (result == null) {