Skip to content

Commit 58ffe10

Browse files
authored
Merge pull request #76 from hannesm/variants
defunctorise
2 parents 4617c9c + aa2b842 commit 58ffe10

File tree

9 files changed

+12
-16
lines changed

9 files changed

+12
-16
lines changed

awa-mirage.opam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ depends: [
2020
"cstruct" {>= "6.0.0"}
2121
"mtime" {>= "1.0.0"}
2222
"lwt" {>= "5.3.0"}
23-
"mirage-time" {>= "2.0.0"}
23+
"mirage-sleep" {>= "4.0.0"}
2424
"duration" {>= "0.2.0"}
2525
"mirage-flow" {>= "4.0.0"}
26-
"mirage-clock" {>= "3.0.0"}
26+
"mirage-mtime" {>= "4.0.0"}
2727
"logs"
2828
]
2929
synopsis: "SSH implementation in OCaml"

awa.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ depends: [
1717
"ocaml" {>= "4.10.0"}
1818
"dune" {>= "2.7"}
1919
"mirage-crypto" {>= "1.0.0"}
20-
"mirage-crypto-rng" {>= "1.0.0"}
20+
"mirage-crypto-rng" {>= "1.2.0"}
2121
"mirage-crypto-pk"
2222
"mirage-crypto-ec" {>= "1.0.0"}
2323
"x509" {>= "1.0.0"}

mirage/awa_mirage.ml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ open Lwt.Infix
33
let src = Logs.Src.create "awa.mirage" ~doc:"Awa mirage"
44
module Log = (val Logs.src_log src : Logs.LOG)
55

6-
module Make (F : Mirage_flow.S) (T : Mirage_time.S) (M : Mirage_clock.MCLOCK) = struct
7-
8-
module MCLOCK = M
9-
6+
module Make (F : Mirage_flow.S) = struct
107
type error = [ `Msg of string
118
| `Read of F.error
129
| `Write of F.write_error ]
@@ -81,8 +78,7 @@ module Make (F : Mirage_flow.S) (T : Mirage_time.S) (M : Mirage_clock.MCLOCK) =
8178
| Ok () -> write_flow t d)
8279
(Ok ()) bufs
8380

84-
let now () =
85-
Mtime.of_uint64_ns (M.elapsed_ns ())
81+
let now () = Mtime.of_uint64_ns (Mirage_mtime.elapsed_ns ())
8682

8783
let read_react t =
8884
match t.state with
@@ -305,7 +301,7 @@ module Make (F : Mirage_flow.S) (T : Mirage_time.S) (M : Mirage_clock.MCLOCK) =
305301
match server.Awa.Server.key_eol with
306302
| None -> []
307303
| Some mtime ->
308-
[ T.sleep_ns (Mtime.to_uint64_ns mtime) >>= fun () -> Lwt.return Rekey ]
304+
[ Mirage_sleep.ns (Mtime.to_uint64_ns mtime) >>= fun () -> Lwt.return Rekey ]
309305

310306
let rec nexus t fd server input_buffer pending_promises =
311307
wrapr (Awa.Server.pop_msg2 server input_buffer)

mirage/awa_mirage.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(** Effectful operations using Mirage for pure SSH. *)
22

33
(** SSH module given a flow *)
4-
module Make (F : Mirage_flow.S) (T : Mirage_time.S) (M : Mirage_clock.MCLOCK) : sig
4+
module Make (F : Mirage_flow.S) : sig
55

66
(** possible errors: incoming alert, processing failure, or a
77
problem in the underlying flow. *)

mirage/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
(name awa_mirage)
33
(public_name awa-mirage)
44
(wrapped false)
5-
(libraries awa mirage-flow mirage-clock mirage-time duration lwt mtime logs))
5+
(libraries awa mirage-flow mirage-mtime mirage-sleep duration lwt mtime logs))

test/awa_gen_key.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
let gen_key seed typ =
3-
Mirage_crypto_rng_unix.initialize (module Mirage_crypto_rng.Fortuna);
3+
Mirage_crypto_rng_unix.use_default ();
44
let seed = match seed with
55
| None -> Base64.encode_string (Mirage_crypto_rng.generate 30)
66
| Some x -> x

test/awa_test_client.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ let write_cstruct fd buf =
3939

4040
let jump _ user pass seed typ keyfile authenticator host port =
4141
let ( let* ) = Result.bind in
42-
Mirage_crypto_rng_unix.initialize (module Mirage_crypto_rng.Fortuna);
42+
Mirage_crypto_rng_unix.use_default ();
4343
let fd = Unix.(socket PF_INET SOCK_STREAM 0) in
4444
Unix.(connect fd (ADDR_INET (inet_addr_of_string host, port)));
4545
match

test/awa_test_server.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ let rec wait_connection priv_key listen_fd server_port =
225225
wait_connection priv_key listen_fd server_port
226226

227227
let jump () =
228-
Mirage_crypto_rng_unix.initialize (module Mirage_crypto_rng.Fortuna);
228+
Mirage_crypto_rng_unix.use_default ();
229229
let g = Mirage_crypto_rng.(create ~seed:"180586" (module Fortuna)) in
230230
let (ec_priv,_) = Mirage_crypto_ec.Ed25519.generate ~g () in
231231
let priv_key = Awa.Hostkey.Ed25519_priv (ec_priv) in

test/test.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ let all_tests = [
608608
]
609609

610610
let _ =
611-
Mirage_crypto_rng_unix.initialize (module Mirage_crypto_rng.Fortuna);
611+
Mirage_crypto_rng_unix.use_default ();
612612
Sys.set_signal Sys.sigalrm (Sys.Signal_handle (fun _ -> failwith "timeout"));
613613
Unix.chmod "data/awa_test_rsa" 0o600;
614614
List.iter run_test all_tests;

0 commit comments

Comments
 (0)