diff --git a/examples/async/dune b/examples/async/dune index 910afb1245..92af22612d 100644 --- a/examples/async/dune +++ b/examples/async/dune @@ -1,6 +1,6 @@ (executables (names hello_world receive_post) - (libraries cohttp-async base async_kernel)) + (libraries mirage-crypto cohttp-async base async_kernel)) (alias (name runtest) diff --git a/examples/async/s3_cp.ml b/examples/async/s3_cp.ml index a6f7446a1d..81efea28fc 100644 --- a/examples/async/s3_cp.ml +++ b/examples/async/s3_cp.ml @@ -45,7 +45,7 @@ open Base open Core -open Async_kernel +open Async open Cohttp open Cohttp_async @@ -78,9 +78,9 @@ module Compat = struct if is_hex(String.get s (i+1)) && is_hex(String.get s (i+2)) then Buffer.add_char buf c else - Buffer.add_bytes buf "%25" + Buffer.add_string buf "%25" end - | _ -> Buffer.add_bytes buf (Printf.sprintf "%%%X" (Char.to_int c)) + | _ -> Buffer.add_string buf (Printf.sprintf "%%%X" (Char.to_int c)) done; Buffer.contents buf @@ -108,7 +108,7 @@ module Compat = struct URI.encoded_of_query encodes [""] as ?a=, and [] as ?a. *) Uri.query uri - |> List.sort ~cmp:ksrt + |> List.sort ~compare:ksrt |> List.map ~f:(fun (k,v) -> (k, match v with [] -> [""] | x -> x)) |> Uri.encoded_of_query @@ -180,7 +180,7 @@ module Auth = struct let digest s = (* string -> sha256 as a hex string *) - Nocrypto.Hash.(digest `SHA256 (Cstruct.of_string s)) + Mirage_crypto.Hash.(digest `SHA256 (Cstruct.of_string s)) |> Compat.cstruct_to_hex_string let make_amz_headers ?body time = @@ -212,7 +212,7 @@ module Auth = struct (* Sort query string in alphabetical order by key *) let canonical_query = Compat.encode_query_string uri in let sorted_headers = Header.to_list request.headers - |> List.sort ~cmp:ksrt in + |> List.sort ~compare:ksrt in let canonical_headers = sorted_headers |> List.fold ~init:"" ~f:(fun acc (k,v) -> acc ^ @@ -244,7 +244,7 @@ module Auth = struct Printf.sprintf "AWS4-HMAC-SHA256\n%s\n%s\n%s" time_str scope_str hashed_req let make_signing_key ?date ~region ~service ~secret_access_key = - let mac k v = Nocrypto.Hash.(mac `SHA256 + let mac k v = Mirage_crypto.Hash.(mac `SHA256 ~key:k (Cstruct.of_string v)) in let date' = match date with @@ -269,7 +269,7 @@ module Auth = struct (string_of_region region) (string_of_service service) in - let signature = Nocrypto.Hash.(mac `SHA256 + let signature = Mirage_crypto.Hash.(mac `SHA256 ~key:signing_key (Cstruct.of_string string_to_sign)) in let auth_header = Printf.sprintf @@ -343,7 +343,7 @@ let determine_paths src dst = | (false, false) -> failwith "Use cp(1) :)" | (true, true) -> failwith "Does not support copying from s3 to s3" -let run region_str aws_access_key aws_secret_key src dst () = +let main region_str aws_access_key aws_secret_key src dst () = (* nb client does not support redirects or preflight 100 *) let open S3 in let region = region_of_string region_str in @@ -376,14 +376,15 @@ let run region_str aws_access_key aws_secret_key src dst () = end let () = - Command.async + let open Async_command in + async_spec ~summary:"Simple command line client that copies files to/from S3" - Command.Spec.(empty - +> flag "-r" (optional_with_default "us-east-1" string) - ~doc:"string AWS Region" - +> anon ("aws_access_key" %: string) - +> anon ("aws_secret_key" %: string) - +> anon ("src" %: string) - +> anon ("dst" %: string) - ) run - |> Command.run + Spec.(empty + +> flag "-r" (optional_with_default "us-east-1" string) + ~doc:"string AWS Region" + +> anon ("aws_access_key" %: string) + +> anon ("aws_secret_key" %: string) + +> anon ("src" %: string) + +> anon ("dst" %: string) + ) main + |> run