diff options
author | Clombrong <cromblong@egregore.fun> | 2025-06-28 12:53:47 +0200 |
---|---|---|
committer | Clombrong <cromblong@egregore.fun> | 2025-06-28 16:44:54 +0200 |
commit | c633d0b1b27b96002c51228e7ade6327d687f4a1 (patch) | |
tree | e4da8446c0c46112a3fe2edb29da6e5970d1c269 | |
parent | b0e746b6c0f9cd9393ff105e6d0e0f0e33ee6a43 (diff) |
feat(stream): pass down auth config to the negotiate function
-rw-r--r-- | lib/stream.ml | 10 | ||||
-rw-r--r-- | test/hello.ml | 2 |
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/stream.ml b/lib/stream.ml index 2b98192..0b600a7 100644 --- a/lib/stream.ml +++ b/lib/stream.ml @@ -43,7 +43,11 @@ let parse_features (el : Xml.element) : features = Basically, it conforms to {{: https://datatracker.ietf.org/doc/html/rfc6120#section-4.3 }}. *) -let negotiate ?(prefer_starttls = true) (domain : string) (portal : Portal.t) : features Lwt.t = +let negotiate + ?(prefer_starttls = true) + (domain : string) + (portal : Portal.t) + (_auth : Sasl.auth_config) : features Lwt.t = (* Restart a stream: Send the usual business, ask for features. *) let start_stream () : features Lwt.t = let* _id = Portal.header domain portal @@ -60,7 +64,7 @@ let negotiate ?(prefer_starttls = true) (domain : string) (portal : Portal.t) : Once [None] is pushed into the stream, the receiving stream is drained and the socket is closed. *) -let initiate (domain : string) : (Portal.t * features) Lwt.t = +let initiate (domain : string) (auth : Sasl.auth_config) : (Portal.t * features) Lwt.t = let open Portal in let* p = connect domain in let push = function @@ -70,5 +74,5 @@ let initiate (domain : string) : (Portal.t * features) Lwt.t = (* Empty the stream completely, then close the socket. *) Lwt.async (fun () -> let+ () = Markup_lwt.drain p.stream in p.push None) in let portal = {p with push} in - let+ features = negotiate domain portal + let+ features = negotiate domain portal auth in (portal, features) diff --git a/test/hello.ml b/test/hello.ml index e55b44a..212d7f2 100644 --- a/test/hello.ml +++ b/test/hello.ml @@ -18,7 +18,7 @@ let main = preferred_mechanisms = [Sasl.PLAIN] } in let domain = (List.nth (String.split_on_char '@' config.jid) 1) in - let* portal, features = Stream.initiate domain in + let* portal, features = Stream.initiate domain config in Lwt.catch (fun () -> program portal config features >|= (fun () -> portal.push None)) (fun exn -> |