-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the Miou implementation of happy-eyeballs
- Loading branch information
Showing
7 changed files
with
612 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
let reporter ppf = | ||
let report src level ~over k msgf = | ||
let k _ = | ||
over () ; | ||
k () in | ||
let with_metadata header _tags k ppf fmt = | ||
Format.kfprintf k ppf | ||
("%a[%a][%a]: " ^^ fmt ^^ "\n%!") | ||
Logs_fmt.pp_header (level, header) | ||
Fmt.(styled `Cyan int) (Stdlib.Domain.self () :> int) | ||
Fmt.(styled `Magenta string) | ||
(Logs.Src.name src) in | ||
msgf @@ fun ?header ?tags fmt -> with_metadata header tags k ppf fmt in | ||
{ Logs.report } | ||
|
||
let () = Fmt_tty.setup_std_outputs ~style_renderer:`Ansi_tty ~utf_8:true () | ||
let () = Logs.set_reporter (reporter Fmt.stdout) | ||
let () = Logs.set_level ~all:true (Some Logs.Debug) | ||
let () = Logs_threaded.enable () | ||
|
||
let () = Miou_unix.run @@ fun () -> | ||
let daemon, t = Happy_eyeballs_miou_unix.create () in | ||
for _ = 0 to 5 do | ||
match Happy_eyeballs_miou_unix.connect t Sys.argv.(1) [ 80 ] with | ||
| Ok ((ipaddr, port), fd) -> | ||
Logs.info (fun m -> m "Connected to %a:%d" Ipaddr.pp ipaddr port); | ||
Miou_unix.close fd | ||
| Error (`Msg err) -> | ||
Logs.err (fun m -> m "%s" err) | ||
done; | ||
Happy_eyeballs_miou_unix.kill daemon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
opam-version: "2.0" | ||
maintainer: "Robur <[email protected]>" | ||
authors: ["Robur <[email protected]>"] | ||
homepage: "https://github.com/robur-coop/miou-toolkit" | ||
dev-repo: "git+https://github.com/robur-coop/miou-toolkit.git" | ||
bug-reports: "https://github.com/robur-coop/miou-toolkit/issues" | ||
doc: "https://robur-coop.github.io/miou-toolkit/" | ||
license: "ISC" | ||
|
||
depends: [ | ||
"ocaml" {>= "5.0.0"} | ||
"dune" {>= "2.0.0"} | ||
"happy-eyeballs" {= version} | ||
"miou" {>= "0.2.0"} | ||
"mtime" {>= "2.0.0"} | ||
"duration" | ||
"domain-name" | ||
"ipaddr" | ||
"fmt" | ||
"logs" | ||
] | ||
build: [ | ||
["dune" "subst"] {dev} | ||
["dune" "build" "-p" name "-j" jobs] | ||
] | ||
|
||
synopsis: "Connecting to a remote host via IP version 4 or 6 using Miou" | ||
description: """ | ||
Happy eyeballs is an implementation of RFC 8305 which specifies how to connect | ||
to a remote host using either IP protocol version 4 or IP protocol version 6. | ||
This uses Miou for side effects. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(library | ||
(name happy_eyeballs_miou_unix) | ||
(modules happy_eyeballs_miou_unix) | ||
(public_name happy-eyeballs-miou-unix) | ||
(libraries | ||
miou.unix | ||
mtime.clock.os | ||
ipaddr.unix | ||
happy-eyeballs)) |
Oops, something went wrong.