Package com.sshtools.synergy.ssh
Class ConnectionProtocol<T extends SshContext>
java.lang.Object
com.sshtools.common.ssh.ExecutorOperationSupport<SshContext>
com.sshtools.synergy.ssh.ConnectionProtocol<T>
- All Implemented Interfaces:
Service
public abstract class ConnectionProtocol<T extends SshContext>
extends ExecutorOperationSupport<SshContext>
implements Service
This class implements the SSH Connection Protocol as an SSH Transport
Protocol service.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Connection<T>protected LinkedList<GlobalRequest>static final Stringprotected StringFields inherited from class com.sshtools.common.ssh.ExecutorOperationSupport
CALLBACKS, EVENTS, MESSAGES_INCOMING, MESSAGES_OUTGOING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGlobalRequestHandler(GlobalRequestHandler<T> handler) createChannel(String channeltype, Connection<T> con) voidDisconnect the current connection.Get the connectionsConfigurationContext.Information for logging purposes when an ignore message is sent during idle.intHow long does the service allow idle for?Get the local address to which the remote socket is connected.intGet the local port ro which the remote socket is connected.intintGet the address of the remote client.Get the underlying transport.Get the username for the connected user.getUUID()booleanidle()The service has reached idle timeout secondsprotected abstract booleanisClient()protected abstract voidonStart()protected abstract voidonStop()voidopenChannel(ChannelNG<T> channel) protected voidprocessGlobalRequestFailure(byte[] msg) Process a global request failureprotected voidprocessGlobalRequestSuccess(byte[] m) Process a global request success response.booleanprocessMessage(byte[] msg) Process a transport message.protected abstract booleanprocessTCPIPCancel(com.sshtools.common.util.ByteArrayReader bar, com.sshtools.common.util.ByteArrayWriter msg) protected abstract booleanprocessTCPIPForward(com.sshtools.common.util.ByteArrayReader bar, com.sshtools.common.util.ByteArrayWriter response) voidsendChannelOpenConfirmation(ChannelNG<T> channel, byte[] responsedata) voidsendChannelOpenFailure(ChannelNG<T> channel, int reason, String desc) voidsendGlobalRequest(GlobalRequest request, boolean wantReply) voidstart()Start the service.voidstop()Stop the serviceMethods inherited from class com.sshtools.common.ssh.ExecutorOperationSupport
addIncomingTask, addOutgoingTask, addTask, cleanupOperations
-
Field Details
-
SERVICE_NAME
- See Also:
-
outstandingRequests
-
username
-
con
-
-
Constructor Details
-
ConnectionProtocol
-
-
Method Details
-
addGlobalRequestHandler
-
getRemoteAddress
Get the address of the remote client.- Returns:
- SocketAddress
-
getLocalAddress
Get the local address to which the remote socket is connected.- Returns:
- InetAddress
-
getLocalPort
public int getLocalPort()Get the local port ro which the remote socket is connected.- Returns:
- int
-
getUsername
Get the username for the connected user.- Returns:
- String
-
onStop
protected abstract void onStop() -
stop
public void stop()Description copied from interface:ServiceStop the service -
getSessionIdentifier
-
openChannel
-
getActiveChannels
-
getMaxChannels
public int getMaxChannels() -
disconnect
public void disconnect()Disconnect the current connection. -
processMessage
Description copied from interface:ServiceProcess a transport message. When a message is received by theTransportProtocolthat is not a transport level message the message is passed onto the active service using this method. The service processes the message and returns a value to indicate whether the message was used.- Specified by:
processMessagein interfaceService- Returns:
- true if the message was processed, otherwise false
- Throws:
IOException
-
processGlobalRequestSuccess
protected void processGlobalRequestSuccess(byte[] m) Process a global request success response. -
processGlobalRequestFailure
protected void processGlobalRequestFailure(byte[] msg) Process a global request failure -
processTCPIPCancel
protected abstract boolean processTCPIPCancel(com.sshtools.common.util.ByteArrayReader bar, com.sshtools.common.util.ByteArrayWriter msg) throws IOException - Throws:
IOException
-
processTCPIPForward
protected abstract boolean processTCPIPForward(com.sshtools.common.util.ByteArrayReader bar, com.sshtools.common.util.ByteArrayWriter response) throws IOException - Throws:
IOException
-
createChannel
protected abstract ChannelNG<T> createChannel(String channeltype, Connection<T> con) throws UnsupportedChannelException, PermissionDeniedException, ChannelOpenException -
sendGlobalRequest
-
getQueueSize
public int getQueueSize() -
sendChannelOpenConfirmation
-
sendChannelOpenFailure
-
getContext
Get the connectionsConfigurationContext.- Specified by:
getContextin classExecutorOperationSupport<SshContext>- Returns:
- SshContext
-
getTransport
Get the underlying transport. Use with Caution.- Returns:
- TransportProtocol
-
start
public void start()Description copied from interface:ServiceStart the service. -
onStart
protected abstract void onStart() -
getUUID
-
getIdleTimeoutSeconds
public int getIdleTimeoutSeconds()Description copied from interface:ServiceHow long does the service allow idle for?- Specified by:
getIdleTimeoutSecondsin interfaceService- Returns:
-
idle
public boolean idle()Description copied from interface:ServiceThe service has reached idle timeout seconds -
isClient
protected abstract boolean isClient() -
getConnection
-
getIdleLog
Description copied from interface:ServiceInformation for logging purposes when an ignore message is sent during idle.- Specified by:
getIdleLogin interfaceService- Returns:
-