eve.net.ssh.forwarding
TCP forwarding bridges coupling EVE sockets to SSH channels.
The bridges sit on top of the existing channel contracts: every byte passes through SshChannel reads/writes and every wakeup runs through the session driver, so flow control, window accounting, and EOF/close semantics stay owned by the SSH layer. Per-direction bridge queues are bounded and couple socket read pause/resume to channel writability.
Half-close propagation is independent in both directions: a socket read EOF becomes a channel sendEof after the queued bytes, and a channel peer EOF becomes a socket write shutdown while socket data keeps flowing into the channel.
Bind, destination, and access decisions are explicit caller policy through EveLocalForwardPolicy and EveForwardedBridgePolicy; no bridge accepts traffic on its own.
Types 7
Bounds and defaults for the forwarding bridges.
Scheduling surface the bridges need from the session driver.
EveBridgeHost.of adapts an EveSessionDriver; tests may provide their own host.
void delegate(SshChannel, void delegate()) watchChannelWatches a channel for readable data or send-window relief.void delegate(SshChannel) unwatchChannelStops watching a channel.void delegate() requestPumpRequests a coalesced session pump.void delegate(SshChannelOpenOperation,
void delegate(SshChannelOpenOperation)) watchOpenWatches a channel-open operation for terminal completion.void delegate(SshChannelOpenOperation) unwatchOpenStops watching a channel-open operation.void delegate(Token) cancelDeadlineCancels a registered deadline.Caller-controlled policy for a local forwarding bridge.
string listenAddressAddress the bridge listens on (bind policy).ushort listenPortPort to bind; 0 lets the OS allocate one.string destinationHostDestination host as seen by the SSH server (direct-tcpip).ushort destinationPortDestination port as seen by the SSH server.string originatorAddressOriginator identity reported to the SSH server.ushort originatorPortOriginator port reported to the SSH server.size_t bridgeQueueMaxBounded queue per bridge direction, in bytes.bool delegate() admitAccess policy consulted for every accepted socket; returning false closes the connection without opening a channel. A null delegate refuses everything.Caller-controlled policy for bridging incoming forwarded channels.
size_t bridgeQueueMaxBounded queue per bridge direction, in bytes.Duration connectTimeoutTimeout for the destination connection attempt.bool delegate(scope const SshForwardedChannelInfo info,
out string destinationHost, out ushort destinationPort) admitAccess and destination policy consulted for every incoming forwarded channel. Returning false refuses the channel; otherwise destinationHost/destinationPort receive where to connect. A null delegat...Bridges one EVE TCP connection and one SSH channel.
Data flows in both directions through bounded queues: socket reads pause when the channel-side queue is full and channel reads wait for socket writability. Independent half-closes propagate as described in the module documentation.
private EveBridgeHost host_private TcpConnection conn_private SshChannel channel_private size_t queueMax_private ubyte[] inbound_private ubyte[] outbound_private bool socketReadPaused_private bool socketEof_private bool channelEofToSocket_private bool socketWriteFailed_private bool unwatched_private bool doneNotified_private void delegate(EveChannelSocketBridge) onDone_private bool bridgeDone_void attachChannel(SshChannel channel)Attaches the SSH channel and starts forwarding.void shutdown()Shuts the bridge down: closes the socket and the channel.void onDone(void delegate(EveChannelSocketBridge) onDone) @propertySets the callback invoked once when the bridge becomes terminal.void drainInbound()Writes queued socket bytes to the channel and completes a socket read EOF behind them.void maybeShutdownWrite()Shuts the socket write direction down once the channel peer's EOF is fully forwarded (independent half-close).void unwatch()this(EveBridgeHost host, TcpConnection conn, SshChannel channel = null,
size_t queueMax = EveForwardBridgeLimits.bridgeQueueMaxDefault)Constructs a bridge over an established socket.Local forwarding bridge: a caller-bound TCP listener whose accepted sockets each become one direct-tcpip channel.
The bridge never chooses the bind address, destination, or access decision; those come from EveLocalForwardPolicy.
private EveBridgeHost host_private EventLoop * loop_private SshSessionImpl session_private EveLocalForwardPolicy policy_private TcpListener listener_private bool stopped_private Opening[] opening_EveChannelSocketBridge[] bridgesLive bridges for accepted connections.void stop()Stops the bridge: closes the listener and every live bridge.void completeOpen(SshChannelOpenOperation open)Completes and retires a watched local channel open.void timeoutOpen(SshChannelOpenOperation open)Cancels and retires a local channel open at its deadline.Duration openTimeout()Returns: the direct-tcpip open timeout: the bridge connect timeout, so a stalled server fails the accepted socket rather than buffering it forever.void pruneBridges()Drops finished bridges so long-lived listeners do not accumulate completed state.void retireBridge(EveChannelSocketBridge bridge)Removes a terminal local bridge from owner tracking.void rejectAccepted(Handle clientHandle)this(EveBridgeHost host, ref EventLoop loop,
SshSessionImpl session,
scope const EveLocalForwardPolicy policy)Binds the listener described by the policy.OpeningOne accepted socket waiting for its SSH channel to open.Destination bridge for incoming forwarded TCP/IP channels.
Implements SshForwardedChannelHandler: each admitted channel triggers a destination connection, and the decision stays PENDING until the connection attempt succeeds or fails. Pass handler to SshSession.setForwardedChannelHandler.
private EveBridgeHost host_private EventLoop * loop_private EveForwardedBridgePolicy policy_private Pending[] pending_private EveChannelSocketBridge[] active_private bool stopped_void stop()Shuts every pending and live bridge down and refuses further channels.SshForwardAcceptResult decideForwardedChannel(
scope const SshForwardedChannelInfo info, SshChannel channel)void onConnected(SshChannel channel)Bridges the pair once the destination connection succeeds.void onConnectFailed(SshChannel channel)Refuses the channel when the destination connect fails or times out.void retireBridge(EveChannelSocketBridge bridge)Removes a terminal forwarded bridge from owner tracking.this(EveBridgeHost host, ref EventLoop loop,
scope const EveForwardedBridgePolicy policy)Constructs the bridge.PendingFunctions 8
auto safeAcceptCb(
void delegate(ref TcpListener, Handle) @system dg) pure nothrow @trustedCasts a system accept callback to the safe EVE callback type.auto safeConnectCb(void delegate(ref TcpConnection) @system dg) pure nothrow @trustedCasts a system connect callback to the safe EVE callback type.auto safeEofCb(void delegate(ref TcpConnection) @system dg) pure nothrow @trustedCasts a system EOF callback to the safe EVE callback type.auto safeDataCb(
void delegate(ref TcpConnection, scope const(ubyte)[]) @system dg) pure nothrow @trustedCasts a system data callback to the safe EVE callback type.auto safeWritableCb(void delegate(ref TcpConnection) @system dg) pure nothrow @trustedCasts a system writable callback to the safe EVE callback type.auto safeCloseCb(
void delegate(ref TcpConnection, SocketCloseReason) @system dg) pure nothrow @trustedCasts a system close callback to the safe EVE callback type.auto safeTimerCb(void delegate(ref EventLoop, Token) @system dg) pure nothrow @trustedCasts a system timer callback to the safe nothrow EVE callback type.