Skip to content
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

win: use WinDNS family of functions for DNS resolving #4388

Open
nikneym opened this issue Apr 12, 2024 · 4 comments
Open

win: use WinDNS family of functions for DNS resolving #4388

nikneym opened this issue Apr 12, 2024 · 4 comments

Comments

@nikneym
Copy link

nikneym commented Apr 12, 2024

Currently GetAddrInfoW is used for DNS queries on Windows. WinDNS functions seems superior to getaddrinfo and it's counterparts. We have:

  • DnsQuery_A (for ANSI encoding)
  • DnsQuery_W (for Unicode encoding)
  • DnsQuery_UTF8 (for UTF-8 encoding)

and DnsQueryEx which does an asynchronous procedure call so it eliminates the need for thread pool (also supports wide characters).

@bnoordhuis
Copy link
Member

WinDNS functions seems superior to getaddrinfo

Superior how?

DnsQueryEx which does an asynchronous procedure call so it eliminates the need for thread pool

DnsQueryEx is only available on Windows 8 so would have to be feature-tested at runtime. It would also be good to double-check if it's really asynchronous and not just using the Windows thread pool.

Replacing GetAddrInfoW with DnsQuery_W doesn't seem compelling on its own but DnsQueryEx might be a good reason to switch. It should be 100% backwards compatible though.

@vtjnash
Copy link
Member

vtjnash commented Apr 13, 2024

We dropped support for windows 8 when Microsoft ended support

@nikneym
Copy link
Author

nikneym commented Apr 13, 2024

Superior how?

DnsQueryEx supports cancellation, already asynchronous through APC and it also returns TTL value (I'm not sure if GetAddrInfoW reports TTL too, though). Other than this variant, they're pretty similar I think.

I've also tried GetAddrInfoExW, though it takes OVERLAPPED, it returns nonzero when the aforementioned argument is given.

I actually want to take part in implementing it, I thought this might be a good first issue as well.

@vtjnash
Copy link
Member

vtjnash commented Apr 13, 2024

The GetAddrInfoExW looks better, since it is in the existing ws2_32 library and seems to support passing an Event object via OVERLAPPED (which can be used with IOCP directly)

mohitpal2621 added a commit to mohitpal2621/libuv that referenced this issue May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants