Skip to content

Commit

Permalink
Rename tls-miou tls-miou-unix
Browse files Browse the repository at this point in the history
  • Loading branch information
dinosaure committed May 3, 2024
1 parent 5391e50 commit eec07e1
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
8 changes: 3 additions & 5 deletions miou/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
(library
(name tls_miou)
(public_name tls-miou)
(libraries miou.unix tls)
(instrumentation
(backend bisect_ppx)))
(name tls_miou_unix)
(public_name tls-miou-unix)
(libraries miou.unix tls))
2 changes: 1 addition & 1 deletion miou/tests/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
ptime
ptime.clock.os
crowbar
tls-miou)
tls-miou-unix)
(instrumentation
(backend bisect_ppx)))
22 changes: 11 additions & 11 deletions miou/tests/fuzz.ml
Original file line number Diff line number Diff line change
Expand Up @@ -131,38 +131,38 @@ let run ~role:_ actions tls =
Miou.yield ();
go buf tls actions
| Send str :: actions ->
Tls_miou.write tls str;
Tls_miou_unix.write tls str;
go buf tls actions
| Close :: actions ->
Tls_miou.close tls;
Tls_miou_unix.close tls;
go buf tls actions
| Shutdown cmd :: actions ->
Tls_miou.shutdown tls (cmd :> [ `read | `write | `read_write ]);
Tls_miou_unix.shutdown tls (cmd :> [ `read | `write | `read_write ]);
go buf tls actions
| Recv len :: actions ->
let tmp = Bytes.make len '\000' in
Tls_miou.really_read tls tmp;
Tls_miou_unix.really_read tls tmp;
Buffer.add_subbytes buf tmp 0 len;
go buf tls actions
in
let buf = Buffer.create 0x100 in
try go buf tls actions with
| End_of_file | Tls_miou.Closed_by_peer | Tls_miou.Tls_alert _
| Tls_miou.Tls_failure _ ->
inhibit (fun () -> Miou_unix.close (Tls_miou.file_descr tls));
| End_of_file | Tls_miou_unix.Closed_by_peer | Tls_miou_unix.Tls_alert _
| Tls_miou_unix.Tls_failure _ ->
inhibit (fun () -> Miou_unix.close (Tls_miou_unix.file_descr tls));
Buffer.contents buf
| exn ->
inhibit (fun () -> Miou_unix.close (Tls_miou.file_descr tls));
inhibit (fun () -> Miou_unix.close (Tls_miou_unix.file_descr tls));
raise exn

let run_client ~to_client:actions cfg addr =
let domain = Unix.domain_of_sockaddr addr in
let socket = Unix.socket ~cloexec:true domain Unix.SOCK_STREAM 0 in
Unix.connect socket addr;
let fd = Miou_unix.of_file_descr ~non_blocking:true socket in
let tls = Tls_miou.client_of_fd cfg fd in
let tls = Tls_miou_unix.client_of_fd cfg fd in
let finally () =
inhibit (fun () -> Miou_unix.close (Tls_miou.file_descr tls))
inhibit (fun () -> Miou_unix.close (Tls_miou_unix.file_descr tls))
in
Fun.protect ~finally @@ fun () -> run ~role:"client" actions tls

Expand Down Expand Up @@ -201,7 +201,7 @@ let run_server ~to_server:actions ~stop fd cfg =
| Ok (fd, _) ->
ignore
( Miou.call_cc ~orphans @@ fun () ->
match Tls_miou.server_of_fd cfg fd with
match Tls_miou_unix.server_of_fd cfg fd with
| tls -> run ~role:"server" actions tls
| exception _ ->
Miou_unix.close fd;
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tls-miou.opam → tls-miou-unix.opam
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ depends: [
"ptime" {with-test}
]
tags: [ "org:mirage"]
synopsis: "Transport Layer Security purely in OCaml, Miou layer"
synopsis: "Transport Layer Security purely in OCaml, Miou+Unix layer"
description: """
Tls-miou provides an effectful Tls_miou module to be used with Miou.
Tls-miou provides an effectful Tls_miou module to be used with Miou and Unix.
"""

pin-depends: [
Expand Down

0 comments on commit eec07e1

Please sign in to comment.