Raxol.SSH.Server (Raxol v2.3.0)

View Source

Serves a Raxol TEA application over SSH.

Each SSH connection gets its own Lifecycle process running the TEA app, with terminal I/O redirected through the SSH channel.

Usage

Raxol.SSH.serve(CounterExample, port: 2222)

Then connect: ssh localhost -p 2222

Options

  • :port - Port to listen on (default: 2222)
  • :host_keys_dir - Directory for SSH host keys (default: "/tmp/raxol_ssh_keys")
  • :max_connections - Maximum concurrent connections (default: 50)

Summary

Functions

Returns a specification to start this module under a supervisor.

Returns the current number of active connections.

Registers a new connection. Returns :ok or {:error, :max_connections}.

Unregisters a connection when it closes.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

connection_count(server \\ __MODULE__)

@spec connection_count(GenServer.server()) :: non_neg_integer()

Returns the current number of active connections.

register_connection(server \\ __MODULE__)

@spec register_connection(GenServer.server()) :: :ok | {:error, :max_connections}

Registers a new connection. Returns :ok or {:error, :max_connections}.

serve(app_module, opts \\ [])

@spec serve(
  module(),
  keyword()
) :: GenServer.on_start()

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()

unregister_connection(server \\ __MODULE__)

@spec unregister_connection(GenServer.server()) :: :ok

Unregisters a connection when it closes.