-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow using Lwt_ssl and / or Tls_lwt, or neither of them
- Loading branch information
Antonio Nuno Monteiro
committed
Jan 30, 2019
1 parent
396b717
commit 1ac80ea
Showing
9 changed files
with
181 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,36 @@ | ||
(* -*- tuareg -*- *) | ||
(* This was inspired by `conduit-lwt-unix`'s dune file *) | ||
|
||
let v ~ssl ~tls () = | ||
let ssl, ssl_d = | ||
if ssl then "ssl_io_real", "lwt_ssl " | ||
else "ssl_io_dummy", "" | ||
in | ||
let tls, tls_d = | ||
if tls then "tls_io_real", "tls.lwt " | ||
else "tls_io_dummy", "" | ||
in | ||
Printf.sprintf {| | ||
(rule (copy %s.ml ssl_io.ml)) | ||
(rule (copy %s.ml tls_io.ml)) | ||
|
||
(library | ||
(name httpaf_lwt) | ||
(public_name httpaf-lwt) | ||
(libraries faraday-lwt-unix httpaf lwt.unix | ||
(select tls_impl.ml from | ||
(tls.lwt -> tls_io.ml) | ||
(lwt_ssl -> ssl_io.ml))) | ||
(modules buffer httpaf_lwt tls_impl) | ||
(libraries faraday-lwt-unix httpaf lwt.unix %s%s) | ||
(modules buffer httpaf_lwt tls_io ssl_io) | ||
(flags (:standard -safe-string))) | ||
|} ssl tls ssl_d tls_d | ||
|
||
let main () = | ||
let is_installed s = Printf.kprintf Sys.command "ocamlfind query %s" s = 0 in | ||
let ssl = is_installed "lwt_ssl" in | ||
let tls = Sys.unix && is_installed "tls.lwt" in | ||
Printf.printf | ||
"Configuration\n\ | ||
\ ssl : %b\n\ | ||
\ tls : %b\n%!" | ||
ssl tls; | ||
v ~ssl ~tls () | ||
|
||
let () = Jbuild_plugin.V1.send @@ main () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
let readf _socket = | ||
fun _fd _buffer -> | ||
Lwt.fail_with "Ssl not available" | ||
|
||
let writev _socket _fd = | ||
fun _iovecs -> | ||
Lwt.fail_with "Ssl not available" | ||
|
||
type client = [ `Ssl_not_available ] | ||
type server = [ `Ssl_not_available ] | ||
|
||
let make_client ?client:_ _socket = | ||
Lwt.fail_with "Ssl not available" | ||
|
||
let make_server ?server:_ ?certfile:_ ?keyfile:_ _socket = | ||
Lwt.fail_with "Ssl not available" |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
let readf _tls = | ||
fun _fd _buffer -> | ||
Lwt.fail_with "Tls not available" | ||
|
||
let writev _tls _fd = | ||
fun _iovecs -> | ||
Lwt.fail_with "Tls not available" | ||
|
||
type client = [ `Tls_not_available ] | ||
type server = [ `Tls_not_available ] | ||
|
||
let make_client ?client:_ _socket = | ||
Lwt.fail_with "Tls not available" | ||
|
||
let make_server ?server:_ ?certfile:_ ?keyfile:_ _socket = | ||
Lwt.fail_with "Tls not available" |
File renamed without changes.