File tree Expand file tree Collapse file tree 5 files changed +27
-25
lines changed Expand file tree Collapse file tree 5 files changed +27
-25
lines changed Original file line number Diff line number Diff line change 22 (name git_mirage_tcp)
33 (modules git_mirage_tcp)
44 (public_name git-mirage.tcp)
5- (libraries mimic result fmt lwt mirage-flow ipaddr mirage-protocols
6- mirage-stack))
5+ (libraries git.nss.git mimic result fmt lwt mirage-flow ipaddr
6+ mirage-protocols mirage- stack))
77
88(library
99 (name git_mirage_ssh)
Original file line number Diff line number Diff line change @@ -35,14 +35,21 @@ struct
3535 let ctx = with_resolv Mimic. empty
3636
3737 let with_smart_git_endpoint edn ctx =
38- match Smart_git.Endpoint. of_string edn with
39- | Ok { Smart_git.Endpoint. path; scheme = `SSH _ ; _ } ->
40- ssh (with_git_path path ctx)
41- | Ok { Smart_git.Endpoint. path; scheme = `Git ; _ } ->
42- gri (with_git_path path ctx)
43- | Ok { Smart_git.Endpoint. path; scheme = `HTTP _ ; _ } ->
44- http (with_git_path path ctx)
45- | Ok { Smart_git.Endpoint. path; scheme = `HTTPS _ ; _ } ->
46- https (with_git_path path ctx)
47- | _ -> ctx
38+ let edn = Smart_git.Endpoint. of_string edn in
39+ let ctx0 =
40+ match edn with
41+ | Ok { Smart_git.Endpoint. path; scheme = `SSH _ ; _ } ->
42+ ssh (with_git_path path ctx)
43+ | Ok { Smart_git.Endpoint. path; scheme = `Git ; _ } ->
44+ gri (with_git_path path ctx)
45+ | Ok { Smart_git.Endpoint. path; scheme = `HTTP _ ; _ } ->
46+ http (with_git_path path ctx)
47+ | Ok { Smart_git.Endpoint. path; scheme = `HTTPS _ ; _ } ->
48+ https (with_git_path path ctx)
49+ | _ -> ctx
50+ in
51+ match edn with
52+ | Ok { Smart_git.Endpoint. host = `Addr (Ipaddr. V4 v ); _ } ->
53+ Mimic. add TCP. tcp_ipaddr v ctx0
54+ | _ -> ctx0
4855end
Original file line number Diff line number Diff line change @@ -37,17 +37,9 @@ module Make (Stack : Mirage_stack.V4) = struct
3737
3838 let tcp_ipaddr = Mimic. make ~name: " tcp-ipaddr"
3939 let tcp_port = Mimic. make ~name: " tcp-port"
40- let tcp_stack = Mimic. make ~name: " tcp-stack"
40+ let tcp_stack : Stack.t Mimic.value = Mimic. make ~name: " tcp-stack"
4141 let with_port v ctx = Mimic. add tcp_port v ctx
4242 let with_ipaddr v ctx = Mimic. add tcp_ipaddr v ctx
4343 let with_stack v ctx = Mimic. add tcp_stack v ctx
44-
45- let with_resolv ctx =
46- let k stack ipaddr port = Lwt. return_some (stack, ipaddr, port) in
47- Mimic. (
48- fold tcp_endpoint
49- Fun. [ req tcp_stack; req tcp_ipaddr; req tcp_port ]
50- ~k ctx)
51-
52- let ctx = with_resolv Mimic. empty
44+ let ctx = Mimic. empty
5345end
Original file line number Diff line number Diff line change @@ -10,6 +10,5 @@ module Make (Stack : Mirage_stack.V4) : sig
1010 val with_port : int -> Mimic .ctx -> Mimic .ctx
1111 val with_ipaddr : Ipaddr.V4 .t -> Mimic .ctx -> Mimic .ctx
1212 val with_stack : Stack .t -> Mimic .ctx -> Mimic .ctx
13- val with_resolv : Mimic .ctx -> Mimic .ctx
1413 val ctx : Mimic .ctx
1514end
Original file line number Diff line number Diff line change @@ -126,14 +126,13 @@ module Endpoint = struct
126126 in
127127 let parse_uri x =
128128 let uri = Uri. of_string x in
129+ let path = Uri. path uri in
129130 let host str =
130131 Domain_name. of_string str
131132 >> = Domain_name. host
132133 >> | (fun x -> `Domain x)
133134 < |> (Ipaddr. of_string str >> | fun x -> `Addr x)
134135 in
135- let path = Astring.String. drop ~max: 1 ~sat: (( = ) '/' ) (Uri. path uri) in
136- (* XXX(dinosaure): [uri] prepend the path by a '/'. *)
137136 match Uri. scheme uri, Uri. host uri with
138137 | Some "git" , Some str ->
139138 host str >> = fun host -> R. ok { scheme = `Git ; path; host }
@@ -344,6 +343,11 @@ struct
344343 let open Lwt.Infix in
345344 Mimic. resolve ctx >> = function
346345 | Error _ as err ->
346+ let pp_host ppf = function
347+ | `Domain v -> Domain_name. pp ppf v
348+ | `Addr v -> Ipaddr. pp ppf v
349+ in
350+ Log. err (fun m -> m " %a not found" pp_host host);
347351 pack None ;
348352 Lwt. return err
349353 | Ok flow ->
You can’t perform that action at this time.
0 commit comments