Remix.run Logo
nly 3 days ago

If you want DNS resolution to obey user/system preferences then you need to use the system provided API

rwmj 3 days ago | parent | next [-]

For sure! The only problem is there should be a non-blocking system-provided API and there isn't.

foota 3 days ago | parent [-]

System provided is maybe a strange word to use here since getaddrinfo is a libc function, not a system call.

rwmj 3 days ago | parent | next [-]

POSIX as the system, of course.

froh 3 days ago | parent | prev [-]

the system API is not syscalls but libc. so why does it feel strange?

tremon 3 days ago | parent | prev | next [-]

The system-provided API for getting DNS user/system preferences on Unix systems is to read /etc/resolv.conf. Every application is free to implement their own lookup from that.

Spivak 3 days ago | parent | next [-]

This isn't even correct on Linux as it won't work if your user has anything other than or in addition to the dns module in their nsswitch.conf. You must use glibc's resolution on Linux for correct behavior. If it's software on your own systems then do what you want but you'll piss off some sysadmins deploying your software if you don't. Even Go farms out to cgo to resolve names if it detects modules it doesn't recognize.

dcrazy 3 days ago | parent | prev [-]

That is absolutely not the API on macOS, which is a certified UNIX.

Seattle3503 3 days ago | parent | prev [-]

In this case it isn't in the kernel, but in glibc. Could someone implement an equivalent alternative? Do any language runtimes re-implement DNS resolution?

NewJazz 3 days ago | parent | next [-]

I think most languages use the OS api by default, but there are plenty of libraries out there that bypass the system resolution.

bradfitz 3 days ago | parent | prev [-]

Go does. And it supports timeouts and cancelation.