From 94b441331742ca50860f2a6986ce567701dd45e7 Mon Sep 17 00:00:00 2001 From: Ouyang Yadong Date: Tue, 6 Apr 2021 16:09:11 +0800 Subject: [PATCH] dns: allow --dns-verbatim to change default dns verbatim Allow the "--dns-verbatim" option to change the default value of verbatim in `dns.lookup()`. This is useful when running Node.js in ipv6-only environments to avoid possible ENETUNREACH errors. --- doc/api/cli.md | 13 ++++++++ lib/dns.js | 3 +- lib/internal/dns/promises.js | 4 +-- lib/internal/dns/utils.js | 22 +++++++++++++ src/node_options.cc | 5 +++ src/node_options.h | 1 + .../test-dns-default-verbatim-false.js | 32 +++++++++++++++++++ .../test-dns-default-verbatim-true.js | 32 +++++++++++++++++++ 8 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 test/parallel/test-dns-default-verbatim-false.js create mode 100644 test/parallel/test-dns-default-verbatim-true.js diff --git a/doc/api/cli.md b/doc/api/cli.md index 055eac22f6f0a2..59a052c60054b2 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -181,6 +181,17 @@ Make built-in language features like `eval` and `new Function` that generate code from strings throw an exception instead. This does not affect the Node.js `vm` module. +### `--dns-verbatim=value` + + +Set the default value of `verbatim` in [`dns.lookup()`][]. The value may be: +* `0` to indicate `false` +* `1` to indicate `true` + +Other values will be ignored. + ### `--enable-fips`