Skip to content

Instantly share code, notes, and snippets.

View jetsanix's full-sized avatar
💭
💭💭💭

jet tsang zeon-git jetsanix

💭
💭💭💭
View GitHub Profile
@jetsanix
jetsanix / doh.js
Created August 11, 2025 20:40
A DNS-over-HTTPS (DoH) reverse proxy, with special handling for Ethereum (.eth) and Solana (.sol) domains for NGINX
/*
* NJS script to implement a DNS‑over‑HTTPS (DoH) reverse proxy with
* special handling for Ethereum (.eth) and Solana (.sol) domains.
*
* When a request hits `/dns‑query` the `handle()` function determines
* the queried name and record type. Standard RFC 8484 GET requests
* include a `?dns=` parameter containing a Base64Url encoded DNS
* message, while the JSON API uses `?name=` and `?type=` parameters
* for textual queries. POST requests carry a raw DNS message with
* `Content‑Type: application/dns‑message`【742873960042857†L96-L108】. The