Package com.sshtools.synergy.ssh
Class RemoteForwardingChannel<T extends SshContext>
java.lang.Object
com.sshtools.synergy.ssh.ChannelNG<T>
com.sshtools.synergy.ssh.ForwardingChannel<T>
com.sshtools.synergy.ssh.SocketForwardingChannel<T>
com.sshtools.synergy.ssh.RemoteForwardingChannel<T>
- All Implemented Interfaces:
Channel,ClientConnector,SelectionKeyAware,SelectorRegistrationListener,SocketHandler
public class RemoteForwardingChannel<T extends SshContext>
extends SocketForwardingChannel<T>
implements ClientConnector
Implements a Remote forwarding channel for use with forwarding sockets from
the server machine through the client to some endpoint reachable from the
client machine.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.sshtools.synergy.ssh.ChannelNG
ChannelNG.ChannelInputStream -
Field Summary
FieldsFields inherited from class com.sshtools.synergy.ssh.SocketForwardingChannel
key, LOCAL_FORWARDING_CHANNEL_TYPE, REMOTE_FORWARDING_CHANNEL_TYPE, selectorThread, socketChannel, X11_FORWARDING_CHANNEL_TYPEFields inherited from class com.sshtools.synergy.ssh.ForwardingChannel
hostToConnect, originatingHost, originatingPort, portToConnectFields inherited from class com.sshtools.synergy.ssh.ChannelNG
cache, con, connection, localWindow, remoteWindow -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRemoteForwardingChannel(SshConnection con, String addressToBind, int portToBind, SocketChannel socketChannel) Constructs a forwarding channel of the type "forwarded-tcpip"RemoteForwardingChannel(String name, SshConnection con, String addressToBind, int portToBind, SocketChannel socketChannel, T context) -
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]Creates the end of the channel open message string address that was connected uint32 port that was connected string originator IP address uint32 originator portprotected SocketAddressprotected voidbooleanCalled when the forwarded socket has been connected.voidinitialize(ProtocolEngine engine, SshEngine daemon, SelectableChannel channel) Initialise this socket with aProtocolEngineand the currentSshEngine.protected voidCalled when the channel has been confirmed as open by the remote side - this method is only called when the channel has been requested by this side of the connectionprotected voidEither nothing was listening on the clients end of the tunnel, or the connection was rejected.protected voidCalled by the subsystem when the selector registration has been completed.protected byte[]openChannel(byte[] requestdata) Called when the channel is being opened.Methods inherited from class com.sshtools.synergy.ssh.SocketForwardingChannel
addTask, canClose, cleanupSocket, createCache, evaluateClosure, evaluateWindowSpace, getInitialOps, getName, getSelectorThread, initialize, onChannelClosed, onChannelClosing, onChannelData, onChannelFree, onChannelOpen, onChannelRequest, onExtendedData, onLocalEOF, onRemoteClose, onRemoteEOF, processReadEvent, processWriteEvent, registrationCompleted, setSelectionKey, setThread, shutdownSocket, wantsRead, wantsWriteMethods inherited from class com.sshtools.synergy.ssh.ForwardingChannel
getHost, getOriginatingHost, getOriginatingPort, getPortMethods inherited from class com.sshtools.synergy.ssh.ChannelNG
addEventListener, checkWindowSpace, clearIdleState, close, close, close, disposeCache, evaluateWindowSpace, getChannelType, getCloseFuture, getConnection, getConnectionProtocol, getContext, getInputStream, getLastActivity, getLocalId, getLocalPacket, getLocalWindow, getMaxiumRemotePacketSize, getMaxiumRemoteWindowSize, getOpenFuture, getOutputStream, getRemoteId, getRemotePacket, getRemoteWindow, getSessionIdentifier, getTimeout, haltIncomingData, isAutoConsume, isClosed, isClosing, isConnected, isIncomingDataHalted, isLocalEOF, isOpen, isRemoteEOF, log, log, log, log, logMessage, logMessage, onChannelError, onWindowAdjust, processChannelRequestResponse, registerExtendedDataType, resetIdleState, resumeIncomingData, sendChannelDataAndBlock, sendChannelDataAndBlock, sendChannelDataAndBlock, sendChannelDataAndBlock, sendChannelDataAndBlock, sendChannelDataAndBlock, sendChannelRequest, sendChannelRequest, sendData, sendEOF, sendExtendedData, sendExtendedData, sendRequestResponse, sendWindowAdjust, sendWindowAdjust, setTimeoutMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.sshtools.synergy.nio.SelectorRegistrationListener
registrationCompletedMethods inherited from interface com.sshtools.synergy.nio.SocketHandler
getConnection, getContext
-
Field Details
-
hasConnected
protected boolean hasConnected
-
-
Constructor Details
-
RemoteForwardingChannel
public RemoteForwardingChannel(SshConnection con, String addressToBind, int portToBind, SocketChannel socketChannel) Constructs a forwarding channel of the type "forwarded-tcpip"- Parameters:
addressToBind- StringportToBind- intsocketChannel- SocketChannel
-
RemoteForwardingChannel
-
RemoteForwardingChannel
public RemoteForwardingChannel(String name, SshConnection con, String addressToBind, int portToBind, SocketChannel socketChannel, T context) - Parameters:
name-addressToBind-portToBind-socketChannel-
-
-
Method Details
-
createChannel
Creates the end of the channel open message string address that was connected uint32 port that was connected string originator IP address uint32 originator port- Specified by:
createChannelin classSocketForwardingChannel<T extends SshContext>- Returns:
- byte[], the end of the channelopenmessage
- Throws:
IOException
-
onRegistrationComplete
protected void onRegistrationComplete()Description copied from class:SocketForwardingChannelCalled by the subsystem when the selector registration has been completed.- Specified by:
onRegistrationCompletein classSocketForwardingChannel<T extends SshContext>
-
onChannelOpenConfirmation
protected void onChannelOpenConfirmation()Description copied from class:ChannelNGCalled when the channel has been confirmed as open by the remote side - this method is only called when the channel has been requested by this side of the connection- Specified by:
onChannelOpenConfirmationin classSocketForwardingChannel<T extends SshContext>
-
openChannel
Description copied from class:ChannelNGCalled when the channel is being opened. You can retrun data to be sent in the channel open confirmation message, or null for none.- Specified by:
openChannelin classSocketForwardingChannel<T extends SshContext>- Returns:
- byte[]
- Throws:
WriteOperationRequestChannelOpenException
-
createSocketAddress
-
createSocketChannel
- Throws:
IOException
-
finishConnect
Called when the forwarded socket has been connected.- Specified by:
finishConnectin interfaceClientConnector- Parameters:
key- SelectionKey- Returns:
- boolean
-
onChannelOpenFailure
protected void onChannelOpenFailure()Either nothing was listening on the clients end of the tunnel, or the connection was rejected. Now we close the connection from the server to the start of the tunnel.- Overrides:
onChannelOpenFailurein classChannelNG<T extends SshContext>
-
initialize
Description copied from interface:SocketHandlerInitialise this socket with aProtocolEngineand the currentSshEngine.- Specified by:
initializein interfaceSocketHandler- Parameters:
engine- ProtocolEnginedaemon- Daemon
-