From 13ab7a0170fb18738d8f0a491c95416c8f2c0c4d Mon Sep 17 00:00:00 2001 From: Clombrong Date: Sun, 29 Jun 2025 08:27:36 +0200 Subject: feat(portal): add _encrypted function --- portal/portal.mli | 3 +++ portal/tcp/portal.ml | 4 ++++ portal/ws/portal.ml | 2 ++ 3 files changed, 9 insertions(+) (limited to 'portal') diff --git a/portal/portal.mli b/portal/portal.mli index 62a7bd7..ed8765d 100644 --- a/portal/portal.mli +++ b/portal/portal.mli @@ -38,3 +38,6 @@ val starttls : t -> unit Lwt.t When [from] is specified, a from attribute is included. *) val header : ?from:string -> string -> t -> string Lwt.t + +(** [_encrypted socket] returns whether [socket] is encrypted, using TLS or otherwise. *) +val _encrypted : socket -> bool diff --git a/portal/tcp/portal.ml b/portal/tcp/portal.ml index 0105a06..d36563a 100644 --- a/portal/tcp/portal.ml +++ b/portal/tcp/portal.ml @@ -174,6 +174,10 @@ let starttls (portal : t) : unit Lwt.t = | Tls _ -> Lwt.fail_with "TLS is already enabled on this socket!" in portal._socket <- Tls tls_sock +let _encrypted = function + | Plain _ -> false + | Tls _ -> true + let header ?from domain (portal : t) = let stanza = let attributes = diff --git a/portal/ws/portal.ml b/portal/ws/portal.ml index 0d15e5a..5ad82c3 100644 --- a/portal/ws/portal.ml +++ b/portal/ws/portal.ml @@ -164,3 +164,5 @@ let connect domain = {stream; push; _socket=ws} let starttls _ = Lwt.fail_with "STARTTLS is unimplemented in WebSockets." + +let _encrypted _ = true -- cgit v1.2.3