-
Notifications
You must be signed in to change notification settings - Fork 166
Description
There is a ProxyCommand class is paramiko which acts like the ProxyCommand directive on the ssh config.
This class implements a the socket-like interface needed by the Transport and Packetizer classes. Using this class instead of a regular socket makes it possible to talk with a Popen’d command that will proxy traffic between the client and a server hosted in another machine.
When creating a new connection, we pass it as the socket that is going to use. E.g;
https://gist.github.com/ovidiucs/e0aebf203f9280ead466#file-paramiko-proxy-py-L38
The class basically acts as a socket-like interface and on send() calls send the data to the stdin of the started subprocess (which is the proxy command) and on read() calls it reads the data from the stdout. See the implementation here;
https://github.com/paramiko/paramiko/blob/d2d3d77395d1079a2e335080b7f9f79d3f70ad2a/paramiko/proxy.py#L71-L119
I thought about implementing a similar class (perhaps using async subprocesses, to make the send/recv non-blocking) though I don't know if there is anything I should be concerned about (does asyncssh use anything besides a regular send/recv on the sockets for example?). I've seen your answer on here #104 (comment) which shows how to pass an external socket to proxy the connection over, so I intend to use that example as the base. If you have any suggestions / or stuff that I should keep in mind while implementing, I'd appreciate it.