Fixes warnings. Adds javadocs.
This commit is contained in:
parent
bd3f6c663f
commit
c7b8fd2e2b
@ -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 <tt>Candidate</tt>s.
|
||||
*/
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -87,6 +87,14 @@ public class DelegatingSocket
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The <tt>SocketChannel</tt> (to be) returned by {@link #getChannel()}. If
|
||||
* <tt>null</tt>, <tt>getChannel()</tt> forwards to {@link #delegate}. (If
|
||||
* <tt>delegate</tt> is <tt>null</tt>, <tt>getChannel()</tt> invokes the
|
||||
* super implementation.
|
||||
*/
|
||||
protected final SocketChannel channel;
|
||||
|
||||
/**
|
||||
* Delegate <tt>Socket</tt>.
|
||||
*/
|
||||
@ -136,6 +144,8 @@ public class DelegatingSocket
|
||||
/**
|
||||
* Initializes a new <tt>DelegatingSocket</tt>.
|
||||
*
|
||||
* @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 <tt>DelegatingSocket</tt>.
|
||||
*
|
||||
* @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 <tt>DelegatingSocket</tt>.
|
||||
*
|
||||
* @param proxy
|
||||
* @see Socket#Socket(Proxy)
|
||||
*/
|
||||
public DelegatingSocket(Proxy proxy)
|
||||
@ -168,13 +183,30 @@ public class DelegatingSocket
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new <tt>DelegatingSocket</tt>.
|
||||
* Initializes a new <tt>DelegatingSocket</tt> instance which is to delegate
|
||||
* (i.e. forwards) method calls to a specific <tt>Socket</tt>.
|
||||
*
|
||||
* @param delegate delegating socket
|
||||
* @param delegate the <tt>Socket</tt> the new instance is to delegate to
|
||||
*/
|
||||
public DelegatingSocket(Socket delegate)
|
||||
{
|
||||
this(delegate, (delegate == null) ? null : delegate.getChannel());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new <tt>DelegatingSocket</tt> instance which is to delegate
|
||||
* (i.e. forward) method calls to a specific <tt>Socket</tt> and to report
|
||||
* (i.e. return) an association with a specific <tt>SocketChannel</tt>.
|
||||
*
|
||||
* @param delegate the <tt>Socket</tt> the new instance is to delegate to
|
||||
* @param channel the <tt>SocketChannel</tt> to be returned by
|
||||
* {@link #getChannel()}. If <tt>null</tt>, <tt>getChannel()</tt> forwards
|
||||
* to <tt>delegate</tt>.
|
||||
*/
|
||||
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 <tt>DelegatingSocket</tt>.
|
||||
*
|
||||
* @param impl
|
||||
* @see Socket#Socket(SocketImpl)
|
||||
*/
|
||||
protected DelegatingSocket(SocketImpl impl)
|
||||
@ -196,6 +229,8 @@ public class DelegatingSocket
|
||||
/**
|
||||
* Initializes a new <tt>DelegatingSocket</tt>.
|
||||
*
|
||||
* @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 <tt>DelegatingSocket</tt>.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user