Add DNS-over-HTTPS resolution library (-sDOH_DNS)#2
Closed
Conversation
standalone DoH library that replaces emscripten's fake 172.29.x.x DNS with real lookups via fetch() to dns.google JSON API. features: - A and AAAA record resolution with TTL-based caching - HTTPS/SVCB record support (RFC 9460 type 65): ALPN hints (h2/h3), IP address hints (pre-seeds A/AAAA cache), port overrides - reverse lookup cache integrates with getnameinfo/gethostbyaddr - overrides both _emscripten_lookup_name and getaddrinfo for full coverage of all DNS code paths - proper IPv6 in getaddrinfo (AAAA queries instead of v4-mapped fakes) - graceful fallback to emscripten fake DNS if DoH fetch fails works with any networking backend (direct sockets, websocket proxy, etc). split out from direct sockets PR per sbc100 review feedback. usage: emcc -sDOH_DNS -sASYNCIFY app.c https://claude.ai/code/session_013tMRcS8HLZpNDZ4vLoNp7C
|
Why close this? |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Standalone DNS-over-HTTPS library that replaces Emscripten's static
172.29.x.xDNS with lookups viafetch()to dns.google's JSON API. Split out from the Direct Sockets PR (emscripten-core#26374 on emscripten-core) per @sbc100's review feedback._emscripten_lookup_name(used bygethostbyname) andgetaddrinfo(which callsDNS.lookup_namedirectly, not_emscripten_lookup_name)getaddrinfoinstead of wrapping fake IPv4 as v4-mapped IPv6DNS.address_mapsogetnameinfo/gethostbyaddrreturn real hostnamesWhy this exists
Emscripten's default DNS assigns IPs in the
172.29.0.0/16range and maintains a bidirectional map. This works for WebSocket-proxy networking where the proxy resolves DNS, but breaks for:172.29.x.xinstead of real IPs_emscripten_lookup_nameis IPv4-only;getaddrinfowithAF_INET6returns a v4-mapped fake addressfetch()external HTTPS endpoints but have no traditional DNS API; DoH via fetch is the natural solutionUsage
Works with any networking backend (Direct Sockets, WebSocket proxy, etc).
Files changed
src/lib/libdoh.js$DOH_DNSmodule +_emscripten_lookup_name+getaddrinfooverridessrc/settings.jsDOH_DNSbuild settingsrc/modules.mjslibdoh.jswhenDOH_DNSenabledtest/test_other.py-sDOH_DNS(validates fallback path)Test plan
test_getaddrinfo_dohpasses (fallback to fake DNS when DoH unavailable)test_getaddrinfostill passes (no regression)https://claude.ai/code/session_013tMRcS8HLZpNDZ4vLoNp7C