Open yorickpeterse opened 1 month ago
For the initial setup I think we should just go with using getaddrinfo()
. This works across all Unix platforms (including macOS), and is easier to implement compared to a pure-Inko DNS stack. At some point in the future we could add a pure Inko resolver, and only use it on e.g. Linux and FreeBSD.
Note to self: reverse DNS is done using getnameinfo()
.
A sketch of using getaddrinfo
, without handling it blocking the OS thread:
getaddrinfo
has apparently no way to specify a timeout/deadline for the DNS operation, meaning it can (in theory) hand indefinitely. This can lead to outages such as the one described at https://www.uber.com/en-NL/blog/denial-by-dns/.
Given the hairy nature of getaddrinfo()
, I'm leaning more towards a pure-Inko DNS client. This means it won't support everything out of the box (e.g. mDNS might be tricky), but it might be good enough for common cases, and wouldn't suffer from the same issues as getaddrinfo()
. We'd still need a way to fetch the name servers though, which at least on macOS isn't trivial.
For Linux and FreeBSD, parsing resolv.conf
is easy enough. For macOS we could probably do something like https://gist.github.com/leiless/5dddcdfbb1d578bd96c44ff727b2cc05, assuming that code is legit.
Given the complexity this likely brings, I'll un-assign this from the 0.16.0 milestone for the time being.
Description
Inko's standard library should provide a
std.net.dns
module, which in turn provides types/methods for looking up DNS names and resolving them to IP addresses. Ideally we'd do so without using libc, by instead parsing/etc/resolv.conf
ourselves and querying the DNS servers through the standard library. For macOS some special care is likely needed as it doesn't useresolv.conf
(or at least considers it obsolete). What exactly is needed here I'm not yet sure of.Related issues
gethostbyname()
& friends are blocking callsRelated work