From b7dd9e58b9a2f47798a77abcac491a51a11e8d6a Mon Sep 17 00:00:00 2001 From: Ouyang Yadong Date: Tue, 6 Apr 2021 16:09:11 +0800 Subject: [PATCH] dns: allow --dns-order to change default dns verbatim Allow the "--dns-order" 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 | 7 +++ src/node_options.h | 1 + .../test-dns-default-verbatim-false.js | 57 +++++++++++++++++++ .../test-dns-default-verbatim-true.js | 57 +++++++++++++++++++ 8 files changed, 167 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..4c4e16b67706a9 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-order=value` + + +Set the default value of `verbatim` in [`dns.lookup()`][]. The value could be: +* `ipv4`: Set default `verbatim` `false`. +* `verbatim`: Set default `verbatim` `true`. + +Otherwise, default `verbatim` will be decided by Node.js. + ### `--enable-fips`