aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClombrong <cromblong@egregore.fun>2025-06-29 08:27:36 +0200
committerClombrong <cromblong@egregore.fun>2025-06-29 08:27:36 +0200
commit13ab7a0170fb18738d8f0a491c95416c8f2c0c4d (patch)
tree48471eff88bdc6819c22260619cc02ce3063dd56
parent7366648aeb205a6a47217bbf190ec45f8ce0c79f (diff)
feat(portal): add _encrypted function
-rw-r--r--portal/portal.mli3
-rw-r--r--portal/tcp/portal.ml4
-rw-r--r--portal/ws/portal.ml2
3 files changed, 9 insertions, 0 deletions
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