With a SOCKS5 proxy server, remote host/port is supplied by the SOCKS5 client upon connecting to the server. This means a SOCKS5 proxy server is only usable by SOCKS5-aware applications (most web browsers support SOCKS5, for example). See RFC 1928 for more information about the protocol.
The StartSocksServer()
method starts a SOCKS5 proxy server that is bound to a single instance of Ssh
class, and therefore to a single SSH session. So unfortunately, Ssh
's SOCKS5 support is not suitable for the scenario you described.
However, the solution you proposed looks like a great approach that could be very useful for many scenarios. We don't currently expose any API that would make it possible, but we have all the modules needed to make it work, so exposing an API for it should be quite straightforward.
We will think it through and let you know whether we can add this quickly. To make sure I understand your needs properly: Basically, what you would like to achieve is to have a TCP socket listen at a local address/port, and tunnel all incoming connection to a remote host/port, but each using it's own SSH session. Is that correct?