public abstract class SocketForwardingChannel extends ForwardingChannel implements SocketHandler, Runnable
An abstract forwarding channel implementation for use with forwarding both local and remote sockets.
ForwardingChannelChannel.DataBlock, Channel.QueuedDatahostToConnect, originatingHost, originatingPort, portToConnectconnection, localwindow, localWindowLock| Constructor and Description |
|---|
SocketForwardingChannel(String channeltype)
Construct the forwarding channel.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
canClose()
Can this channel close?
|
protected boolean |
canClose(boolean socketError) |
protected abstract byte[] |
createChannel()
Called when the channel is being created.
|
protected void |
evaluateClosure(boolean socketError)
set the closePending flag to true and attempt to close the channel
|
protected void |
evaluateWindowSpace(int remaining)
Called to evaluate the window space available.
|
int |
getInterestedOps()
Returns the current operations the handler is interested in
|
void |
initialize(ProtocolEngine engine,
Daemon daemon,
SelectableChannel sc,
SelectorThread selectorThread)
No initialization 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(byte[] 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(String parm1,
boolean parm2,
byte[] parm3)
Called when a channel request is received.
|
protected void |
onExtendedData(byte[] 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 void |
onWindowAdjust(int count) |
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(SelectableChannel channel,
SelectionKey key)
The registration completed and its selector added to an available
SelectorThread |
void |
run() |
void |
setSelectionKey(SelectionKey key) |
void |
setThread(SelectorThread thread)
Sets the selector thread for this connection
|
protected void |
shutdownSocket() |
getHost, getOriginatingHost, getOriginatingPort, getPortaddEventListener, addInputListener, addOutputListener, clearIdleState, close, close, consumeWindowSpace, createCloseTask, executeTask, getChannelType, getConnection, getContext, getLocalId, getLocalPacket, getLocalWindow, getQueueSize, getRemoteId, getRemotePacket, getRemoteWindow, getSessionIdentifier, isClosed, isClosing, isEOF, isOpen, isSelfManagedWindowSpace, markEOF, onChannelOpenFailure, queueSize, registerExtendedData, resetIdleState, sendChannelData, sendChannelData, sendChannelData, sendChannelData, sendChannelDataAndBlock, sendChannelRequest, sendEOF, sendExtendedData, sendExtendedData, sendRequestResponse, sendWindowAdjustclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetUuidpublic SocketForwardingChannel(String channeltype)
channeltype - the type of channel i.e. "forwarded-tcpip"public void setSelectionKey(SelectionKey key)
setSelectionKey in interface SelectionKeyAwareprotected void onChannelOpen()
onChannelOpen in class Channelpublic void initialize(ProtocolEngine engine, Daemon daemon, SelectableChannel sc, SelectorThread selectorThread)
initialize in interface SocketHandlerengine - ProtocolEnginedaemon - Daemonprotected abstract byte[] createChannel()
throws IOException
ChannelcreateChannel in class ChannelIOExceptionprotected void onExtendedData(byte[] data,
int type)
onExtendedData in class Channelprotected abstract void onRegistrationComplete()
public void registrationCompleted(SelectableChannel channel, SelectionKey key)
SelectorRegistrationListenerSelectorThreadregistrationCompleted in interface SelectorRegistrationListenerchannel - SelectableChannelkey - SelectionKeyprotected void onChannelData(byte[] data)
onChannelData in class Channelprotected void onChannelRequest(String parm1, boolean parm2, byte[] parm3)
ChannelonChannelRequest in class Channelprotected void onChannelFree()
onChannelFree in class Channelprotected void onChannelClosing()
onChannelClosing in class Channelprotected boolean canClose()
Channelprotected boolean canClose(boolean socketError)
protected void onRemoteClose()
onRemoteClose in class Channelprotected void evaluateClosure(boolean socketError)
protected void shutdownSocket()
protected void onChannelClosed()
ChannelonChannelClosed in class Channelprotected void onLocalEOF()
onLocalEOF in class Channelprotected void onRemoteEOF()
onRemoteEOF in class Channelprotected abstract void onChannelOpenConfirmation()
ChannelonChannelOpenConfirmation in class Channelprotected void evaluateWindowSpace(int remaining)
ChannelevaluateWindowSpace in class Channelprotected abstract byte[] openChannel(byte[] parm1)
throws WriteOperationRequest,
ChannelOpenException
ChannelopenChannel in class ChannelWriteOperationRequestChannelOpenExceptionpublic boolean processReadEvent()
processReadEvent in interface SocketHandlerpublic boolean processWriteEvent()
processWriteEvent in interface SocketHandlerpublic int getInterestedOps()
SocketHandlergetInterestedOps in interface SocketHandlerpublic void setThread(SelectorThread thread)
setThread in interface SocketHandlerthread - SelectorThreadprotected void onWindowAdjust(int count)
onWindowAdjust in class ChannelCopyright © 2025. All rights reserved.