Skip to main content

DNS_OVERRIDE

Constant DNS_OVERRIDE 

Source
const DNS_OVERRIDE: &str = "\"use strict\";\n// Redirect ALL Node.js DNS resolution to the embedded Hickory server\nconst dns = require(\"dns\");\nconst { Resolver } = dns;\n\nconst [host, portStr] = (process.env.LAND_DNS_SERVER || \"127.0.0.1:5380\").split(\n\t\":\",\n);\nconst servers = [`${host}:${portStr}`];\n\ndns.setServers(servers); // affects net.lookup global path\ndns.promises.setDefaultResultOrder(\"ipv4first\");\n\n// Also override the node:dns/promises Resolver class default\nconst r = new Resolver();\nr.setServers(servers);\n\n// Patch dns.lookup so http/https native modules use Hickory too\nconst origLookup = dns.lookup.bind(dns);\ndns.lookup = (hostname, options, cb) => {\n\tconst callback = typeof options === \"function\" ? options : cb;\n\tconst opts = typeof options === \"object\" ? options : {};\n\t// .editor.land always force-resolves via Hickory (already configured above)\n\torigLookup(hostname, { ...opts, verbatim: true }, callback);\n};\n";