-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dns: default to verbatim=true in dns.lookup() #37681
Changes from 24 commits
5bef0de
4be87a0
43d1492
beb6420
604366c
1bb0e55
16a1682
178683c
2b67c17
4b06383
6340f13
2f7edf0
75bd959
a19f8ec
0232a4a
2ef88c7
98b3ffb
7a0e447
5037efc
787dc69
26f7f45
269eda7
1928b44
5557b85
bccf676
0c8be88
7cae409
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,7 @@ server.listen(0, '127.0.0.1', common.mustCall(function() { | |
|
||
headers.forEach(function(h) { | ||
const req = http.get({ | ||
host: '127.0.0.1', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of doing this, I suggest changing line 52 to server.listen(0, common.hasIPv6 ? '::1' : '127.0.0.1', common.mustCall(function() { That way, we are still testing the default value. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is problematic because we don't know if
I think it's better to stick to pure IPv4 for now. |
||
port: port, | ||
headers: h | ||
}); | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -41,6 +41,7 @@ function test(size, err, next) { | |||||
const client = tls.connect({ | ||||||
minDHSize: 2048, | ||||||
port: this.address().port, | ||||||
host: '127.0.0.1', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can try this but I think it's safer to use hardcoded IPv4 because not specifying the host would mean it defaults to |
||||||
rejectUnauthorized: false | ||||||
}, function() { | ||||||
nsuccess++; | ||||||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -80,7 +80,7 @@ function reopenAfterClose(msg) { | |||
} | ||||
|
||||
function ping(port, callback) { | ||||
net.connect(port) | ||||
net.connect(port, '127.0.0.1') | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The inspector should "just work" with the default IMHO, the fact that it defaults to IPv4 goes a bit against that. I think it comes from here: Line 85 in f392ac0
Not that it has anything to do with this PR, I just wanted to point it out. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should, but it doesn't. On some systems it will listen on |
||||
.on('connect', function() { close(this); }) | ||||
.on('error', function(err) { close(this, err); }); | ||||
|
||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,7 +3,7 @@ const common = require('../common'); | |||||
const net = require('net'); | ||||||
const assert = require('assert'); | ||||||
|
||||||
const c = net.createConnection(common.PORT); | ||||||
const c = net.createConnection(common.PORT, common.localhostIPv4); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Shouldn't you instead change the assertion line 13: assert.strictEqual(e.address, common.hasIPv6 ? '::1' : '127.0.0.1'); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, because we can't predict to which IP address
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And also remove |
||||||
|
||||||
c.on('connect', common.mustNotCall()); | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -8,16 +8,19 @@ const net = require('net'); | |||
const expectedErrorCodes = ['ECONNREFUSED', 'EADDRINUSE']; | ||||
|
||||
const optionsIPv4 = { | ||||
host: common.localhostIPv4, | ||||
port: common.PORT, | ||||
localPort: common.PORT + 1, | ||||
localAddress: common.localhostIPv4 | ||||
localAddress: common.localhostIPv4, | ||||
family: 4, | ||||
}; | ||||
|
||||
const optionsIPv6 = { | ||||
host: '::1', | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't remove it. I feel this might break stuff. |
||||
port: common.PORT + 2, | ||||
localPort: common.PORT + 3, | ||||
localAddress: '::1', | ||||
family: 6, | ||||
}; | ||||
|
||||
function onError(err, options) { | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of doing this, I suggest changing line 62 to
That way, we are still testing the default value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that works. Or we have to change the connect-line as follows as well:
client = net.connect(address.port, common.hasIPv6 ? '::1' : '127.0.0.1', function() {
Otherwise it will listen on
::1
on an IPv6-enabled system, but will try to connect to127.0.0.1
and will fail withECONNREFUSED
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum that's not what I see on my machine… It tries to connect to
::1
as expected.If you don't specify a host in
net.connect
, it will uselocalhost
, which always resolves to127.0.0.1
withverbatim
set tofalse
(that's the current test). Withverbatim
set totrue
, it will resolve to::1
on IPv6 enabled system, and to127.0.0.1
otherwise.Anyway, I don't feel strongly about this, if you think it's simpler let's keep IPv4 for this test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It did almost everywhere. But on SmartOS it would still resolve to
127.0.0.1
, probably because::1 localhost
is not set in/etc/hosts
. I seem to remember that it also resolved to127.0.0.1
on my machine until I set that line in/etc/hosts
. This wasn't a problem because the Linux kernel always adds127.0.0.1
to thelo
-interface, so even on an otherwise IPv6-only system it would still have that127.0.0.1
address available and most software will not only listen on::1
but also127.0.0.1
. Until we can be sure that every system will also have::1 localhost
I think the safe solution is to hardcode the address here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One could argue that the safe thing to do is to keep
verbatim
tofalse
… If it's not easy to fix our CI machines, I don't think we can expect our users to fix their machines when updating Node.js.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sure if we add
::1 localhost
to/etc/hosts/
will solve this. Unfortunately I don't have access to SmartOS to examine this. As mentioned already, IPv6 is here to stay and should be accounted for. Having systems with faulty IPv6 will fail eventually. This is a bit ideologic, though, I have to admit. But landing this in the next LTS would give people both the time and the incentive to fix some fundamental issues. Otherwise people that need IPv6 will suffer. Unless we rewrite a lot of the logic, to catch all all cases, and/or implement dualstack listeners (forlocalhost
at least) this could cause some tiny problems. And those will only affectlocalhost
.