Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c3d8756

Browse filesBrowse files
AdamMajerruyadorno
authored andcommitted
net, dns: socket should handle its output as input
As a consequence of #43014 , server sockets and others, once connected, report string family names. But when feeding these to Socket.connect(), it passes these to host resolution with a string for family while a numeric family is expected internally. This results in wrong hints flags to be set and resolution to fail. As solution, is to add ability to handle both numeric and string family names when doing lookup and connect. Fixes: #44003 PR-URL: #44083 Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 46f8fb8 commit c3d8756
Copy full SHA for c3d8756

File tree

Expand file treeCollapse file tree

2 files changed

+11
-11
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-11
lines changed
Open diff view settings
Collapse file

‎lib/net.js‎

Copy file name to clipboardExpand all lines: lib/net.js
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,16 @@ Socket.prototype.connect = function(...args) {
10941094
return this;
10951095
};
10961096

1097+
function socketToDnsFamily(family) {
1098+
switch (family) {
1099+
case 'IPv4':
1100+
return 4;
1101+
case 'IPv6':
1102+
return 6;
1103+
}
1104+
1105+
return family;
1106+
}
10971107

10981108
function lookupAndConnect(self, options) {
10991109
const { localAddress, localPort } = options;
@@ -1136,7 +1146,7 @@ function lookupAndConnect(self, options) {
11361146

11371147
if (dns === undefined) dns = require('dns');
11381148
const dnsopts = {
1139-
family: options.family,
1149+
family: socketToDnsFamily(options.family),
11401150
hints: options.hints || 0
11411151
};
11421152

Collapse file

‎test/parallel/parallel.status‎

Copy file name to clipboardExpand all lines: test/parallel/parallel.status
-10Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ test-crypto-dh-stateless: SKIP
3737
test-crypto-keygen: SKIP
3838

3939
[$system==solaris] # Also applies to SmartOS
40-
# https://github.com/nodejs/node/pull/43054
41-
test-net-socket-connect-without-cb: SKIP
42-
test-net-socket-ready-without-cb: SKIP
43-
test-tcp-wrap-listen: SKIP
4440
# https://github.com/nodejs/node/issues/43446
4541
test-net-connect-reset-until-connected: PASS, FLAKY
4642
# https://github.com/nodejs/node/issues/43457
@@ -65,12 +61,6 @@ test-worker-message-port-message-before-close: PASS,FLAKY
6561
# https://github.com/nodejs/node/issues/43446
6662
test-net-connect-reset-until-connected: PASS, FLAKY
6763

68-
[$system==aix]
69-
# https://github.com/nodejs/node/pull/43054
70-
test-net-socket-connect-without-cb: SKIP
71-
test-net-socket-ready-without-cb: SKIP
72-
test-tcp-wrap-listen: SKIP
73-
7464
[$system==ibmi]
7565
# https://github.com/nodejs/node/pull/30819
7666
test-child-process-fork-net-server: SKIP

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.