Package com.trilead.ssh2.transport
Class TransportManager
- java.lang.Object
-
- com.trilead.ssh2.transport.TransportManager
-
public class TransportManager extends java.lang.Object
TransportManager.- Version:
- $Id: TransportManager.java,v 1.2 2008/04/01 12:38:09 cplattne Exp $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
TransportManager.AsynchronousWorker
(package private) class
TransportManager.HandlerEntry
-
Field Summary
Fields Modifier and Type Field Description private java.util.Vector
asynchronousQueue
private java.lang.Thread
asynchronousThread
(package private) java.util.Vector
connectionMonitors
(package private) java.lang.Object
connectionSemaphore
(package private) boolean
flagKexOngoing
(package private) java.lang.String
hostname
(package private) KexManager
km
private static Logger
log
static int
MAX_PACKET_SIZE
Advertised maximum SSH packet size that the other side can send to us.(package private) java.util.Vector
messageHandlers
(package private) boolean
monitorsWereInformed
(package private) int
port
(package private) java.lang.Throwable
reasonClosedCause
(package private) java.lang.Thread
receiveThread
(package private) java.net.Socket
sock
private java.lang.String
sourceAddress
(package private) TransportConnection
tc
private ClientServerHello
versions
-
Constructor Summary
Constructors Constructor Description TransportManager(java.lang.String host, int port)
TransportManager(java.lang.String host, int port, java.lang.String sourceAddress)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
changeRecvCipher(BlockCipher bc, MAC mac)
void
changeSendCipher(BlockCipher bc, MAC mac)
void
close(java.lang.Throwable cause, boolean useDisconnectPacket)
private java.net.InetAddress
createInetAddress(java.lang.String host)
There were reports that there are JDKs which use the resolver even though one supplies a dotted IP address in the Socket constructor.private void
ensureConnected()
private void
establishConnection(ProxyData proxyData, int connectTimeout, int readTimeout)
void
forceKeyExchange(CryptoWishList cwl, DHGexParameters dhgex)
ConnectionInfo
getConnectionInfo(int kexNumber)
int
getPacketOverheadEstimate()
java.lang.Throwable
getReasonClosedCause()
If the socket connection is lost (either by this side closing down or the other side closing down),byte[]
getSessionIdentifier()
ClientServerHello
getVersionInfo()
void
initialize(CryptoWishList cwl, ServerHostKeyVerifier verifier, DHGexParameters dhgex, int connectTimeout, int readTimeout, java.security.SecureRandom rnd, ProxyData proxyData)
void
initialize(CryptoWishList cwl, ServerHostKeyVerifier verifier, DHGexParameters dhgex, int connectTimeout, java.security.SecureRandom rnd, ProxyData proxyData)
boolean
isConnectionClosed()
void
kexFinished()
private java.net.InetAddress
parseIPv4Address(java.lang.String host)
void
receiveLoop()
void
registerMessageHandler(MessageHandler mh, int low, int high)
void
removeMessageHandler(MessageHandler mh, int low, int high)
void
sendAsynchronousMessage(byte[] msg)
void
sendKexMessage(byte[] msg)
void
sendMessage(byte[] msg)
void
setConnectionMonitors(java.util.Vector monitors)
void
setSoTimeout(int timeout)
void
setTcpNoDelay(boolean state)
-
-
-
Field Detail
-
log
private static final Logger log
-
asynchronousQueue
private final java.util.Vector asynchronousQueue
-
asynchronousThread
private java.lang.Thread asynchronousThread
-
sourceAddress
private final java.lang.String sourceAddress
-
hostname
java.lang.String hostname
-
port
int port
-
sock
final java.net.Socket sock
-
connectionSemaphore
final java.lang.Object connectionSemaphore
-
flagKexOngoing
boolean flagKexOngoing
-
reasonClosedCause
java.lang.Throwable reasonClosedCause
-
tc
TransportConnection tc
-
km
KexManager km
-
messageHandlers
java.util.Vector messageHandlers
-
receiveThread
java.lang.Thread receiveThread
-
connectionMonitors
java.util.Vector connectionMonitors
-
monitorsWereInformed
boolean monitorsWereInformed
-
versions
private ClientServerHello versions
-
MAX_PACKET_SIZE
public static final int MAX_PACKET_SIZE
Advertised maximum SSH packet size that the other side can send to us.
-
-
Constructor Detail
-
TransportManager
public TransportManager(java.lang.String host, int port) throws java.io.IOException
- Throws:
java.io.IOException
-
TransportManager
public TransportManager(java.lang.String host, int port, java.lang.String sourceAddress) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
createInetAddress
private java.net.InetAddress createInetAddress(java.lang.String host) throws java.net.UnknownHostException
There were reports that there are JDKs which use the resolver even though one supplies a dotted IP address in the Socket constructor. That is why we try to generate the InetAdress "by hand".- Parameters:
host
-- Returns:
- the InetAddress
- Throws:
java.net.UnknownHostException
-
parseIPv4Address
private java.net.InetAddress parseIPv4Address(java.lang.String host) throws java.net.UnknownHostException
- Throws:
java.net.UnknownHostException
-
getPacketOverheadEstimate
public int getPacketOverheadEstimate()
-
setTcpNoDelay
public void setTcpNoDelay(boolean state) throws java.io.IOException
- Throws:
java.io.IOException
-
setSoTimeout
public void setSoTimeout(int timeout) throws java.io.IOException
- Throws:
java.io.IOException
-
getConnectionInfo
public ConnectionInfo getConnectionInfo(int kexNumber) throws java.io.IOException
- Throws:
java.io.IOException
-
getVersionInfo
public ClientServerHello getVersionInfo()
-
getReasonClosedCause
public java.lang.Throwable getReasonClosedCause()
If the socket connection is lost (either by this side closing down or the other side closing down),- Returns:
- a non-null object indicating the cause of the connection loss.
-
isConnectionClosed
public boolean isConnectionClosed()
-
getSessionIdentifier
public byte[] getSessionIdentifier()
-
close
public void close(java.lang.Throwable cause, boolean useDisconnectPacket)
-
establishConnection
private void establishConnection(ProxyData proxyData, int connectTimeout, int readTimeout) throws java.io.IOException
- Throws:
java.io.IOException
-
initialize
public void initialize(CryptoWishList cwl, ServerHostKeyVerifier verifier, DHGexParameters dhgex, int connectTimeout, java.security.SecureRandom rnd, ProxyData proxyData) throws java.io.IOException
- Throws:
java.io.IOException
-
initialize
public void initialize(CryptoWishList cwl, ServerHostKeyVerifier verifier, DHGexParameters dhgex, int connectTimeout, int readTimeout, java.security.SecureRandom rnd, ProxyData proxyData) throws java.io.IOException
- Throws:
java.io.IOException
-
registerMessageHandler
public void registerMessageHandler(MessageHandler mh, int low, int high)
-
removeMessageHandler
public void removeMessageHandler(MessageHandler mh, int low, int high)
-
sendKexMessage
public void sendKexMessage(byte[] msg) throws java.io.IOException
- Throws:
java.io.IOException
-
ensureConnected
private void ensureConnected() throws java.io.IOException
- Throws:
java.io.IOException
-
kexFinished
public void kexFinished() throws java.io.IOException
- Throws:
java.io.IOException
-
forceKeyExchange
public void forceKeyExchange(CryptoWishList cwl, DHGexParameters dhgex) throws java.io.IOException
- Throws:
java.io.IOException
-
changeRecvCipher
public void changeRecvCipher(BlockCipher bc, MAC mac)
-
changeSendCipher
public void changeSendCipher(BlockCipher bc, MAC mac)
-
sendAsynchronousMessage
public void sendAsynchronousMessage(byte[] msg) throws java.io.IOException
- Throws:
java.io.IOException
-
setConnectionMonitors
public void setConnectionMonitors(java.util.Vector monitors)
-
sendMessage
public void sendMessage(byte[] msg) throws java.io.IOException
- Throws:
java.io.IOException
-
receiveLoop
public void receiveLoop() throws java.io.IOException
- Throws:
java.io.IOException
-
-