aboutsummaryrefslogtreecommitdiff
path: root/portal/tcp
diff options
context:
space:
mode:
authorClombrong <cromblong@egregore.fun>2025-06-28 09:26:59 +0200
committerClombrong <cromblong@egregore.fun>2025-06-28 09:27:46 +0200
commit5483070246cebb3a9dce06a237d0561f8caa02fd (patch)
tree5f7f8b208ad3c525900cda7a3af1f39a83a535b1 /portal/tcp
parent27230436c2f8602a61a267ecbb07f46b7a4d02c3 (diff)
feat(portal_to_tcp): implement starttls function
Diffstat (limited to 'portal/tcp')
-rw-r--r--portal/tcp/portal.ml12
1 files changed, 12 insertions, 0 deletions
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;