Traversio

Direct Streamlocal Channels

Use a raw OpenSSH `[email protected]` channel when Swift code should speak to one remote Unix domain socket.

SSHConnection.openDirectStreamLocalChannel(...) opens one raw byte stream to a Unix domain socket on the SSH server side.

Use it when:

  • your Swift code owns the protocol bytes
  • the remote service listens on a socket path such as /run/postgresql/.s.PGSQL.5432
  • you want the same event and transcript style as SSHDirectTCPIPChannel

Mental Model

your Swift code
    -> one SSH [email protected] channel
        -> one remote Unix domain socket

OpenSSH documents streamlocal as a forwarding extension. This direct channel form is one channel, one socket path, and caller-owned bytes.

Example

import Traversio

func queryRemoteSocket(configuration: SSHClientConfiguration) async throws -> [UInt8] {
    try await SSHClient.withConnection(configuration: configuration) { connection in
        let channel = try await connection.openDirectStreamLocalChannel(
            socketPath: "/run/my-service.sock"
        )

        try await channel.write("ping\n")
        try await channel.sendEOF()

        return try await channel.collectDataUntilClose().data
    }
}

Parameters

  • socketPath is the Unix domain socket path on the server side
  • originatorAddress and originatorPort are metadata sent in the OpenSSH-compatible channel-open payload

The defaults use 127.0.0.1 and 0, which are enough for the common client-owned stream case.

What You Get Back

SSHDirectStreamLocalChannel exposes:

  • write(_:)
  • write(_ string: String)
  • sendEOF()
  • close()
  • readChunk()
  • nextEvent()
  • events
  • collectDataUntilClose()

Supporting public types:

  • SSHDirectStreamLocalChannelOutput
  • SSHStreamLocalChannelEvent
  • SSHStreamLocalChannelEventSequence

Support Status

Current state:

  • channel-open encoding follows OpenSSH's deployed [email protected] shape: socket path, originator string, and originator port
  • the wrapper uses the same managed channel lifecycle, receive-window handling, EOF, close, and cancellation-aware event-stream behavior as direct TCP/IP channels
  • live validation covers an OpenSSH target with a remote Unix socket echo server created during the probe
  • remote streamlocal listeners are exposed separately through SSHConnection.withRemoteStreamLocalForwardListener(...)

On this page