Commit Graph

166 Commits

Author SHA1 Message Date
Antoine du Hamel
231548b5cf
lib: enforce ASCII order in error code imports
PR-URL: https://github.com/nodejs/node/pull/52625
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2024-04-23 17:05:38 +00:00
Paolo Insogna
7e89369166
dns: add order option and support ipv6first
PR-URL: https://github.com/nodejs/node/pull/52492
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2024-04-17 15:24:28 +00:00
Aras Abbasi
83e6350b82
errors: improve hideStackFrames
PR-URL: https://github.com/nodejs/node/pull/49990
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2023-11-11 16:25:08 +00:00
Yagiz Nizipli
8b5cd3248d
dns: call ada::idna::to_ascii directly from c++
PR-URL: https://github.com/nodejs/node/pull/47920
Fixes: https://github.com/nodejs/performance/issues/77
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2023-05-10 16:04:35 +00:00
btea
2ac5e9889a
dns: expose getDefaultResultOrder
PR-URL: https://github.com/nodejs/node/pull/46973
Fixes: https://github.com/nodejs/node/issues/46919
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
2023-04-26 08:56:04 +00:00
Antoine du Hamel
9dbb1623ff
lib: add trailing commas to all public core modules
PR-URL: https://github.com/nodejs/node/pull/46848
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
2023-02-28 12:10:24 +01:00
Antoine du Hamel
fe514bf960
lib: enforce use of trailing commas for functions
PR-URL: https://github.com/nodejs/node/pull/46629
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
2023-02-14 18:45:16 +01:00
Yagiz Nizipli
572d55645c
dns: remove unnecessary parameter from validateOneOf
PR-URL: https://github.com/nodejs/node/pull/44635
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
2022-09-17 11:44:02 +00:00
Joyee Cheung
12fb94c78c
dns: refactor default resolver
This patch refactors the DNS default resolver code to make it
easier to be included in a snapshot:

- The code specific for the callback-based DNS resolver are not
  in a separate module to make the dependency clearer (it's not
  actually needed if the user only ever loads `dns/promises`)
- The common part of the callback-based resolver and the promise-
  based resolver is now ResolverBase. The other two user-facing
  resolvers are now subclasses of ResolverBase. The default
  Resolver is constructed with just ResolverBase. This would
  be fine as the default resolver is never actually exposed
  to the user-land and it has been working using duck-typing anyway.
- Move the construction of Resolver subclasses into a common
  method `createResolverClass()` to reduce code duplication.
  The two subclasses now also share the same base constructor.
  This would make it possible for them to also share code
  for snapshot support later.
- `--dns-result-order` is now queried and refreshed during
  pre-execution. To avoid loading the cares_wrap binding unnecessarily
  the loading of the binding is also made lazy.

PR-URL: https://github.com/nodejs/node/pull/44541
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2022-09-13 13:36:08 +00:00
theanarkh
60898eed65
lib: add diagnostics channel and perf hooks detail
PR-URL: https://github.com/nodejs/node/pull/43984
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2022-07-29 14:27:16 +01:00
Feng Yu
3847617f55
dns: make promise API fully constructed from lib/internal/dns/promises
PR-URL: https://github.com/nodejs/node/pull/43227
Refs: https://github.com/nodejs/node/discussions/43198
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2022-06-20 19:58:45 +01:00
Feng Yu
dc53c29b97
dns: export error code constants from dns/promises
PR-URL: https://github.com/nodejs/node/pull/43176
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-06-18 13:54:31 +01:00
Antoine du Hamel
70b516e4db dns: accept 'IPv4' and 'IPv6' for family
Refs: https://github.com/nodejs/node/issues/43014

PR-URL: https://github.com/nodejs/node/pull/43054
Fixes: https://github.com/nodejs/node/issues/43014
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2022-06-15 18:02:01 -04:00
theanarkh
85f8821f4d
net,dns: move hasObserver out of perf function
move the hasObserver out of startPerf and stopPerf
to avoid generating useless objects when these are no observer

