Class SshRemoteSocketForwarder
- Namespace
- SshSharp
- Assembly
- SshSharp.dll
A remote Unix-socket forwarding (ssh -R /remote/socket:target) started by ForwardRemoteUnixSocketAsync(string, string, int, CancellationToken):
the server listens on the Unix socket RemoteSocketPath, and each connection made to it is relayed to a TCP port
(LocalHost:LocalPort) or a Unix socket (LocalSocketPath) reached from this machine, or passed
to the application's handler (ForwardRemoteUnixSocketAsync(string, Func<SshForwardedConnection, CancellationToken, Task>, int, CancellationToken)).
Dispose it to cancel the forwarding on the server and close the forwarded connections.
public sealed class SshRemoteSocketForwarder : IAsyncDisposable
- Inheritance
-
SshRemoteSocketForwarder
- Implements
- Inherited Members
Properties
- ActiveConnections
How many forwarded connections are open now.
- HandlerShutdownTimeout
For a forwarding to a handler (IsHandler): how long DisposeAsync() waits for the handlers it cancelled to return before it closes the connections of those still running under them. 5 seconds by default; Zero closes them at once, and InfiniteTimeSpan waits as long as they take. Set it before disposing; it does not apply to other forwardings, whose connections are closed at once.
- IsHandler
Whether connections go to a handler in this process (ForwardRemoteUnixSocketAsync(string, Func<SshForwardedConnection, CancellationToken, Task>, int, CancellationToken)) rather than to a host and port or a socket.
- LocalHost
The host connections go to, from this machine; null when they go to LocalSocketPath or a handler.
- LocalPort
The port on LocalHost; 0 when connections go to LocalSocketPath or a handler.
- LocalSocketPath
The Unix socket on this machine connections go to; null when they go to LocalHost or a handler.
- MaxConnections
The most connections this forwarding serves at once: a handler's
maxConnections, above which the server's channels are refused until some end; MaxValue (no limit of its own) for a forwarding to a host and port or a socket. MaxForwardedConnections applies across all forwardings either way.
- RemoteSocketPath
The Unix socket the server listens on.
Methods
- DisposeAsync()
Cancels the forwarding on the server (
cancel-streamlocal-forward@openssh.com) and closes every forwarded connection. For a forwarding to a handler, the token each handler was given is cancelled, and this waits up to HandlerShutdownTimeout (5 seconds by default) for the handlers to return; the connections of any still running then are closed under them, and this returns without waiting for them further. A connection the server opened before the cancel, but that reaches this forwarder only after disposal has gathered the connections it waits for, is closed without being served.