-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Directly use Happy_eyeballs_lwt instead of a copy of it #346
Conversation
We probably can fully delete the cycle between |
Indeed, but that would be rather itchy, no? We'd need to have |
4d7415f
to
3cfe1d5
Compare
Hmm, I guess I'm still a bit puzzled. What I thought about the API:
So, what is there to note? I believe each application should only have a single happy-eyeballs instance. There's no need for having multiple (there would be if there would be multiple network stacks, but there aren't). A single instance means a shared DNS cache, and a simpler way to debug everything. With this PR, the dns-client-lwt uses the very same happy-eyeballs instance \o/ So, for a client there are then two choices (by default):
Does this make sense? This also means that we do not need a |
issues with the proposal above (and my changes to your happy-eyeballs PR):
So, another proposal:
|
see 3fc14f0 what I have in mind :) |
I rebased and added some commits, this is now as well adapting dns-client-mirage to use happy-eyeballs-mirage. A review would be great (API + whether it works), it seems to compile, but I haven't tested it. |
I finally tried to make a simple let ( let* ) = Lwt.bind
module Make
(S : Tcpip.Stack.V4V6)
(H : Happy_eyeballs_mirage.S with type flow = S.TCP.flow)
(D : Dns_client_mirage.S) = struct
let start _stack he _dns =
let* flow = H.connect he "google.com" [ 80; 443 ] in
match flow with
| Ok ((ipaddr, port), flow) ->
Fmt.pr ">>> connected to google.com via %a:%d\n%!" Ipaddr.pp ipaddr port;
S.TCP.close flow
| Error (`Msg msg) -> failwith msg
end And this is the open Mirage
let connect_handler =
main "Unikernel.Make"
(stackv4v6 @-> happy_eyeballs @-> dns_client @-> job)
let stackv4v6 = generic_stackv4v6 default_network
let happy_eyeballs = generic_happy_eyeballs stackv4v6
let dns = generic_dns_client stackv4v6 happy_eyeballs
let () = register "connect" [ connect_handler $ stackv4v6 $ happy_eyeballs $ dns ] Of course, we need to upgrade the mirage tool and reverse again the dependency. I did a draft here: mirage/mirage#1543. WDYT? |
your example looks nice. but can we remove the "dns" and |
So we can ignore it but we must explicitly say that we want the DNS stack at some points to be able to do some DNS resolution into our |
And looking into your code, esp. in the mirage changes, I guess:
but I've no idea how we can write that in the mirage tool. maybe we can depend on generic_dns_client in happy_eyeballs device, and then bind a |
I'd like a user of happy eyeballs device be: let ( let* ) = Lwt.bind
module Make
(S : Tcpip.Stack.V4V6)
(H : Happy_eyeballs_mirage.S with type flow = S.TCP.flow) = struct
let start _stack he =
let* flow = H.connect he "google.com" [ 80; 443 ] in
match flow with
| Ok ((ipaddr, port), flow) ->
Fmt.pr ">>> connected to google.com via %a:%d\n%!" Ipaddr.pp ipaddr port;
S.TCP.close flow
| Error (`Msg msg) -> failwith msg
end And this is the config.ml. open Mirage
let connect_handler =
main "Unikernel.Make"
(stackv4v6 @-> happy_eyeballs @-> job)
let stackv4v6 = generic_stackv4v6 default_network
let happy_eyeballs = generic_happy_eyeballs stackv4v6
let () = register "connect" [ connect_handler $ stackv4v6 $ happy_eyeballs ] Do you think that is possible? |
To re-centralize my initial point, this PR and the PR on
So it's actually possible to hide everything and say that the given If we go down this path, we must extend arguments of |
From our discussion on IRC, we figured:
The reasoning for the latter is that we will use only a single happy-eyeballs instance across the entire unikernel:
We should settle this (as mentioned, it likely requires some minor modification to happy-eyeballs) to get this through the door and cut a release of DNS. I plan to work on this today. |
Timeouts and delays can be specified during establishing a connection in happy-eyeballs with robur-coop/happy-eyeballs#42 |
This commit delete a dependency cycle between happy-eyeballs, happy-eyeballs-lwt, dns and dns-client-lwt. The basic happy-eyeballs-lwt implementation is not able yet to resolve domain-name but the user can inject a getaddrinfo which may come from dns-client-lwt. The idea is: 1) create a happy-eyeballs-lwt instance 2) create a dns-client-lwt instance 3) inject Dns_client_lwt.getaddrinfo into our happy-eyeballs-lwt instance This patch delete a duplicate code about happy-eyeballs implementations.
resolver and provide a new function, [create_happy_eyeballs], which does the injection of the [ocaml-dns] DNS resolver.
Ok, I updated this PR in respect to the happy-eyeballs 1.1.0 release, and the discussion we had on IRC @dinosaure. Would be great if you could take a look into the recent commits, and whether this is in line with what you think should be done. Now, there's |
I updated the mirage/mirage#1543 according to your recent change. The unikernel itself did not change but it compiles again if you pin this version of |
For me, the PR is ok to merge now 👍. And the mirage devices are updated. The example given below works and was tested. |
CHANGES: * dns-client (lwt, mirage): depend on happy-eyeballs-{lwt,mirage} instead of duplicating the code. This requires happy-eyeballs 1.1.0, and now the same Happy_eyeballs_{lwt,mirage}.t is used for DNS (connecting to the nameserver) and for the application (connecting to a remote host) (@dinosaure @hannesm mirage/ocaml-dns#346) * server: improve API documentation (@hannesm 1a80bd4080e597687152cf351d035ef5f00c5946 000ae02dfc477d91c05891e3891a447328ae448a) * server: add a `packet_callback` to `handle_packet` and `handle_buf` (@RyanGibb mirage/ocaml-dns#349) * server: expose `update_data` (@RyanGibb mirage/ocaml-dns#350) * resolver: b root name server IP change (@hannesm mirage/ocaml-dns#348) * secondary server [mirage]: avoid infinite loop in connect (avoids SYN floods) (@hannesm @reynir mirage/ocaml-dns#347) * resolver, dns_zone: use consistently `Log` instead of `Logs` (@palainp mirage/ocaml-dns#342)
CHANGES: * dns-client (lwt, mirage): depend on happy-eyeballs-{lwt,mirage} instead of duplicating the code. This requires happy-eyeballs 1.1.0, and now the same Happy_eyeballs_{lwt,mirage}.t is used for DNS (connecting to the nameserver) and for the application (connecting to a remote host) (@dinosaure @hannesm mirage/ocaml-dns#346) * server: improve API documentation (@hannesm 1a80bd4080e597687152cf351d035ef5f00c5946 000ae02dfc477d91c05891e3891a447328ae448a) * server: add a `packet_callback` to `handle_packet` and `handle_buf` (@RyanGibb mirage/ocaml-dns#349) * server: expose `update_data` (@RyanGibb mirage/ocaml-dns#350) * resolver: b root name server IP change (@hannesm mirage/ocaml-dns#348) * secondary server [mirage]: avoid infinite loop in connect (avoids SYN floods) (@hannesm @reynir mirage/ocaml-dns#347) * resolver, dns_zone: use consistently `Log` instead of `Logs` (@palainp mirage/ocaml-dns#342)
Release 8.0.0 CHANGES: * dns-client (lwt, mirage): depend on happy-eyeballs-{lwt,mirage} instead of duplicating the code. This requires happy-eyeballs 1.1.0, and now the same Happy_eyeballs_{lwt,mirage}.t is used for DNS (connecting to the nameserver) and for the application (connecting to a remote host) (@dinosaure @hannesm mirage#346) * server: improve API documentation (@hannesm 1a80bd4 000ae02) * server: add a `packet_callback` to `handle_packet` and `handle_buf` (@RyanGibb mirage#349) * server: expose `update_data` (@RyanGibb mirage#350) * resolver: b root name server IP change (@hannesm mirage#348) * secondary server [mirage]: avoid infinite loop in connect (avoids SYN floods) (@hannesm @reynir mirage#347) * resolver, dns_zone: use consistently `Log` instead of `Logs` (@palainp mirage#342)
This commit delete a dependency cycle between happy-eyeballs, happy-eyeballs-lwt, dns and dns-client-lwt. The basic happy-eyeballs-lwt implementation is not able yet to resolve domain-name but the user can inject a getaddrinfo which may come from dns-client-lwt. The idea is: 1) create a happy-eyeballs-lwt instance
2) create a dns-client-lwt instance
3) inject Dns_client_lwt.getaddrinfo into our happy-eyeballs-lwt
instance
This patch delete a duplicate code about happy-eyeballs implementations.
Related to robur-coop/happy-eyeballs#38