PR-URL: https://github.com/nodejs/node/pull/43217
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2022-06-09 05:32:46 +01:00
Antoine du Hamel
06d8606960
lib: use null-prototype objects for property descriptors
Refs: https://github.com/nodejs/node/pull/42921

PR-URL: https://github.com/nodejs/node/pull/43270
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2022-06-03 09:23:58 +01:00
Antoine du Hamel
08773e3c04 dns: remove dns.lookup and dnsPromises.lookup options type coercion
PR-URL: https://github.com/nodejs/node/pull/41431
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2022-04-12 05:50:11 +02:00
theanarkh
e5200392a2
net,dns: trace tcp connection and dns by perf_hooks
use the perf_hooks to trace the time spent by net.connect, dns.lookup,
dns.lookupService, dns.resolvexxx.

PR-URL: https://github.com/nodejs/node/pull/42390
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
2022-03-29 16:43:28 +01:00
Mohammed Keyvanzadeh
8c4b8b201a
lib: replace validator and error
Refs: https://github.com/nodejs/node/pull/41660

PR-URL: https://github.com/nodejs/node/pull/41678
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-02-05 08:36:48 -08:00
Antoine du Hamel
f182b9b29f dns: runtime deprecate type coercion of dns.lookup options
PR-URL: https://github.com/nodejs/node/pull/39793
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2021-09-15 16:59:10 +00:00
Ouyang Yadong
d8797f5994 dns: allow --dns-result-order to change default dns verbatim
Allow the `--dns-result-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.

PR-URL: https://github.com/nodejs/node/pull/38099
Refs: https://github.com/nodejs/node/issues/31566
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2021-06-02 19:28:05 +02:00
ZiJian Liu
08dd4b1723
lib: refactor to use validateString
PR-URL: https://github.com/nodejs/node/pull/37006
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-01-22 19:56:34 -08:00
ZiJian Liu
b00bb01db9 lib: refactor to use validateCallback
PR-URL: https://github.com/nodejs/node/pull/36609
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2020-12-29 15:48:57 +00:00
Antoine du Hamel
96b4950dca dns: refactor to use more primordials
PR-URL: https://github.com/nodejs/node/pull/36314
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-12-07 19:40:52 +00:00
Danny Sonnenschein
6f34498148 net: add support for resolving DNS CAA records
This adds support for DNS Certification Authority Authorization
(RFC 8659) to Node.js.

PR-URL: https://github.com/nodejs/node/pull/35466
Fixes: https://github.com/nodejs/node/issues/19239
Refs: https://github.com/nodejs/node/issues/14713
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-10-16 10:21:32 +02:00
Denys Otrishko
c66e6471e7
lib: remove ERR_INVALID_OPT_VALUE and ERR_INVALID_OPT_VALUE_ENCODING
This will be a start to generalize all argument validation
errors. As currently we throw ARG/OPT, OUT_OF_RANGE, and other more
specific errors.
The OPT errors didn't bring much to the errors as it's just another
variant of ARG error which is sometimes more confusing (some of our code
used OPT errors to denote just argument validation errors presumably
because of similarity of OPT to 'option' and not 'options-object')
and they don't specify the name of the options object where the invalid
value is located. Much better approach would be to just specify path
to the invalid value in the name of the value as it is done in this PR
(i.e. 'options.format', 'options.publicKey.type' etc)

Also since this decreases a variety of errors we have it'd be easier to
reuse validation code across the codebase.

Refs: https://github.com/nodejs/node/pull/31251
Refs: https://github.com/nodejs/node/pull/34070#discussion_r467251009
Signed-off-by: Denys Otrishko <shishugi@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/34682
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-09-11 17:54:42 +03:00
Denys Otrishko
6726246dbb lib: allow to validate enums with validateOneOf
PR-URL: https://github.com/nodejs/node/pull/34070
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-08-17 11:50:46 -07:00
Luigi Pinca
b533fb3508 tools: enable no-else-return lint rule
Refs: https://github.com/nodejs/node/pull/32644
Refs: https://github.com/nodejs/node/pull/32662

PR-URL: https://github.com/nodejs/node/pull/32667
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2020-05-16 06:42:16 +02:00
rickyes
6779331831
dns: remove duplicate code
PR-URL: https://github.com/nodejs/node/pull/32664
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-04-07 20:35:07 +02:00
murgatroid99
18c3ff99aa
dns: add dns.ALL hints flag constant
PR-URL: https://github.com/nodejs/node/pull/32183
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-03-30 17:21:13 +02:00
James M Snell
b023d61716 lib: move isLegalPort to validators, refactor
isLegalPort was used multiple places in the same way -- to validate
the port and throw if necessary. Moved into internal/validators.

PR-URL: https://github.com/nodejs/node/pull/31851
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-03-05 11:52:53 -08:00
Michaël Zasso
0646eda4fc
lib: flatten access to primordials
Store all primordials as properties of the primordials object.
Static functions are prefixed by the constructor's name and prototype
methods are prefixed by the constructor's name followed by "Prototype".
For example: primordials.Object.keys becomes primordials.ObjectKeys.

PR-URL: https://github.com/nodejs/node/pull/30610
Refs: https://github.com/nodejs/node/issues/29766
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-11-25 10:28:15 +01:00
Dmitriy Kikinskiy
bbfa2e9cb1 dns: switch var to const/let
Simple exchange var to const/let.

PR-URL: https://github.com/nodejs/node/pull/30302
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2019-11-09 05:49:26 -08:00
cjihrig
df936c5925 dns: update lookupService() first arg name
The first argument to lookupService() should be an IP address,
and is named "address" in the documentation. This commit updates
the code to match the documentation and provide less confusing
errors.

PR-URL: https://github.com/nodejs/node/pull/29040
Fixes: https://github.com/nodejs/node/issues/29039
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-08-10 19:06:21 -07:00
Rich Trott
09cdc37824 dns: do not indicate invalid IPs are IPv6
In lib/dns.js, use `isIP()` instead of `isIPv4()` for determining the
`family` property in `lookup()`. If an invalid IP address is returned,
the `family` currently provided is `6`. With this change, it will be
`0`. Update documentation to reflect this.

PR-URL: https://github.com/nodejs/node/pull/27081
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-04-16 16:19:17 -07:00
Michaël Zasso
908292cf1f lib: enforce the use of Object from primordials
PR-URL: https://github.com/nodejs/node/pull/27146
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
2019-04-12 05:38:45 +02:00
Ruben Bridgewater
3b044962c4
errors: add more information in case of invalid callbacks
This adds the actual callback that is passed through to the error
message in case an ERR_INVALID_CALLBACK error is thrown.

PR-URL: https://github.com/nodejs/node/pull/27048
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
2019-04-04 12:51:03 +02:00
Ruben Bridgewater
f86f5736da
benchmark,lib: change var to const
Refs: https://github.com/nodejs/node/pull/26679

PR-URL: https://github.com/nodejs/node/pull/26915
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2019-03-30 13:16:39 +01:00
cjihrig
61e4d89098
dns: make dns.promises enumerable
PR-URL: https://github.com/nodejs/node/pull/26592
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2019-03-29 18:57:09 -04:00
cjihrig
aa2ac1981a
dns: remove dns.promises experimental warning
PR-URL: https://github.com/nodejs/node/pull/26592
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2019-03-29 18:57:04 -04:00
Ben Noordhuis
f399b01dc4
dns: use IDNA 2008 to encode non-ascii hostnames
Before this commit, Node.js left it up to the system resolver or c-ares.

Leaving it to the system resolver introduces platform differences
because:

* some support IDNA 2008
* some only IDNA 2003 (glibc until 2.28), and
* some don't support IDNA at all (musl libc)

c-ares doesn't support IDNA either although curl does, by virtue of
linking against libidn2. Upgrading from libidn1 to libidn2 in order
to get proper IDNA 2008 support was the fix for curl's CVE-2016-8625.

libidn2 is not an option (incompatible license) but ICU has an IDNA API
and we already use that in one place. For non-ICU builds, we fall back
to the bundled punycode.js that also supports IDNA 2008.

Fixes: https://github.com/nodejs-private/security/issues/97
Fixes: https://github.com/nodejs/node/issues/25558

PR-URL: https://github.com/nodejs/node/pull/25679
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
2019-01-28 20:42:44 +01:00
cjihrig
54f8453ea1 dns: simplify dns.promises warning logic
dns.promises is lazy loaded. Instead of using a seaparate
Boolean flag to track whether or not it has been loaded, just
inspect the state of the lazy loaded module itself.

PR-URL: https://github.com/nodejs/node/pull/24788
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Masashi Hirano <shisama07@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2018-12-04 11:32:45 -08:00
Ulises Gascón
beb0f03e78 dns: fix inconsistent (hostname vs host)
Fixes: https://github.com/nodejs/node/issues/20892
PR-URL: https://github.com/nodejs/node/pull/23572
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-10-20 21:56:28 -07:00
Ouyang Yadong
26af728994
dns: deprecate passing falsy hostname to dns.lookup
We can `dns.lookup` a falsy `hostname` like `dns.lookup(false)`
for the reason of backwards compatibility long before(see #13119
for detail). This behavior is undocumented and seems useless in
real world apps.

We could also make invalid `hostname` throw in the future and the
change might be semver-major.

Fixes: https://github.com/nodejs/node/issues/13119

PR-URL: https://github.com/nodejs/node/pull/23173
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-10-04 14:51:02 -07:00
Gus Caplan
e7f710c1d4 bootstrapper: move internalBinding to NativeModule
internalBinding is used so often that it should just automatically be
available for usage in internals.

PR-URL: https://github.com/nodejs/node/pull/23025
Refs: https://github.com/nodejs/node/commit/2a9eb31
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-10-04 11:55:34 +02:00
cjihrig
8b0c482647
dns: make process.binding('cares_wrap') internal
PR-URL: https://github.com/nodejs/node/pull/22474
Refs: https://github.com/nodejs/node/issues/22160
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-08-30 09:08:44 -04:00
Jon Moss
e570ae79f5 lib: extract validateString validator
Pulls out a common argument validator to `internal/validators`

PR-URL: https://github.com/nodejs/node/pull/22101
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-08-07 10:51:27 -04:00
cjihrig
7486c4d710
dns: add promisified dns module
PR-URL: https://github.com/nodejs/node/pull/21264
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2018-06-20 13:35:27 -04:00
Jamie Davis
872c331a93 dns: improve setServers() errors and performance
Issue 1: make invalid setServers yield uniform error

Behavior:
dns.setServers throws a null pointer dereference on some inputs.
Expected behavior was the more pleasant
  TypeError [ERR_INVALID_IP_ADDRESS] ...

Root cause(s?):
- Dereferencing the result of a regex match without confirming
  that there was a match.
- assuming the capture of an optional group (?)

Solution:
Confirm the match, and handle a missing port cleanly.

Tests: I added tests for various unusual inputs.

Issue 2: revise quadratic regex in setServers

Problem:
The IPv6 regex was quadratic.
On long malicious input the event loop could block.

The security team did not deem it a security risk,
but said a PR was welcome.

Solution:
Revise the regex to a linear-complexity version.

Tests:
I added REDOS tests to the "oddities" section.

Fixes: https://github.com/nodejs/node/issues/20441
Fixes: https://github.com/nodejs/node/issues/20443

PR-URL: https://github.com/nodejs/node/pull/20445
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-06-08 21:35:32 -07:00
davidmarkclements
2119ceedbf errors: alter ERR_INVALID_IP_ADDRESS
changes the base instance for ERR_INVALID_IP_ADDRESS
from Error to TypeError as a more accurate representation
of the error.

PR-URL: https://github.com/nodejs/node/pull/19979
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-04-14 10:55:35 -07:00
Ruben Bridgewater
b29c36b807
errors: make dns errors consistent
Right now the hostname could in some cases be missed, depending on
the libuv error number. This makes sure there the hostname is always
added, if available.

PR-URL: https://github.com/nodejs/node/pull/19754
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-04-05 19:29:02 +02:00