diff options
author | Clombrong <cromblong@egregore.fun> | 2025-08-14 22:56:13 +0200 |
---|---|---|
committer | Clombrong <cromblong@egregore.fun> | 2025-08-15 00:14:00 +0200 |
commit | cbdbb587236f8d747ae5baf4b4f92e9458dff4f1 (patch) | |
tree | f3cd4c27529eea1621eed6554ccf18006ddd8665 | |
parent | e4e8a81f030dc599b1d5dc84b9725667c3872124 (diff) |
feat(portal): add opaque domain type to portal
-rw-r--r-- | portal/portal.mli | 10 | ||||
-rw-r--r-- | portal/tcp/portal.ml | 6 | ||||
-rw-r--r-- | portal/ws/portal.ml | 6 |
3 files changed, 20 insertions, 2 deletions
diff --git a/portal/portal.mli b/portal/portal.mli index ed8765d..10b6bc3 100644 --- a/portal/portal.mli +++ b/portal/portal.mli @@ -4,6 +4,12 @@ exception MalformedStanza of Error.t type socket +(** Opaque domain name type. *) +type domain + +val domain_of_string : string -> domain +val domain_to_string : domain -> string + (** The type of portals communicating with an XMPP server via [_socket]. [stream] is the data sent by the XMPP server. @@ -23,7 +29,7 @@ type t = { val xmlns : string (** [connect domain] returns a Portal connected to the XMPP server [domain]. *) -val connect : string -> t Lwt.t +val connect : domain -> t Lwt.t (** [starttls portal] mutates [portal] into a TLS-encrypted stream with the same state. @@ -37,7 +43,7 @@ val starttls : t -> unit Lwt.t the response stream header. When [from] is specified, a from attribute is included. *) -val header : ?from:string -> string -> t -> string Lwt.t +val header : ?from:string -> domain -> 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 c88ac98..a3f163e 100644 --- a/portal/tcp/portal.ml +++ b/portal/tcp/portal.ml @@ -4,6 +4,12 @@ open Markup type socket = Plain of Lwt_unix.file_descr | Tls of Tls_lwt.Unix.t +(** Opaque domain name type. Currently a string, might be subject to change. *) +type domain = string + +let domain_of_string (s : string) : domain = s +let domain_to_string (s : domain) : string = s + type t = { mutable stream : (signal, async) stream; mutable push : (signal, sync) stream option -> unit; diff --git a/portal/ws/portal.ml b/portal/ws/portal.ml index 5ad82c3..6b42216 100644 --- a/portal/ws/portal.ml +++ b/portal/ws/portal.ml @@ -7,6 +7,12 @@ let sjs = Js.to_string type socket = WebSockets.webSocket Js.t +(** Opaque domain name type. Currently a string. *) +type domain = string + +let domain_of_string (s : string) : domain = s +let domain_to_string (s : domain) : string = s + type t = { mutable stream : (signal, async) stream; mutable push : (signal, sync) stream option -> unit; |