public abstract class SocketForwardingChannel<T extends SshContext> extends ForwardingChannel<T> implements SocketHandler
ForwardingChannelChannelNG.ChannelInputStream| Modifier and Type | Field and Description |
|---|---|
protected java.nio.channels.SelectionKey |
key |
static java.lang.String |
LOCAL_FORWARDING_CHANNEL_TYPE |
static java.lang.String |
REMOTE_FORWARDING_CHANNEL_TYPE |
protected SelectorThread |
selectorThread |
protected java.nio.channels.SocketChannel |
socketChannel |
static java.lang.String |
X11_FORWARDING_CHANNEL_TYPE |
hostToConnect, originatingHost, originatingPort, portToConnectcache, con, connection, localWindow, remoteWindow| Constructor and Description |
|---|
SocketForwardingChannel(java.lang.String channeltype,
SshConnection con)
Construct the forwarding channel.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addTask(ConnectionAwareTask task)
Add a task to the executor
|
protected boolean |
canClose()
Can this channel close?
|
protected void |
cleanupSocket() |
protected CachingDataWindow |
createCache(int maximumWindowSpace) |
protected abstract byte[] |
createChannel()
Called when the channel is being created.
|
protected void |
evaluateClosure()
set the closePending flag to true and attempt to close the channel
|
protected void |
evaluateWindowSpace(int remaining) |
int |
getInitialOps()
Returns the current operations the handler is interested in
|
java.lang.String |
getName()
A name for this Socket
|
SelectorThread |
getSelectorThread()
Get the selector thread this handler is connected to.
|
void |
initialize(ProtocolEngine engine,
SshEngine daemon)
No initialisation is necessary so this method does nothing.
|
protected void |
onChannelClosed()
Called when the channel has been closed to enable resources to be freed.
|
protected void |
onChannelClosing()
does nothing
|
protected void |
onChannelData(java.nio.ByteBuffer data)
data has arrived from the end of the tunnel so add to the queue of data
heading towards the start of the tunnel
|
protected void |
onChannelFree()
does nothing
|
protected void |
onChannelOpen()
does nothing
|
protected abstract void |
onChannelOpenConfirmation()
Called 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
|
protected void |
onChannelRequest(java.lang.String parm1,
boolean parm2,
byte[] parm3)
Called when a channel request is received.
|
protected void |
onExtendedData(java.nio.ByteBuffer data,
int type)
does nothing
|
protected void |
onLocalEOF()
The start of the tunnel has gone EOF , if the end of the tunnel has already
gone EOF then close the tunnel.
|
protected abstract void |
onRegistrationComplete()
Called by the subsystem when the selector registration has been completed.
|
protected void |
onRemoteClose()
We override this to make sure that all data from the socket has been sent
before we close our side of the channel
|
protected void |
onRemoteEOF()
The end of the tunnel has gone EOF , if the start of the tunnel has already
gone EOF then close the tunnel.
|
protected abstract byte[] |
openChannel(byte[] parm1)
Called when the channel is being opened.
|
boolean |
processReadEvent()
read data from the start/end of tunnel and write it into the ssh tunnel.
|
boolean |
processWriteEvent()
read data from the ssh tunnel and write it to the start/end point.
|
void |
registrationCompleted(java.nio.channels.SelectableChannel channel,
java.nio.channels.SelectionKey key,
SelectorThread selectorThread)
The registration completed and its selector added to an available
SelectorThread |
void |
setSelectionKey(java.nio.channels.SelectionKey key) |
void |
setThread(SelectorThread thread)
Sets the selector thread for this connection
|
protected void |
shutdownSocket() |
boolean |
wantsRead()
Tell the selector that the handler wants to read.
|
boolean |
wantsWrite()
Tell the selector that the handler wants to write.
|
checkWindowSpace, getHost, getOriginatingHost, getOriginatingPort, getPortaddEventListener, clearIdleState, close, close, evaluateWindowSpace, getChannelType, getCloseFuture, getConnection, getConnectionProtocol, getContext, getInputStream, getLastActivity, getLocalId, getLocalPacket, getLocalWindow, getMaxiumRemotePacketSize, getMaxiumRemoteWindowSize, getOpenFuture, getOutputStream, getRemoteId, getRemotePacket, getRemoteWindow, getSessionIdentifier, getTimeout, haltIncomingData, isClosed, isClosing, isConnected, isIncomingDataHalted, isLocalEOF, isOpen, isRemoteEOF, log, log, log, logMessage, onChannelError, onChannelOpenFailure, onWindowAdjust, processChannelRequestResponse, registerExtendedDataType, resetIdleState, resumeIncomingData, sendChannelDataAndBlock, sendChannelDataAndBlock, sendChannelDataAndBlock, sendChannelDataAndBlock, sendChannelDataAndBlock, sendChannelDataAndBlock, sendChannelRequest, sendChannelRequest, sendData, sendEOF, sendExtendedData, sendExtendedData, sendRequestResponse, sendWindowAdjust, sendWindowAdjust, setTimeoutclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetConnection, getContext, initializepublic static final java.lang.String LOCAL_FORWARDING_CHANNEL_TYPE
public static final java.lang.String REMOTE_FORWARDING_CHANNEL_TYPE
public static final java.lang.String X11_FORWARDING_CHANNEL_TYPE
protected java.nio.channels.SocketChannel socketChannel
protected SelectorThread selectorThread
protected java.nio.channels.SelectionKey key
public SocketForwardingChannel(java.lang.String channeltype,
SshConnection con)
channeltype - the type of channel i.e. "forwarded-tcpip"protected CachingDataWindow createCache(int maximumWindowSpace)
createCache in class ChannelNG<T extends SshContext>public void setSelectionKey(java.nio.channels.SelectionKey key)
setSelectionKey in interface SelectionKeyAwareprotected void onChannelOpen()
onChannelOpen in class ChannelNG<T extends SshContext>public void initialize(ProtocolEngine engine, SshEngine daemon)
protected abstract byte[] createChannel()
throws java.io.IOException
ChannelNGcreateChannel in class ChannelNG<T extends SshContext>java.io.IOExceptionprotected void onExtendedData(java.nio.ByteBuffer data,
int type)
onExtendedData in class ChannelNG<T extends SshContext>protected abstract void onRegistrationComplete()
public void registrationCompleted(java.nio.channels.SelectableChannel channel,
java.nio.channels.SelectionKey key,
SelectorThread selectorThread)
SelectorRegistrationListenerSelectorThreadregistrationCompleted in interface SelectorRegistrationListenerchannel - SelectableChannelkey - SelectionKeyselectorThread - SelectorThreadprotected void onChannelData(java.nio.ByteBuffer data)
onChannelData in class ChannelNG<T extends SshContext>protected void onChannelRequest(java.lang.String parm1,
boolean parm2,
byte[] parm3)
ChannelNGonChannelRequest in class ChannelNG<T extends SshContext>protected void onChannelFree()
onChannelFree in class ChannelNG<T extends SshContext>protected void onChannelClosing()
onChannelClosing in class ChannelNG<T extends SshContext>protected void cleanupSocket()
protected boolean canClose()
ChannelNGcanClose in class ChannelNG<T extends SshContext>protected void evaluateClosure()
protected void shutdownSocket()
protected void onChannelClosed()
ChannelNGonChannelClosed in class ChannelNG<T extends SshContext>protected void onLocalEOF()
onLocalEOF in class ChannelNG<T extends SshContext>protected void onRemoteClose()
onRemoteClose in class ChannelNG<T extends SshContext>protected void onRemoteEOF()
onRemoteEOF in class ChannelNG<T extends SshContext>protected abstract void onChannelOpenConfirmation()
ChannelNGonChannelOpenConfirmation in class ChannelNG<T extends SshContext>protected void evaluateWindowSpace(int remaining)
protected abstract byte[] openChannel(byte[] parm1)
throws WriteOperationRequest,
ChannelOpenException
ChannelNGopenChannel in class ChannelNG<T extends SshContext>WriteOperationRequestChannelOpenExceptionpublic boolean processReadEvent()
processReadEvent in interface SocketHandlerpublic boolean processWriteEvent()
processWriteEvent in interface SocketHandlerpublic boolean wantsWrite()
SocketHandlerwantsWrite in interface SocketHandlerpublic boolean wantsRead()
SocketHandlerwantsRead in interface SocketHandlerpublic int getInitialOps()
SocketHandlergetInitialOps in interface SocketHandlerpublic void setThread(SelectorThread thread)
setThread in interface SocketHandlerthread - SelectorThreadpublic void addTask(ConnectionAwareTask task)
SocketHandleraddTask in interface SocketHandlerpublic SelectorThread getSelectorThread()
SocketHandlergetSelectorThread in interface SocketHandlerpublic java.lang.String getName()
SocketHandlergetName in interface SocketHandlerCopyright © 2021. All rights reserved.