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()
Return type:

SSHClientConnection

async forward_port(dest_host, dest_port)
Return type:

int

async close()
Return type:

None

class otto.host.transport.SshHopTransport(factory, parent=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=None)

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.

Return type:

SSHClientConnection

async forward_port(dest_host, dest_port)

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

Returns the local port number to connect to.

Return type:

int

async close()

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

Return type:

None