Skip to content
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

use search path from platform when resolving names with resolve* #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

markdrago
Copy link

@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.

@markdrago markdrago changed the title use search path from platform when resolving names with resolv* use search path from platform when resolving names with resolve* Jan 20, 2015
@taoeffect
Copy link
Collaborator

This project is no longer maintained, but we are happy to link to a well maintained fork.

Please see: #111

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants