Skip to content

tls: accept lookup option for tls.connect() - #12839

Closed
indutny wants to merge 4 commits into
nodejs:masterfrom
indutny:feature/tls-lookup
Closed

indutny wants to merge 4 commits into
nodejs:masterfrom
indutny:feature/tls-lookup

Conversation

@indutny

@indutny indutny commented May 4, 2017

Copy link
Copy Markdown
Member

net.connect() and consequently http.Agent support custom DNS
lookup option. However, as we move to https.Agent - this option no
longer works because it is not proxied by tls.connect.

Fix this inconsistency by passing it down to net.connect.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

tls

`net.connect()` and consequently `http.Agent` support custom DNS
`lookup` option. However, as we move to `https.Agent` - this option no
longer works because it is not proxied by `tls.connect`.

Fix this inconsistency by passing it down to `net.connect`.
@indutny indutny added the tls Issues and PRs related to the tls subsystem. label May 4, 2017
@nodejs-github-bot nodejs-github-bot added the tls Issues and PRs related to the tls subsystem. label May 4, 2017
@indutny

indutny commented May 4, 2017

Copy link
Copy Markdown
Member Author

cc @nodejs/collaborators

@indutny

indutny commented May 4, 2017

Copy link
Copy Markdown
Member Author

cc @nodejs/crypto

@indutny

indutny commented May 4, 2017

Copy link
Copy Markdown
Member Author

@MylesBorins I wonder how far this can be backported? This looks like a very big oversight on our end, that could be fixed for our LTS users.

@benjamingr

Copy link
Copy Markdown
Member

@indutny the change looks like there shouldn't be any trouble backporting it to 6.x and 4.x, based on how _tls_wrap looks like at these branches.

@addaleax addaleax added lts-watch-v4.x semver-minor PRs that contain new features and should be released in the next minor version. and removed lts-watch-v4.x labels May 4, 2017
@addaleax

addaleax commented May 4, 2017

Copy link
Copy Markdown
Member

I don’t think this could be backported to v4.x since it’s in Maintenance mode now, but for v6.x it should make sense as part of one of the regular semver-minor updates?

@indutny

indutny commented May 4, 2017

Copy link
Copy Markdown
Member Author

I'd love to see it backported to v4.x, if this is not in contradiction to our promises. My company is still moving to v6, and v4 upgrade will be much much easier to roll out. Otherwise, I'm going to write some terrible hacky code 😢

@addaleax

addaleax commented May 4, 2017

Copy link
Copy Markdown
Member

@nodejs/lts Thoughts? I think we can consider it a bugfix, it we want to.

@subeeshcbabu-zz

Copy link
Copy Markdown

It would be awesome, if this fix lands in v4.x as well. While we are migrating all our code to pick up latest LTS, having this option enabled in v4.x helps us a lot to maintain and phase out the upgrade process.

Comment thread test/parallel/test-tls-lookup.js Outdated

const expectedError = /^TypeError: "lookup" option should be a function$/;

['foobar', 1, {}, []].forEach((input) => connectThrows(input));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: how about passing connectThrows directly instead of wrapping it in another function?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is practically a copy-paste of test-net-lookup.js FWIW.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack.

Comment thread test/parallel/test-tls-lookup.js Outdated
}, expectedError);
}

connectDoesNotThrow(common.mustCall(common.noop));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: in light of #12822 I'm not sure if it makes sense to use () => {} here.

@Trott Trott May 5, 2017 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lpinca You mean don't use common.noop here? Instead use () => {}? (If so: 👍)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Trott yes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack.

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggested reword of docs, otherwise LGTM

Comment thread doc/api/tls.md
`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()`][].

ghost May 5, 2017

Copy link
Copy Markdown
Contributor

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.

ghost May 5, 2017

Copy link
Copy Markdown
Member Author

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.

ghost May 5, 2017

Copy link
Copy Markdown
Contributor

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.

@MylesBorins

ghost commented May 6, 2017

Copy link
Copy Markdown
Contributor

if this lands as a patch it can likely be included in a future maintenance release... I don't think it would be appropriate to do another minor.

That being said there are some other minors that could offer better consistency across our release lines. While I am reluctant I support LTS discussing this... I've tagged this issue

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

['foobar', 1, {}, []].forEach(function connectThrows(input) {
const opts = {
host: 'localhost',
port: common.PORT,

ghost May 15, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an ongoing effort to avoid the usage of common.PORT. cc @Trott Can you please change the port number to zero, if it is applicable?

ghost May 15, 2017

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a copy-paste of a similar net test FWIW

@indutny

ghost commented May 15, 2017

Copy link
Copy Markdown
Member Author

Landed in e600fbe, thank you everyone!

@MylesBorins

ghost commented Sep 19, 2017 •

Copy link
Copy Markdown
Contributor

LTS WG agreed that this can be backported

@indutny

ghost commented Sep 19, 2017

Copy link
Copy Markdown
Member Author

Hooray!

@MylesBorins

ghost commented Jan 11, 2018

Copy link
Copy Markdown
Contributor

It looks like we agreed to backport but never did! I just landed on v6.x-staging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver-minor PRs that contain new features and should be released in the next minor version. tls Issues and PRs related to the tls subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.