host.transport

Hop transport abstractions for multi-hop connectivity.

A HopTransport decouples the transport mechanism (SSH tunnel, future telnet relay, etc.) from ConnectionManager. The concrete SshHopTransport wraps an SSHClientConnection and provides tunnel access and local port forwarding — the same operations that Phase 1 performed inline inside ConnectionManager.

For multi-hop chains each transport may hold a reference to a parent transport. Closing a transport cascades to its parent, tearing down the entire chain from the outermost hop inward.

class otto.host.transport.HopTransport(*args, **kwargs)

Bases: Protocol

Minimal interface that ConnectionManager needs from a hop.

async get_tunnel() SSHClientConnection
async forward_port(dest_host: str, dest_port: int) int
async close() None
class otto.host.transport.SshHopTransport(factory: collections.abc.Callable[..., Awaitable[SSHClientConnection]], parent: SshHopTransport | None = None)

Bases: object

Concrete HopTransport backed by an SSH connection.

Parameters

factory:

Async callable that returns an SSHClientConnection to the hop host. Called at most once (lazily, on first get_tunnel).

parent:

Optional parent transport whose tunnel this transport’s connection rides over. Closed automatically when this transport is closed.

async get_tunnel(_visited: set[str] | None = None) SSHClientConnection

Return the hop SSH connection, creating it via the factory if needed.

_visited threads the cycle-detection set used by RemoteHost._build_hop_transport’s factory through the parent chain. External callers don’t need to pass it.

async forward_port(dest_host: str, dest_port: int) int

Forward a local ephemeral port to dest_host:dest_port through the tunnel.

Returns the local port number to connect to.

async close() None

Close port forwards, the tunnel connection, and the parent transport.