Skip to content

Commit

Permalink
dns-client-mirage: revert renaming of io_addr to Plain | Tls, use Pla…
Browse files Browse the repository at this point in the history
…intext | Tls
  • Loading branch information
hannesm committed Oct 24, 2022
1 parent e8f3340 commit 3e5968d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions mirage/client/dns_client_mirage.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module IM = Map.Make(Int)
module type S = sig
module Transport : Dns_client.S
with type io_addr = [
| `Plain of Ipaddr.t * int
| `Plaintext of Ipaddr.t * int
| `Tls of Tls.Config.client * Ipaddr.t * int
]
and type +'a io = 'a Lwt.t
Expand Down Expand Up @@ -97,11 +97,11 @@ The format of a nameserver is:
| "tcp" :: nameserver ->
let str = String.concat ":" nameserver in
let* ipaddr, port = Ipaddr.with_port_of_string ~default:53 str in
Ok (`Tcp, `Plain (ipaddr, port))
Ok (`Tcp, `Plaintext (ipaddr, port))
| "udp" :: nameserver ->
let str = String.concat ":" nameserver in
let* ipaddr, port = Ipaddr.with_port_of_string ~default:53 str in
Ok (`Udp, `Plain (ipaddr, port))
Ok (`Udp, `Plaintext (ipaddr, port))
| _ ->
Error (`Msg ("Unable to decode nameserver " ^ str))
end |> Result.map_error (function `Msg e -> `Msg (e ^ format))
Expand All @@ -110,12 +110,12 @@ The format of a nameserver is:
with type stack = S.t
and type +'a io = 'a Lwt.t
and type io_addr = [
| `Plain of Ipaddr.t * int
| `Plaintext of Ipaddr.t * int
| `Tls of Tls.Config.client * Ipaddr.t * int
] = struct
type stack = S.t
type io_addr = [
| `Plain of Ipaddr.t * int
| `Plaintext of Ipaddr.t * int
| `Tls of Tls.Config.client * Ipaddr.t * int
]
type +'a io = 'a Lwt.t
Expand Down Expand Up @@ -342,10 +342,11 @@ The format of a nameserver is:
t.requests (Lwt.return (Ok ()))

let to_pairs =
List.map (function `Plain (ip, port) | `Tls (_, ip, port) -> (ip, port))
List.map (function `Plaintext (ip, port)
| `Tls (_, ip, port) -> (ip, port))

let find_ns ns (addr, port) =
List.find (function `Plain (ip, p) | `Tls (_, ip, p) ->
List.find (function `Plaintext (ip, p) | `Tls (_, ip, p) ->
Ipaddr.compare ip addr = 0 && p = port)
ns

Expand Down Expand Up @@ -384,7 +385,7 @@ The format of a nameserver is:
in
let config = find_ns t.nameservers addr in
match config with
| `Plain _ -> continue (`Plain flow)
| `Plaintext _ -> continue (`Plain flow)
| `Tls (tls_cfg, _ip, _port) ->
TLS.client_of_flow tls_cfg flow >>= function
| Ok tls -> continue (`Tls tls)
Expand Down Expand Up @@ -428,7 +429,7 @@ The format of a nameserver is:
match t.proto, t.flow with
| `Udp, _ ->
let dst, dst_port = match t.nameservers with
| `Plain (ip, port) :: _ -> ip, port
| `Plaintext (ip, port) :: _ -> ip, port
| _ -> assert false
in
let src = S.IP.src (S.ip t.stack) ~dst in
Expand Down
2 changes: 1 addition & 1 deletion mirage/client/dns_client_mirage.mli
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module type S = sig
module Transport : Dns_client.S
with type io_addr = [
| `Plain of Ipaddr.t * int
| `Plaintext of Ipaddr.t * int
| `Tls of Tls.Config.client * Ipaddr.t * int
]
and type +'a io = 'a Lwt.t
Expand Down

0 comments on commit 3e5968d

Please sign in to comment.