dns: do not consult hosts file in reverse lookups - #64268
Conversation
|
Review requested:
|
|
Marking as semver-major (happy to be overruled). Although we do state in the small print that |
This comment was marked as spam.
This comment was marked as spam.
addaleax
left a comment
There was a problem hiding this comment.
This should come with a changes: entry in the documentation as well, even if it only aligns behavior with what is already documented. It's a significant change, and semver-major seems appropriate.
Additionally, I would strongly recommend giving this a proper commit message. Commit messages should explain:
- What happened
- How it happened
- Why it happened this way
Right now, this PR's commit message explains very little, but most importantly, it's not explaining why this change in behavior is better than e.g. a change of the documentation to just match current reality.
dns.reverse() is documented with dns.resolve*() as always performing DNS queries without using hosts file configuration. However, c-ares ares_gethostbyaddr() honors the channel lookup order, which can include the files source and cause reverse lookups to return entries from /etc/hosts. Configure c-ares resolver channels with ARES_OPT_LOOKUPS set to "b" so getHostByAddr uses DNS/PTR lookups only. This keeps dns.reverse() aligned with dns.resolve*() and preserves the distinction from system-resolution APIs such as dns.lookup() and dns.lookupService(). This is preferable to documenting the current behavior because hosts- file reverse lookup results are platform-dependent and expose hostent alias semantics rather than DNS PTR record semantics. Signed-off-by: Archkon <180910180+Archkon@users.noreply.github.com>
This comment was marked as spam.
This comment was marked as spam.
addaleax
left a comment
There was a problem hiding this comment.
I'll approve so CI can be kicked off but one thing that stands out a bit is that this, just based on the code changes, seems to also affect regular/non-reverse lookups? That seems like a pretty significant unintentional change
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
|
This will require an additional @nodejs/tsc approval to land. |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
mcollina
left a comment
There was a problem hiding this comment.
This seems a regression in functionality and not really a fix for the given issue.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
|
Landed in 54a5095 |
Fixes: #64257