eve.net.ssh.transport

EVE TCP transport adapter for ddn-net-ssh.

Wraps an EVE connection (TcpConnection or UnixConnection) into the SshTransport contract from ddn.api.net.ssh. Incoming data from EVE's onData callback is buffered internally and presented through the synchronous EveStreamTransport.read method; outbound data written through EveStreamTransport.write is copied into EVE's send queue.

The module exports two aliases of the same implementation: EveSshTransport for SSH TCP sessions and EveAgentTransport for ssh-agent Unix sockets.

Typical usage:

auto conn = TcpConnection.create();
auto transport = new EveSshTransport(conn);

conn.onData = (ref TcpConnection c, scope const(ubyte)[] data) {
   transport.feed(data);
   session.pump();
};
conn.onClose = (ref TcpConnection c, SocketCloseReason reason) {
   transport.noteClosed(reason);
   session.pump();
};

Required EVE APIs. This adapter requires an EVE release providing: TcpConnection with create, connect, send returning SendStatus with the queue-based contract (OK and PARTIAL accept the whole buffer, PRESSURE accepts nothing), close, isOpen, pauseReading, resumeReading, and the onConnect, onData, onWritable, onClose callback properties; SocketCloseReason; and EventLoop with create, run, stop, dispose, and registerTimer.

Ownership. The application owns both the connection and the transport and must keep the connection alive for the transport's lifetime. The adapter does not install EVE callbacks itself: the application wires onData to feed and onClose to noteClosed. close closes the underlying connection.

Acceptance is not acknowledgment. write reporting accepted bytes means EVE queued them for transmission; the peer has not acknowledged anything. Higher-level semantics (for example SFTP write confirmations) stay with the protocol layers.

This module depends on EVE and the shared SSH API contracts only. The dependency direction is one-way: ddn-net-ssh and the SFTP package never import EVE.

Types 4

Receive-side bounds of EveSshTransport.

receiveHighWater = 1024 * 1024Buffered bytes at which socket reads are paused
receiveLowWater = 256 * 1024Buffered bytes at which paused socket reads resume
private enumTransportCloseState : ubyte

The result of a peer close event as translated for read.

noneNo close event observed yet
eofPeer closed its sending side cleanly
failedThe connection failed or was reset
closedThe application closed the transport

EVE-backed byte-stream transport adapting one connection type C.

Incoming bytes are fed through feed and drained through read; the internal receive buffer is bounded by pausing socket reads at the high-water mark and resuming below the low-water mark. The buffer may exceed the high-water mark by at most one already-delivered chunk.

Fields
private C conn_
private ubyte[] readBuffer_
private size_t readPos_
private size_t receiveHighWater_
private size_t receiveLowWater_
private bool readPaused_
private TransportCloseState closeState_
Methods
void feed(scope const(ubyte)[] data) @trustedFeeds received socket data into the internal buffer.
void noteClosed(SocketCloseReason reason) @safe nothrowRecords a peer close event.
ptrdiff_t read(ubyte[] buffer) @trusted nothrowReads buffered data into the provided buffer.
ptrdiff_t write(const(ubyte)[] data) @trustedQueues data for transmission on the underlying connection.
void flush() @safe pure nothrowFlushes buffered output. No-op: EVE queues and flushes writes itself.
void close() @trusted nothrowCloses the underlying connection.
bool isOpen() @property const @safe nothrowReturns: whether the transport can still make progress.
bool readPaused() @property const @safe nothrow @nogcReturns: whether socket read delivery is currently paused at the receive high-water mark.
size_t bufferedBytes() @property const @safe nothrow @nogcReturns: the number of buffered bytes not yet read.
private void compact() @trusted nothrow
Constructors
this(ref C conn, size_t receiveHighWater = EveSshTransportLimits.receiveHighWater, size_t receiveLowWater = EveSshTransportLimits.receiveLowWater)Constructs the adapter over an EVE TCP connection.

SSH TCP transport adapter over an EVE TcpConnection.