Commit 0f232e9
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: #44541
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>1 parent 2d87b6f commit 0f232e9Copy full SHA for 0f232e9
File tree
Expand file treeCollapse file tree
7 files changed
+191
-141
lines changedOpen diff view settings
Filter options
- lib
- internal
- dns
- main
- process
- test/parallel
Expand file treeCollapse file tree
7 files changed
+191
-141
lines changedOpen diff view settings
Collapse file
+4-93Lines changed: 4 additions & 93 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
22 | 22 | |
23 | 23 | |
24 | 24 | |
25 | | - |
26 | | - |
27 | 25 | |
28 | 26 | |
29 | | - |
30 | 27 | |
31 | 28 | |
32 | 29 | |
| ||
37 | 34 | |
38 | 35 | |
39 | 36 | |
40 | | - |
41 | 37 | |
42 | | - |
43 | 38 | |
44 | 39 | |
45 | 40 | |
46 | 41 | |
47 | 42 | |
48 | 43 | |
| 44 | + |
| 45 | + |
| 46 | + |
49 | 47 | |
50 | 48 | |
51 | 49 | |
| ||
89 | 87 | |
90 | 88 | |
91 | 89 | |
92 | | - |
93 | 90 | |
94 | 91 | |
95 | 92 | |
96 | 93 | |
97 | | - |
98 | 94 | |
99 | 95 | |
100 | 96 | |
| ||
293 | 289 | |
294 | 290 | |
295 | 291 | |
296 | | - |
297 | | - |
298 | | - |
299 | | - |
300 | | - |
301 | | - |
302 | | - |
303 | | - |
304 | | - |
305 | | - |
306 | | - |
307 | | - |
308 | | - |
309 | | - |
310 | | - |
311 | | - |
312 | | - |
313 | | - |
314 | | - |
315 | | - |
316 | | - |
317 | | - |
318 | | - |
319 | | - |
320 | | - |
321 | | - |
322 | | - |
323 | | - |
324 | | - |
325 | | - |
326 | | - |
327 | | - |
328 | | - |
329 | | - |
330 | | - |
331 | | - |
332 | | - |
333 | | - |
334 | | - |
335 | | - |
336 | | - |
337 | | - |
338 | | - |
339 | | - |
340 | | - |
341 | | - |
342 | | - |
343 | | - |
344 | | - |
345 | | - |
346 | | - |
347 | | - |
348 | | - |
349 | | - |
350 | | - |
351 | | - |
352 | | - |
353 | | - |
354 | | - |
355 | | - |
356 | | - |
357 | | - |
358 | | - |
359 | | - |
360 | | - |
361 | | - |
362 | | - |
363 | | - |
364 | | - |
365 | | - |
366 | | - |
367 | | - |
368 | | - |
369 | | - |
370 | | - |
371 | | - |
372 | | - |
373 | | - |
374 | | - |
375 | | - |
376 | | - |
377 | | - |
378 | | - |
379 | | - |
380 | | - |
381 | 292 | |
382 | 293 | |
383 | 294 | |
| ||
429 | 340 | |
430 | 341 | |
431 | 342 | |
432 | | - |
| 343 | + |
433 | 344 | |
434 | 345 | |
435 | 346 | |
|
Collapse file
lib/internal/dns/callback_resolver.js
Copy file name to clipboard+116Lines changed: 116 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | + |
Collapse file
lib/internal/dns/promises.js
Copy file name to clipboardExpand all lines: lib/internal/dns/promises.js+8-36Lines changed: 8 additions & 36 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1 | 1 | |
2 | 2 | |
3 | 3 | |
4 | | - |
5 | 4 | |
6 | 5 | |
7 | 6 | |
| ||
10 | 9 | |
11 | 10 | |
12 | 11 | |
13 | | - |
| 12 | + |
14 | 13 | |
15 | | - |
16 | | - |
17 | 14 | |
18 | 15 | |
19 | 16 | |
20 | 17 | |
21 | 18 | |
22 | 19 | |
| 20 | + |
23 | 21 | |
24 | 22 | |
25 | 23 | |
| ||
52 | 50 | |
53 | 51 | |
54 | 52 | |
55 | | - |
56 | 53 | |
57 | 54 | |
58 | 55 | |
| ||
305 | 302 | |
306 | 303 | |
307 | 304 | |
308 | | - |
309 | | - |
310 | | - |
311 | | - |
312 | | - |
313 | | - |
314 | | - |
315 | | - |
316 | | - |
317 | | - |
318 | | - |
319 | | - |
320 | | - |
321 | | - |
322 | | - |
323 | | - |
324 | | - |
325 | | - |
326 | | - |
327 | | - |
328 | | - |
329 | | - |
330 | | - |
331 | | - |
332 | | - |
333 | | - |
334 | | - |
335 | | - |
336 | | - |
337 | | - |
| 305 | + |
338 | 306 | |
339 | 307 | |
340 | 308 | |
| ||
349 | 317 | |
350 | 318 | |
351 | 319 | |
352 | | - |
| 320 | + |
| 321 | + |
| 322 | + |
| 323 | + |
| 324 | + |
353 | 325 | |
354 | 326 | |
355 | 327 | |
|
0 commit comments