public abstract class SocketForwardingChannel extends ForwardingChannel implements SocketHandler, Runnable
An abstract forwarding channel implementation for use with forwarding both local and remote sockets.
ForwardingChannel
Channel.DataBlock, Channel.QueuedData
hostToConnect, originatingHost, originatingPort, portToConnect
connection, 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, getPort
addEventListener, 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, sendWindowAdjust
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getUuid
public SocketForwardingChannel(String channeltype)
channeltype
- the type of channel i.e. "forwarded-tcpip"public void setSelectionKey(SelectionKey key)
setSelectionKey
in interface SelectionKeyAware
protected void onChannelOpen()
onChannelOpen
in class Channel
public void initialize(ProtocolEngine engine, Daemon daemon, SelectableChannel sc, SelectorThread selectorThread)
initialize
in interface SocketHandler
engine
- ProtocolEnginedaemon
- Daemonprotected abstract byte[] createChannel() throws IOException
Channel
createChannel
in class Channel
IOException
protected void onExtendedData(byte[] data, int type)
onExtendedData
in class Channel
protected abstract void onRegistrationComplete()
public void registrationCompleted(SelectableChannel channel, SelectionKey key)
SelectorRegistrationListener
SelectorThread
registrationCompleted
in interface SelectorRegistrationListener
channel
- SelectableChannelkey
- SelectionKeyprotected void onChannelData(byte[] data)
onChannelData
in class Channel
protected void onChannelRequest(String parm1, boolean parm2, byte[] parm3)
Channel
onChannelRequest
in class Channel
protected void onChannelFree()
onChannelFree
in class Channel
protected void onChannelClosing()
onChannelClosing
in class Channel
protected boolean canClose()
Channel
protected boolean canClose(boolean socketError)
protected void onRemoteClose()
onRemoteClose
in class Channel
protected void evaluateClosure(boolean socketError)
protected void shutdownSocket()
protected void onChannelClosed()
Channel
onChannelClosed
in class Channel
protected void onLocalEOF()
onLocalEOF
in class Channel
protected void onRemoteEOF()
onRemoteEOF
in class Channel
protected abstract void onChannelOpenConfirmation()
Channel
onChannelOpenConfirmation
in class Channel
protected void evaluateWindowSpace(int remaining)
Channel
evaluateWindowSpace
in class Channel
protected abstract byte[] openChannel(byte[] parm1) throws WriteOperationRequest, ChannelOpenException
Channel
openChannel
in class Channel
WriteOperationRequest
ChannelOpenException
public boolean processReadEvent()
processReadEvent
in interface SocketHandler
public boolean processWriteEvent()
processWriteEvent
in interface SocketHandler
public int getInterestedOps()
SocketHandler
getInterestedOps
in interface SocketHandler
public void setThread(SelectorThread thread)
setThread
in interface SocketHandler
thread
- SelectorThreadprotected void onWindowAdjust(int count)
onWindowAdjust
in class Channel
Copyright © 2024. All rights reserved.