From 63e8015bb6469783ca2732231d481bcd065fdf34 Mon Sep 17 00:00:00 2001 From: Calascibetta Romain Date: Thu, 2 Mar 2023 11:46:54 +0100 Subject: [PATCH] Add a documentation about Awa_mirage.spawn_server and its usage --- mirage/awa_mirage.mli | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/mirage/awa_mirage.mli b/mirage/awa_mirage.mli index dd50f89..e2f1536 100644 --- a/mirage/awa_mirage.mli +++ b/mirage/awa_mirage.mli @@ -42,6 +42,26 @@ module Make (F : Mirage_flow.S) (T : Mirage_time.S) (M : Mirage_clock.MCLOCK) : val spawn_server : ?stop:Lwt_switch.t -> Awa.Server.t -> Awa.Ssh.message list -> F.flow -> exec_callback -> t Lwt.t + (** [spawn_server ?stop server msgs flow callback] launches an {i internal} + SSH channels handler which can be stopped by [stop]. This SSH channels + handler will call [callback] for every new channels requested by the + client. [msgs] are the SSH {i hello} given by {!val:Awa.Server.make} which + returns also a {!type:Awa.Server.t} required here. + + A basic usage of [spawn_server] is: + {[ + let ssh_channel_handler _cmd _ic _oc _ec = + Lwt.return_unit + + let tcp_handler flow = + let server, msgs = Awa.Server.make private_key db in + SSH.spawn_server server msgs flow ssh_handler >>= fun _t -> + close flow + ]} + + {b NOTE}: Even if the [ssh_channel_handler] is fulfilled, [spawn_server] + continues to handle SSH channels. Only [stop] can really stop the internal + SSH channels handler. *) end with module FLOW = F