Reverse (Open)SSH tunnels with dynamically allocated remote ports. E.g.
> tun = SshMachine(...).tunnel(1234, 0, reverse=True)
> tun.dport
'43385'
Dynamic remote port allocation is done by OpenSSH (ssh -R).
Non-reverse and reverse (Open)SSH tunnels with dynamically allocated local ports. E.g.
> tun = SshMachine(...).tunnel(0, 1234)
> tun.lport
37689
Dynamic local port allocation is done by rpyc.utils.factory._get_free_port, which I've duplicated into Plumbum. (Minor point: license-wise, rpyc.utils.factory._get_free_port is released by @tomerfiliba under the MIT license already. In theory Plumbum should add attribution to satisfy RPyC's license here, but I suspect that Tomer probably would not mind as they authored both projects.)
This also adds a reverse property to SshTunnel. lhost and dhost properties could also be added if deemed useful—I imagine the use primary cases there would be to check what address the tunnel was bound to or if the tunnel is for ports or sockets.
This PR probably should also update SshMachine().tunnel's docs. Note that #562 did not update docs for reverse.
Coverage increased (+0.09%) to 83.758% when pulling fc968c52422a26072ef76272e54c85d6e8ed507f on gschaffner:dynamic-ssh-tunnel-ports into 70380ddc5ad346ab6758506f5000864260a9c418 on tomerfiliba:master.
Hi! This adds two new features:
Reverse (Open)SSH tunnels with dynamically allocated remote ports. E.g.
Dynamic remote port allocation is done by OpenSSH (
ssh -R
).Non-reverse and reverse (Open)SSH tunnels with dynamically allocated local ports. E.g.
Dynamic local port allocation is done by
rpyc.utils.factory._get_free_port
, which I've duplicated into Plumbum. (Minor point: license-wise,rpyc.utils.factory._get_free_port
is released by @tomerfiliba under the MIT license already. In theory Plumbum should add attribution to satisfy RPyC's license here, but I suspect that Tomer probably would not mind as they authored both projects.)This also adds a
reverse
property toSshTunnel
.lhost
anddhost
properties could also be added if deemed useful—I imagine the use primary cases there would be to check what address the tunnel was bound to or if the tunnel is for ports or sockets.This PR probably should also update
SshMachine().tunnel
's docs. Note that #562 did not update docs forreverse
.