From 5483070246cebb3a9dce06a237d0561f8caa02fd Mon Sep 17 00:00:00 2001 From: Clombrong Date: Sat, 28 Jun 2025 09:26:59 +0200 Subject: feat(portal_to_tcp): implement starttls function --- portal/tcp/portal.ml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/portal/tcp/portal.ml b/portal/tcp/portal.ml index 47f8c04..b717d9c 100644 --- a/portal/tcp/portal.ml +++ b/portal/tcp/portal.ml @@ -186,3 +186,15 @@ let upgrade_to_tls (fd : Lwt_unix.file_descr) : Tls_lwt.Unix.t Lwt.t = let tls_config = Tls.Config.client ~authenticator () |> handle_msg in Tls_lwt.Unix.client_of_fd tls_config fd with Failure msg -> Lwt.fail_with msg + +let starttls (portal : t) : unit Lwt.t = + let s = match portal._socket with + | Plain s -> s + | Tls _ -> failwith "gjgehwgiorg" + in + let+ tls_sock = upgrade_to_tls s in + let sock = Tls tls_sock + in let stream, push = socket_to_stream sock + in portal.stream <- stream; + portal.push <- push; + portal._socket <- sock; -- cgit v1.2.3