Table of Contents

Method FromConnector

Namespace
SshSharp
Assembly
SshSharp.dll

FromConnector(Func<string, int, CancellationToken, ValueTask<Stream>>)

A proxy that is your own code: connector receives the host and port to reach (the SSH server, or the first JumpHosts or ProxyJump host) and returns a connected, duplex stream to it, such as a cloud provider's WebSocket tunnel, a named pipe or an in-memory transport. It goes wherever an SshProxy goes: Proxy, Proxy and the DI package's client options.

public static SshProxy FromConnector(Func<string, int, CancellationToken, ValueTask<Stream>> connector)

Parameters

connector Func<string, int, CancellationToken, ValueTask<Stream>>

Opens the connection. Its token ends with the caller's and with ConnectTimeout (or ssh_config's ConnectTimeout); there is no other time limit. The stream it returns belongs to the SSH connection from then on, which disposes it. It is called once per connection attempt, possibly from several attempts at once. LocalEndPoint and AddressFamily do not apply: the connector makes its own connection.

Returns

SshProxy

Remarks

An exception from the connector fails the connection with ConnectFailed, with the exception inside (an SshException it throws passes as it is, and so does cancellation by the caller's token). The host name is not part of that error's message.

Exceptions

ArgumentNullException

connector is null.