Trooper proxy generates a chain of connections to arrive to the desired remote server.
Given a list of connections:
[[{host, "server1"}, {user, "user1"}, {password, "pass1"}],
[{host, "server2"}, {user, "user2"}, {password, "pass2"}]]
The proxy creates the connection to the first server and a server
listening in a random port and running in a long polling way a proxy
command (i.e. nc server2 22
), you can provide the command through
the options. For example, in the previous example:
[[{host, "server1"}, {user, "user1"}, {password, "pass1"},
{proxy, "nc ~s ~b"}], ...]
Keep in mind it should receive two params, the first one is the name of the server (~s) where it should to connect and the second one is the port (~b).
The second connection is established against the random port and local interface. This way all of the information is sent to the remote server to that proxy command and therefore to the new server.
At the end, you are connected to the last server in the list, but through all of the previous servers. Note that you have to provide the way to connect to the following server keeping in mind you're in the previous one.
exit_status() = integer()
reason() = atom() | string()
abstract datatype: trooper_proxy()
exec/2 | Executes the command in background setting the current process as the receiver for the incoming information from the SSH connection. |
exec/3 | Executes the command in background setting the current process as the receiver for the incoming information from the SSH connection. |
exec_long_polling/2 | Executes the command in background setting the current process as the receiver for the incoming information from the SSH connection. |
exec_long_polling/3 | Executes the command in background setting the current process as the receiver for the incoming information from the SSH connection. |
start/1 | Starts the proxy connections to the remote servers. |
stop/1 | Stops the SSH proxy connection. |
exec(Trooper_proxy::trooper_proxy(), Command::string()) -> {ok, exit_status(), binary()} | {error, reason()}
Executes the command in background setting the current process as the receiver for the incoming information from the SSH connection.
exec(Trooper_proxy::trooper_proxy(), CommandFormat::string(), Args::[term()]) -> {ok, exit_status(), binary()} | {error, reason()}
Executes the command in background setting the current process as the receiver for the incoming information from the SSH connection. This function let us to use the format and args way to create the command to be execute in the remote server.
exec_long_polling(Trooper_proxy::trooper_proxy(), Command::string()) -> pid()
Executes the command in background setting the current process as the receiver for the incoming information from the SSH connection.
exec_long_polling(Trooper_proxy::trooper_proxy(), CommandFormat::string(), Args::[term()]) -> pid()
Executes the command in background setting the current process as the receiver for the incoming information from the SSH connection. This function let us to use the format and args way to create the command to be execute in the remote server.
start(Configs::[trooper_ssh:opts()]) -> {ok, trooper_proxy()}
Starts the proxy connections to the remote servers.
stop(Trooper_proxy::trooper_proxy()) -> ok
Stops the SSH proxy connection.