diff --git a/src/org/ice4j/ice/Component.java b/src/org/ice4j/ice/Component.java
index 435e40a..274c23d 100644
--- a/src/org/ice4j/ice/Component.java
+++ b/src/org/ice4j/ice/Component.java
@@ -7,14 +7,10 @@
*/
package org.ice4j.ice;
-import java.io.*;
-import java.net.*;
import java.util.*;
import java.util.logging.*;
import org.ice4j.*;
-import org.ice4j.ice.harvest.*;
-import org.ice4j.socket.*;
/**
* A component is a piece of a media stream requiring a single transport
@@ -281,81 +277,6 @@ public class Component
}
}
- /**
- * Creates a local TCP candidate for use with a specific remote GTalk TCP
- * candidate.
- *
- * @param remoteCandidate the GTalk TCP candidate that we'd like to connect
- * to.
- * @param localCandidate the local candidate that we are pairing
- * remoteCandidate with and that we should use as a source for the ice
- * ufrag and password.
- *
- * @return the newly created {@link LocalCandidate}
- */
- private LocalCandidate createLocalTcpCandidate4GTalk(
- RemoteCandidate remoteCandidate,
- LocalCandidate localCandidate)
- {
- MultiplexingSocket sock = new MultiplexingSocket();
- try
- {
- // if we use proxy (socks5, ...), the connect() timeout
- // may not be respected
- int timeout = sock.getSoTimeout();
- sock.setSoTimeout(1000);
- sock.connect(new InetSocketAddress(
- remoteCandidate.getTransportAddress().getAddress(),
- remoteCandidate.getTransportAddress().getPort()), 1000);
- sock.setSoTimeout(timeout);
- }
- catch(Exception e)
- {
- logger.info(
- "Failed to connect to "
- + remoteCandidate.getTransportAddress());
- try
- {
- sock.close();
- }
- catch (IOException ioex)
- {
- }
- return null;
- }
-
- try
- {
- if(remoteCandidate.getTransportAddress().getPort() == 443)
- {
- //SSL/TCP handshake
- OutputStream outputStream =
- sock.getOriginalOutputStream();
- InputStream inputStream = sock.getOriginalInputStream();
-
- if(!GoogleTurnSSLCandidateHarvester.sslHandshake(
- inputStream, outputStream))
- {
- logger.info("Failed to connect to SSL/TCP relay");
- return null;
- }
- }
-
- LocalCandidate newLocalCandidate =
- new HostCandidate(new IceTcpSocketWrapper(sock),
- this, Transport.TCP);
- parentStream.getParentAgent().getStunStack().addSocket(
- newLocalCandidate.getStunSocket(null));
- newLocalCandidate.setUfrag(localCandidate.getUfrag());
- return newLocalCandidate;
- }
- catch(IOException ioe)
- {
- logger.log(Level.INFO, "Failed to connect to SSL/TCP relay", ioe);
- return null;
- }
- }
-
/**
* Update ICE processing with new Candidates.
*/
diff --git a/src/org/ice4j/ice/harvest/GoogleTurnSSLCandidateHarvester.java b/src/org/ice4j/ice/harvest/GoogleTurnSSLCandidateHarvester.java
index f081a63..0a3c73a 100644
--- a/src/org/ice4j/ice/harvest/GoogleTurnSSLCandidateHarvester.java
+++ b/src/org/ice4j/ice/harvest/GoogleTurnSSLCandidateHarvester.java
@@ -45,7 +45,7 @@ public class GoogleTurnSSLCandidateHarvester
/**
* Data for the SSL message sent by the client.
*/
- static final byte SSL_CLIENT_HANDSHAKE[] =
+ public static final byte SSL_CLIENT_HANDSHAKE[] =
{
(byte)0x80, 0x46, 0x01, 0x03, 0x01, 0x00, 0x2d, 0x00,
0x00, 0x00, 0x10, 0x01, 0x00, (byte)0x80, 0x03, 0x00,
diff --git a/src/org/ice4j/socket/DelegatingSocket.java b/src/org/ice4j/socket/DelegatingSocket.java
index 4a7e912..df3a74f 100644
--- a/src/org/ice4j/socket/DelegatingSocket.java
+++ b/src/org/ice4j/socket/DelegatingSocket.java
@@ -87,6 +87,14 @@ public class DelegatingSocket
}
}
+ /**
+ * The SocketChannel (to be) returned by {@link #getChannel()}. If
+ * null, getChannel() forwards to {@link #delegate}. (If
+ * delegate is null, getChannel() invokes the
+ * super implementation.
+ */
+ protected final SocketChannel channel;
+
/**
* Delegate Socket.
*/
@@ -136,6 +144,8 @@ public class DelegatingSocket
/**
* Initializes a new DelegatingSocket.
*
+ * @param address
+ * @param port
* @see Socket#Socket(InetAddress, int)
*/
public DelegatingSocket(InetAddress address, int port)
@@ -147,6 +157,10 @@ public class DelegatingSocket
/**
* Initializes a new DelegatingSocket.
*
+ * @param address
+ * @param port
+ * @param localAddr
+ * @param localPort
* @see Socket#Socket(InetAddress, int, InetAddress, int)
*/
public DelegatingSocket(
@@ -160,6 +174,7 @@ public class DelegatingSocket
/**
* Initializes a new DelegatingSocket.
*
+ * @param proxy
* @see Socket#Socket(Proxy)
*/
public DelegatingSocket(Proxy proxy)
@@ -168,13 +183,30 @@ public class DelegatingSocket
}
/**
- * Initializes a new DelegatingSocket.
+ * Initializes a new DelegatingSocket instance which is to delegate
+ * (i.e. forwards) method calls to a specific Socket.
*
- * @param delegate delegating socket
+ * @param delegate the Socket the new instance is to delegate to
*/
public DelegatingSocket(Socket delegate)
+ {
+ this(delegate, (delegate == null) ? null : delegate.getChannel());
+ }
+
+ /**
+ * Initializes a new DelegatingSocket instance which is to delegate
+ * (i.e. forward) method calls to a specific Socket and to report
+ * (i.e. return) an association with a specific SocketChannel.
+ *
+ * @param delegate the Socket the new instance is to delegate to
+ * @param channel the SocketChannel to be returned by
+ * {@link #getChannel()}. If null, getChannel() forwards
+ * to delegate.
+ */
+ public DelegatingSocket(Socket delegate, SocketChannel channel)
{
this.delegate = delegate;
+ this.channel = channel;
delegateAsDelegatingSocket
= (delegate instanceof DelegatingSocket)
@@ -185,6 +217,7 @@ public class DelegatingSocket
/**
* Initializes a new DelegatingSocket.
*
+ * @param impl
* @see Socket#Socket(SocketImpl)
*/
protected DelegatingSocket(SocketImpl impl)
@@ -196,6 +229,8 @@ public class DelegatingSocket
/**
* Initializes a new DelegatingSocket.
*
+ * @param host
+ * @param port
* @see Socket#Socket(String, int)
*/
public DelegatingSocket(String host, int port)
@@ -207,6 +242,10 @@ public class DelegatingSocket
/**
* Initializes a new DelegatingSocket.
*
+ * @param host
+ * @param port
+ * @param localAddr
+ * @param localPort
* @see Socket#Socket(String, int, InetAddress, int)
*/
public DelegatingSocket(
@@ -270,7 +309,18 @@ public class DelegatingSocket
@Override
public SocketChannel getChannel()
{
- return (delegate == null) ? super.getChannel() : delegate.getChannel();
+ SocketChannel channel = this.channel;
+
+ if (channel == null)
+ {
+ Socket delegate = this.delegate;
+
+ channel
+ = (delegate == null)
+ ? super.getChannel()
+ : delegate.getChannel();
+ }
+ return channel;
}
/**