nix
nix copied to clipboard
Add `getaddrinfo` from POSIX <netdb.h>
I found myself implementing this and felt I should make a PR.
Most of the doc comments are quotes from the posix documentation.
I am uncertain how the remaining AddrInfo fields should be converted to stronger types so I just left comments.
I also added the name info bit flags struct, but left it unused.
It seems I forgot to test with the current nix MSRV, as it compiles fine with cargo 1.67.0. I'll push a fix.
What advantages does this have over the existing DNS stuff in libstd, and in other crates?
What advantages does this have over the existing DNS stuff in libstd, and in other crates?
Ability to control the DNS resolution mechanism, i.e resolve to IPv4-mapped addresses on IPv6 networks. The standard to_sock_addrs() zeroes out the hints struct:
https://github.com/rust-lang/rust/blob/9337f7afa6fda07e60d6aa5ee88e692878446782/library/std/src/sys_common/net.rs#L210
What other crates do is probably the same but nix is already a collection of safe wrappers around POSIX APIs, so it would make sense to have a safe wrapper for getaddrinfo.