From 17bf60aed9e518904c601d3fb72365faa7086e59 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 15 Aug 2023 10:20:06 +0000 Subject: [PATCH] feat: support dns-result-order Node.js cli flag Co-authored-by: deepak1556 --- docs/api/command-line-switches.md | 9 ++ patches/node/.patches | 1 + .../dns_expose_getdefaultresultorder.patch | 141 ++++++++++++++++++ shell/common/node_bindings.cc | 10 +- spec/api-utility-process-spec.ts | 24 +++ .../api/utility-process/dns-result-order.js | 3 + 6 files changed, 185 insertions(+), 3 deletions(-) create mode 100644 patches/node/dns_expose_getdefaultresultorder.patch create mode 100644 spec/fixtures/api/utility-process/dns-result-order.js diff --git a/docs/api/command-line-switches.md b/docs/api/command-line-switches.md index ee5e746420c25..fd63da4f1cbe6 100644 --- a/docs/api/command-line-switches.md +++ b/docs/api/command-line-switches.md @@ -291,6 +291,15 @@ Print stack traces for deprecations. Print stack traces for process warnings (including deprecations). +### `--dns-result-order=order` + +Set the default value of the `verbatim` parameter in the Node.js [`dns.lookup()`](https://nodejs.org/api/dns.html#dnslookuphostname-options-callback) and [`dnsPromises.lookup()`](https://nodejs.org/api/dns.html#dnspromiseslookuphostname-options) functions. The value could be: + +* `ipv4first`: sets default `verbatim` `false`. +* `verbatim`: sets default `verbatim` `true`. + +The default is `verbatim` and `dns.setDefaultResultOrder()` have higher priority than `--dns-result-order`. + [app]: app.md [append-switch]: command-line.md#commandlineappendswitchswitch-value [debugging-main-process]: ../tutorial/debugging-main-process.md diff --git a/patches/node/.patches b/patches/node/.patches index 789ac0e5f9db3..ad5c4f8bba703 100644 --- a/patches/node/.patches +++ b/patches/node/.patches @@ -37,3 +37,4 @@ chore_remove_--no-harmony-atomics_related_code.patch fix_account_for_createexternalizablestring_v8_global.patch fix_wunreachable-code_warning_in_ares_init_rand_engine.patch fix_do_not_resolve_electron_entrypoints.patch +dns_expose_getdefaultresultorder.patch diff --git a/patches/node/dns_expose_getdefaultresultorder.patch b/patches/node/dns_expose_getdefaultresultorder.patch new file mode 100644 index 0000000000000..b1866ad37a58a --- /dev/null +++ b/patches/node/dns_expose_getdefaultresultorder.patch @@ -0,0 +1,141 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: btea <2356281422@qq.com> +Date: Wed, 26 Apr 2023 16:56:04 +0800 +Subject: dns: expose getDefaultResultOrder + +PR-URL: https://github.com/nodejs/node/pull/46973 +Fixes: https://github.com/nodejs/node/issues/46919 +Reviewed-By: Matteo Collina +Reviewed-By: Paolo Insogna + +diff --git a/doc/api/dns.md b/doc/api/dns.md +index 59a56c7d1c2aa87b4786c5b6397978b195af1f83..2bb997bb0a2b4ebdbb9ae5625762e8c3184ace8d 100644 +--- a/doc/api/dns.md ++++ b/doc/api/dns.md +@@ -792,6 +792,18 @@ priority than [`--dns-result-order`][]. When using [worker threads][], + [`dns.setDefaultResultOrder()`][] from the main thread won't affect the default + dns orders in workers. + ++## `dns.getDefaultResultOrder()` ++ ++ ++ ++Get the default value for `verbatim` in [`dns.lookup()`][] and ++[`dnsPromises.lookup()`][]. The value could be: ++ ++* `ipv4first`: for `verbatim` defaulting to `false`. ++* `verbatim`: for `verbatim` defaulting to `true`. ++ + ## `dns.setServers(servers)` + + ++ ++Get the value of `dnsOrder`. ++ + ### `dnsPromises.setServers(servers)` + +