View Source trooper_proxy (trooper v0.4.2)

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.

Summary

Functions

Executes the command in background setting the current process as the receiver for the incoming information from the SSH connection.

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.

Executes the command in background setting the current process as the receiver for the incoming information from the SSH connection.

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.

Starts the proxy connections to the remote servers.

Stops the SSH proxy connection.

Types

exit_status/0

-type exit_status() :: integer().

reason/0

-type reason() :: atom() | string().

trooper_proxy/0

-opaque trooper_proxy()

Functions

exec(Trooper_proxy, Command)

-spec exec(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, CommandFormat, Args)

-spec exec(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, Command)

-spec exec_long_polling(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, CommandFormat, Args)

-spec exec_long_polling(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)

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

Starts the proxy connections to the remote servers.

stop(Trooper_proxy)

-spec stop(trooper_proxy()) -> ok.

Stops the SSH proxy connection.