summaryrefslogtreecommitdiff
path: root/gemini
diff options
context:
space:
mode:
authorRyan Kavanagh <rak@rak.ac>2020-06-12 21:38:57 -0400
committerRyan Kavanagh <rak@rak.ac>2020-06-12 21:38:57 -0400
commit8f9ad88bcd6c000f37bb11c82485c0d7c0a2e894 (patch)
tree837e4ed233cc9cadd81fa250f1416ac3575efb29 /gemini
parentRefactor transactions to use conduit (diff)
Revert "Refactor transactions to use conduit"
This reverts commit 7b8746607baf893dbabb81cd58394d299ecb4ae1.
Diffstat (limited to '')
-rw-r--r--gemini/dune3
-rw-r--r--gemini/geminiTransaction.ml23
2 files changed, 11 insertions, 15 deletions
diff --git a/gemini/dune b/gemini/dune
index 2a39e4b..7e15878 100644
--- a/gemini/dune
+++ b/gemini/dune
@@ -1,5 +1,4 @@
(library
(name gemini)
- (libraries base angstrom angstrom-lwt-unix conduit conduit-lwt-unix lwt lwt_ppx
- lwt_ssl mirage-crypto-pk ptime stdlib tls.lwt uri)
+ (libraries base angstrom angstrom-lwt-unix lwt lwt_ppx mirage-crypto-pk ptime stdlib tls.lwt uri)
(preprocess (pps lwt_ppx)))
diff --git a/gemini/geminiTransaction.ml b/gemini/geminiTransaction.ml
index 4752b2d..27208b7 100644
--- a/gemini/geminiTransaction.ml
+++ b/gemini/geminiTransaction.ml
@@ -228,21 +228,18 @@ struct
let response_of_string = Angstrom.parse_string ~consume:All response_parser
let transaction r =
- let resolver =
- let service : Resolver_lwt.service_fn = function
- | "gemini" -> Lwt.return (Some ({ name = "gemini";
- port = 1965;
- tls = true } : Resolver.service))
- | s -> Resolver_lwt_unix.system_service s in
- let rewrites = [("", Resolver_lwt_unix.system_resolver)] in
- Resolver_lwt.init ~service ~rewrites () in
+ let open Angstrom_lwt_unix in
+ let host = Base.Option.value_exn (Uri.host r.url)
+ ~message:"URL with no host?" in
+ let port = Base.Option.value_exn (Uri.port r.url)
+ ~message:"URL with no port?" in
+ let%lwt authenticator = r.authenticator in
try%lwt
- let%lwt ctx = Conduit_lwt_unix.init () in
- let%lwt endp = Resolver_lwt.resolve_uri ~uri:r.url resolver in
- let%lwt client = Conduit_lwt_unix.endp_to_client ~ctx endp in
- let%lwt (_flow, ic, oc) = Conduit_lwt_unix.connect ~ctx client in
+ let%lwt (ic, oc) = Tls_lwt.connect_ext
+ Tls.Config.(client ~peer_name:host ~authenticator
+ ~ciphers:Ciphers.default ()) (host, port) in
let%lwt () = Lwt_io.write oc (Uri.to_string r.url ^ "\r\n") in
- let%lwt (_, parsed) = Angstrom_lwt_unix.parse response_parser ic in
+ let%lwt (_, parsed) = parse response_parser ic in
Lwt.return parsed
with
| Tls_lwt.Tls_alert alert ->