Skip to content

Latest commit

 

History

History
168 lines (103 loc) · 5.14 KB

trooper_proxy.md

File metadata and controls

168 lines (103 loc) · 5.14 KB

Module trooper_proxy

Trooper proxy generates a chain of connections to arrive to the desired remote server.

Description

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.

Data Types


exit_status() = integer()

reason() = atom() | string()

abstract datatype: trooper_proxy()

Function Index

exec/2Executes the command in background setting the current process as the receiver for the incoming information from the SSH connection.
exec/3Executes the command in background setting the current process as the receiver for the incoming information from the SSH connection.
exec_long_polling/2Executes the command in background setting the current process as the receiver for the incoming information from the SSH connection.
exec_long_polling/3Executes the command in background setting the current process as the receiver for the incoming information from the SSH connection.
start/1Starts the proxy connections to the remote servers.
stop/1Stops the SSH proxy connection.

Function Details

exec/2


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/3


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/2


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/3


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/1


start(Configs::[trooper_ssh:opts()]) -> {ok, trooper_proxy()}

Starts the proxy connections to the remote servers.

stop/1


stop(Trooper_proxy::trooper_proxy()) -> ok

Stops the SSH proxy connection.