ddn.net.ssh.channel

Multiplexed SSH connection-protocol channels (RFC 4254).

One SshChannelImpl instance per opened channel. The session owns the registry and the single pump that advances every channel; channels never touch the transport themselves - they enqueue messages through the session and expose flow-control visibility per the public API contract.

Types 6

Channel-side limits from the support matrix and RFC 4254.

defaultWindow = 2 * 1024 * 1024Default initial window we grant the peer (matches OpenSSH)
defaultMaxPacket = 32768Default maximum packet size we accept from the peer
channelsMax = 128Default maximum packet size the peer grants us may be small; writes are chunked to whatever the peer allows. Maximum channels per session.
adjustThresholdDivisor = 2Window-adjust threshold: replenish after half the window is consumed.
writeBacklogMax = 2 * 1024 * 1024Maximum accepted-but-unsent bytes one channel buffers; writes beyond it are accepted partially (or reported as WAIT)
fairShareBytes = 256 * 1024Maximum bytes one channel hands to the session per pump call, keeping per-channel sends bounded and the scheduler fair.
terminalModesMax = 128Maximum terminal-mode pairs in one pty-req (RFC 4254 section 8 has 159 defined opcodes; the encoded stream stays small).
forwardedAcceptsPendingMax = 8Maximum incoming forwarded channels waiting for an accept decision.

Internal channel lifecycle beyond the public states.

openingOpen request sent, waiting for confirmation or failure
openPeer confirmed; data can flow
closingLocal close sent; waiting for the peer's CHANNEL_CLOSE
closedClose handshake done
failedFailed independently of the session

Open-operation implementation driven by session pumping.

Methods
void confirm()
void fail(SshError error)
SshProgress progress() @property const
bool done() @property const
SshError error() @property const
SshChannel channel() @property
void cancel()
Constructors
this(SshChannelImpl channel)Constructs an operation for a channel being opened.

Channel-request-operation implementation.

Methods
void complete(bool accepted)
void fail(SshError error)
SshProgress progress() @property const
bool done() @property const
SshError error() @property const
bool accepted() @property const
void cancel()

Endpoint fields of a direct TCP/IP channel open (RFC 4254 7.2).

Fields
string hostDestination host as seen by the server
ushort portDestination port
string originatorAddressOriginator address reported to the server
ushort originatorPortOriginator port reported to the server

One multiplexed channel.

Flow control: the session replenishes the receive window as the application consumes buffered data; writes respect the peer's window and maximum packet size. Consumers observe backpressure through canWrite and never manage windows themselves.

Methods
SshChannelOpenOp openOperation() @propertyThe pending open operation (valid while opening).
uint localId() @property constThe locally assigned channel number.
uint remoteId() @property constThe peer-assigned channel number once confirmed.
SshChannelPhase phase() @property constThe internal lifecycle phase.
SshChannelRequestOp pendingRequest() @propertyThe pending request operation, if one is in flight.
string lastRequestType() @property constThe last request type sent (for reply matching).
bool dataQueued() @property const
ulong remoteWindowRemaining() @property const
bool peerConfirmed() @property const
void beginIncoming(uint remoteChannel, uint initialWindow, uint maxPacket)Registers a peer-opened channel (remote forwarding) in the open state before the accept decision: the peer may send data right after its open (RFC 4254 section 5.1).
void confirmIncoming()Marks an incoming channel confirmed after an accept decision.
bool incomingUnconfirmed() @property constReturns: whether an incoming channel still awaits acceptance.
ubyte[] buildIncomingConfirmation()Builds the CHANNEL_OPEN_CONFIRMATION for an accepted incoming channel.
void handleOpenConfirmation(uint remoteChannel, uint initialWindow, uint maxPacket) Handles CHANNEL_OPEN_CONFIRMATION. Params: remoteChannel = Peer-assigned channel number. initialWindow = Window the peer grants us. maxPacket = Maximum packet the peer accepts.
void handleOpenFailure(uint reasonCode, string description)Handles CHANNEL_OPEN_FAILURE.
void handleOpenCancelled()Marks a cancelled open as closed without a wire message.
void handleData(const(ubyte)[] data)Buffers incoming standard data and consumes our receive window.
void handleExtendedData(const(ubyte)[] data)Buffers incoming extended data.
void handleWindowAdjust(uint bytesToAdd)Handles a peer window adjustment.
void handleEof()Handles peer EOF.
void handleClose()Handles peer close.
void handleRequestReply(bool accepted)Handles CHANNEL_SUCCESS / CHANNEL_FAILURE for the pending request.
void handleExitInfo(SshWireReader reader)Handles exit-status and exit-signal channel requests.
ubyte[] buildOpenPayload()Builds the CHANNEL_OPEN payload for this channel type.
ubyte[] buildWindowAdjust(uint bytesToAdd)Builds a CHANNEL_WINDOW_ADJUST payload.
ubyte[] buildData(const(ubyte)[] chunk)Builds a CHANNEL_DATA payload.
ubyte[] buildExtendedData(const(ubyte)[] chunk)Builds a CHANNEL_EXTENDED_DATA payload.
ubyte[] buildEof()Builds a CHANNEL_EOF payload.
ubyte[] buildClose()Builds a CHANNEL_CLOSE payload.
ubyte[] buildRequest(scope const SshChannelRequest request)Builds a CHANNEL_REQUEST payload.
void handleIncomingRequest(string requestType, SshWireReader reader)Handles a server-originated channel request (exit info).
void failChannel(SshError error)Marks the channel failed independently of the session.
SshChannelType type() @property const
SshResult read(ubyte[] buffer)
SshResult readExtended(ubyte[] buffer)
SshResult write(const(ubyte)[] data)
bool canRead() @property const
bool hasExtendedData() @property const
bool canWrite() @property const
size_t pendingWriteBytes() @property const
ulong sendWindowRemaining() @property const
uint peerMaximumPacketSize() @property const
void sendEof()
bool eofSent() @property const
bool peerEof() @property const
void close()
bool closeSent() constReturns: whether we already sent our CHANNEL_CLOSE.
bool closed() @property const
SshError channelError() @property const
SshExitStatus exitStatus() @property const
void discardExtendedData(bool discard)
bool pumpWrites()Sends as much of the write backlog as the remote window allows.
void releaseReceive(size_t bytes)Returns: whether the receive window needs replenishing. Records application consumption of received bytes.
uint takeAdjust()Removes and returns the pending re-grant when it crosses the replenish threshold.
void creditGranted(uint granted)Mirrors a sent CHANNEL_WINDOW_ADJUST into the local credit view.
void markClosed()
Constructors
this(ddn.net.ssh.session.SshSessionImpl sender, uint localId, SshChannelType type, scope const SshChannelOpenOptions options, SshDirectTcpIpTarget target = SshDirectTcpIpTarget.init) Constructs a channel in the opening phase. Params: sender = Session that owns this channel. localId = Locally assigned channel number. type = Channel type. options = Flow-control...

Functions 1

fnubyte[] encodeTerminalModes(scope const SshTerminalMode[] modes)Encodes terminal modes for a pty-req (RFC 4254 section 8).