-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
tls: accept lookup
option for tls.connect()
#12839
Changes from 3 commits
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 |
---|---|---|
|
@@ -752,6 +752,9 @@ decrease overall server throughput. | |
<!-- YAML | ||
added: v0.11.3 | ||
changes: | ||
- version: REPLACEME | ||
pr-url: https://github.com/nodejs/node/pull/12839 | ||
description: The `lookup` option is supported now. | ||
- version: REPLACEME | ||
pr-url: https://github.com/nodejs/node/pull/11984 | ||
description: The `ALPNProtocols` and `NPNProtocols` options can | ||
|
@@ -809,6 +812,7 @@ changes: | |
`tls.createSecureContext()`. *Note*: In effect, all | ||
[`tls.createSecureContext()`][] options can be provided, but they will be | ||
_completely ignored_ unless the `secureContext` option is missing. | ||
* `lookup`: {Function} Custom lookup function. Defaults to [`dns.lookup()`][]. | ||
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.
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. Good point, fixed! Thanks. |
||
* ...: Optional [`tls.createSecureContext()`][] options can be provided, see | ||
the `secureContext` option for more information. | ||
* `callback` {Function} | ||
|
@@ -1291,3 +1295,4 @@ where `secure_socket` has the same API as `pair.cleartext`. | |
[modifying the default cipher suite]: #tls_modifying_the_default_tls_cipher_suite | ||
[specific attacks affecting larger AES key sizes]: https://www.schneier.com/blog/archives/2009/07/another_new_aes.html | ||
[tls.Server]: #tls_class_tls_server | ||
[`dns.lookup`]: dns.html#dns_dns_lookup_hostname_options_callback | ||
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 have been 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. Ack. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const tls = require('tls'); | ||
|
||
const expectedError = /^TypeError: "lookup" option should be a function$/; | ||
|
||
['foobar', 1, {}, []].forEach(function connectThrows(input) { | ||
const opts = { | ||
host: 'localhost', | ||
port: common.PORT, | ||
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. There is an ongoing effort to avoid the usage of 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 is a copy-paste of a similar |
||
lookup: input | ||
}; | ||
|
||
assert.throws(function() { | ||
tls.connect(opts); | ||
}, expectedError); | ||
}); | ||
|
||
connectDoesNotThrow(common.mustCall(() => {})); | ||
|
||
function connectDoesNotThrow(input) { | ||
const opts = { | ||
host: 'localhost', | ||
port: common.PORT, | ||
lookup: input | ||
}; | ||
|
||
assert.doesNotThrow(function() { | ||
tls.connect(opts); | ||
}); | ||
} |
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.
nit:
s/Custom/Optional/
, for consistency with above.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.
Should I change
net.md
as well? This is a copy-paste from it.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.
Style varies between different files in node. Here, I was looking at the next property up "Optional TLS context..." and thought this function should be internally consistent, but I opened the diff further, there is no consistency, so just leave the current wording as is (or change it if you want). But net is (hopefully) consistent already in how it docs its properties.