Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/api/tls.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ Construct a new TLSSocket object from existing TCP socket.
- `secureContext`: An optional TLS context object from
[`tls.createSecureContext()`][]

- `lookup`: {Function} Custom lookup function. Defaults to [`dns.lookup()`][].

- `isServer`: If `true` the TLS socket will be instantiated in server-mode.
Default: `false`

Expand Down Expand Up @@ -1065,6 +1067,7 @@ console.log(ciphers); // ['AES128-SHA', 'AES256-SHA', ...]
[Stream]: stream.html#stream_stream
[SSL_METHODS]: https://www.openssl.org/docs/ssl/ssl.html#DEALING-WITH-PROTOCOL-METHODS
[tls.Server]: #tls_class_tls_server
[`dns.lookup()`]: dns.html#dns_dns_lookup_hostname_options_callback
[SSL_CTX_set_timeout]: https://www.openssl.org/docs/ssl/SSL_CTX_set_timeout.html
[RFC 4492]: https://www.rfc-editor.org/rfc/rfc4492.txt
[Forward secrecy]: https://en.wikipedia.org/wiki/Perfect_forward_secrecy
Expand Down
3 changes: 2 additions & 1 deletion lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,8 @@ exports.connect = function(/* [port, host], options, cb */) {
port: options.port,
host: options.host,
family: options.family,
localAddress: options.localAddress
localAddress: options.localAddress,
lookup: options.lookup
};
}
socket.connect(connect_opt, function() {
Expand Down
32 changes: 32 additions & 0 deletions test/parallel/test-tls-lookup.js
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: options.lookup should be a function.$/;

['foobar', 1, {}, []].forEach(function connectThrows(input) {
const opts = {
host: 'localhost',
port: common.PORT,
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);
});
}