dns: allow --dns-verbatim to change default dns verbatim
Allow the NODE_DNS_VERBATIM environment variable --dns-verbatim
--dns-order
option to change the default
value of verbatim
in dns.lookup()
.
Refs: #31566 (closed)
We already have #37931 and #20710 to change the default verbatim
in the future version
of Node.js. But I still want to submit this PR to see if we could accept using an
environment variable option to change the default value. As this is not a semver-major change,
it's also possible to backport it to Node.js v12 and v14.
This is useful when running Node.js in ipv6-only environments. When a domain
supports both ipv4 and ipv6, a http request to this domain would fail as it tries to
connect to the ipv4 address by default and thus emit an ENETUNREACH
error.
Although we could change the family
or add a customized lookup
for http requests
to make them succeed in ipv6-only environments, it's nearly impossible as we have to
change all the code in third-party packages to make them work as expected.
(Actually, this is the scenario that I have encountered.)