Start SSH and Telnet servers for hosting TUI applications over the network.
Each connecting client gets their own session. Two modes are supported:
:isolated(default) — each client runs an independent app instance with its own state. Ideal for single-user tools, games, and dashboards.:shared— all clients share the same app state. Input from any client mutates the shared state and all clients re-render. Ideal for collaborative apps, multi-player games, and shared dashboards.
SSH Example
Drafter.Server.start_ssh(ChatApp,
port: 2222,
mode: :shared,
auth: [{"alice", "pass1"}, {"bob", "pass2"}]
)Telnet Example
Drafter.Server.start_telnet(MyApp, port: 2323, mode: :isolated)Generating SSH host keys
If no system_dir: is provided, host keys are automatically generated and
cached in a temp directory. For production use, generate persistent keys:
ssh-keygen -t rsa -b 2048 -f /etc/drafter/ssh_host_rsa_key -N ""Then pass system_dir: "/etc/drafter".
Summary
Functions
Starts an SSH server hosting app_module, linked to the caller.
Starts a Telnet server hosting app_module, linked to the caller.
Functions
Starts an SSH server hosting app_module, linked to the caller.
app_module is a module that does use Drafter.App. Returns {:ok, pid} for the
listener, or {:error, reason}. The listener runs until it is stopped; each client
that connects gets its own session process.
Options
:port- TCP port. Default2222.:ip- the interface to bind, as an address tuple. Default{127, 0, 0, 1}, which accepts only local connections.:mode-:isolated(default) gives each client its own app state;:sharedruns every client against one shared state.:auth-[{username, password}]tuples for password authentication, or the atom:anonymousto accept any username and password. Default[{"admin", "admin"}].:system_dir- path to the directory holding the SSH host keys. Default: adrafter_sshdirectory under the system temp directory, with RSA host keys generated byssh-keygenon first use.:mount_props-map()handed to each session'smount/1. Default%{}. The authenticated username is added to it under:usernameas a string, so every SSH session's mount props carry that key whether or not you set it.
Starts a Telnet server hosting app_module, linked to the caller.
app_module is a module that does use Drafter.App. Always returns {:ok, pid}
for the acceptor process, which is linked to the caller. The socket is opened
inside that process, so a port already in use surfaces as an exit from the acceptor
rather than an {:error, reason} return. Each client that connects gets its own
session process.
Telnet carries no authentication or encryption; bind it only where that is acceptable.
Options
:port- TCP port. Default2323. Bound on all interfaces.:mode-:isolated(default) gives each client its own app state;:sharedruns every client against one shared state.:mount_props-map()handed to each session'smount/1. Default%{}.