Package com.sshtools.synergy.ssh
Class LocalForwardingChannel<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.LocalForwardingChannel<T>
- All Implemented Interfaces:
Channel,ClientConnector,SelectionKeyAware,SelectorRegistrationListener,SocketHandler
public class LocalForwardingChannel<T extends SshContext>
extends SocketForwardingChannel<T>
implements ClientConnector
Implements a Local forwarding channel for use with forwarding sockets from
the client machine through the server to some endpoint reachable from the
server machine.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.sshtools.synergy.ssh.ChannelNG
ChannelNG.ChannelInputStream -
Field Summary
Fields 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
ConstructorsConstructorDescriptionLocalForwardingChannel(String channelType, SshConnection con) LocalForwardingChannel(String channelType, SshConnection con, String hostToConnect, int portToConnect, SocketChannel socketChannel) Constructs a forwarding channel of the type "forwarded-tcpip" -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanprotected byte[]Create the forwarding channel.protected SocketAddressprotected SocketChannelbooleanCalled 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.protected voidEither nothing was listening on the clients end of the tunnel, or the connection was rejected.protected voidprotected voidprotected voidCalled when the forwarded sockets selector has been registered with a {@link com,maverick.nio.SelectorThread}.protected byte[]openChannel(byte[] requestdata) Open a forwarding channel.protected voidreadForwarding(com.sshtools.common.util.ByteArrayReader bar) 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
-
Constructor Details
-
LocalForwardingChannel
-
LocalForwardingChannel
public LocalForwardingChannel(String channelType, SshConnection con, String hostToConnect, int portToConnect, SocketChannel socketChannel) Constructs a forwarding channel of the type "forwarded-tcpip"- Parameters:
addressToBind- StringportToBind- intsocketChannel- SocketChannel
-
-
Method Details
-
createChannel
Create the forwarding channel.- Specified by:
createChannelin classSocketForwardingChannel<T extends SshContext>- Returns:
- byte[]
- Throws:
IOException
-
openChannel
Open a forwarding channel.- Specified by:
openChannelin classSocketForwardingChannel<T extends SshContext>- Parameters:
requestdata- byte[]- Returns:
- byte[]
- Throws:
WriteOperationRequestChannelOpenException
-
readForwarding
- Throws:
IOException
-
createSocketAddress
-
createSocketChannel
- Throws:
IOException
-
checkPermissions
protected boolean checkPermissions() -
onRegistrationComplete
protected void onRegistrationComplete()Called when the forwarded sockets selector has been registered with a {@link com,maverick.nio.SelectorThread}.- Specified by:
onRegistrationCompletein classSocketForwardingChannel<T extends SshContext>
-
finishConnect
Called when the forwarded socket has been connected.- Specified by:
finishConnectin interfaceClientConnector- Parameters:
key- SelectionKey- Returns:
- boolean
-
onConnectionError
-
onConnectionComplete
protected void onConnectionComplete() -
onChannelOpenConfirmation
protected void onChannelOpenConfirmation()Called when the channel has been confirmed as open.- Specified by:
onChannelOpenConfirmationin classSocketForwardingChannel<T extends SshContext>
-
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
-