use search path from platform when resolving names with resolve*#91
Open
markdrago wants to merge 1 commit intotjfontaine:masterfrom
Open
use search path from platform when resolving names with resolve*#91markdrago wants to merge 1 commit intotjfontaine:masterfrom
markdrago wants to merge 1 commit intotjfontaine:masterfrom
Conversation
Collaborator
|
This project is no longer maintained, but we are happy to link to a well maintained fork. Please see: #111 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@tjfontaine we spoke about this a bit in #node.js the other day. After we spoke I ran in to some issues and this patch is the result. The tl;dr version is that it looks like dns and native-dns do not use the search path in resolv.conf when the resolve* functions are used.
To go in to a bit more detail, at my company we use DNS to help us discover the zookeeper nodes that are running in a given environment (dev, qa, prod). The way we do this is we perform a lookup for an SRV record (_zookeeper._tcp) and then rely on the search path in resolv.conf to find the right name for the given environment (_zookeeper._tcp.nyc.dev.company.com). This works in other languages without an issue (eg python: dns.resolver.query('_zookeeper._tcp', 'SRV')). We're looking to do more with node, so here we are.
I wrote out the code to do a similar request using dns.resolveSrv from the native dns package and was getting ENOTFOUND. I spent a bit of time reading through the c-ares source, but my c++-fu failed me so I switched over to native-dns, had the same issue with ENOTFOUND, and started reading through the native-dns code to try and find out why. It looks like the lookup() function will use the search path from the platform, but the resolve* functions do not. I'm curious to know why that is. This patch just copies some of the functionality from the lookup functions and uses it in the resolve* functions. With this patch I see the behavior I was expecting, resolve* starts using the search paths.
Here's some before/after debug output:
before: https://gist.github.com/markdrago/0f4542a7cb35011e8fef
after: https://gist.github.com/markdrago/52b73c29ef30ec86fef4
It's probably also worth pointing out that my search_path was of the form:
[ [ 'nyc.dev.company.com', 'company.com', 'home' ] ]
So I had to pull the inner array out with [0] before working with it.