From 7f54be100d7e1b40ff7297d86fbf142db5462da9 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 | 7 ++- lib/internal/dns/promises.js | 8 ++- lib/internal/dns/utils.js | 22 +++++++ src/node_options.cc | 5 ++ src/node_options.h | 1 + .../test-dns-default-verbatim-false.js | 57 +++++++++++++++++++ .../test-dns-default-verbatim-true.js | 57 +++++++++++++++++++ 8 files changed, 165 insertions(+), 5 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`