-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Conversation
@@ -117,6 +117,17 @@ The callback has arguments `(err, domains)`. | |||
On error, `err` is an `Error` object, where `err.code` is | |||
one of the error codes listed below. | |||
|
|||
## dns.getServers() | |||
|
|||
Returns an array of ips as strings that are currently being used for resolution |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/ips/IP addresses/ ?
I have pushed the changes for the lint fixes. I also further extended the test to include setting IPv6 resolvers. However, So this PR is currently blocked, |
I believe I fixed the bug in |
Thanks for looking into this, I've commented on that pullreq with another issue I found. I updated my current branch but haven't force pushed, I opted to do the parsing in js and the slightly safer |
c-ares doesn't take pull requests, I believe. You have to |
@bnoordhuis I did push my new change, if you could please re-review I'd appreciate it. |
char ip[INET6_ADDRSTRLEN]; | ||
|
||
uv_inet_ntop(cur->family, | ||
static_cast<const void *>(&cur->addr), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: const void*
@bnoordhuis updated, I also got rid of the superfluous memcpy since |
for (int i = 0; cur != NULL; ++i, cur = cur->next) { | ||
char ip[INET6_ADDRSTRLEN]; | ||
|
||
uv_inet_ntop(cur->family, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check the return value. If return_value.code is not UV_OK, ip probably contains garbage.
A few more nits, otherwise LGTM. |
getServers returns an array of ips that are currently being used for resolution setServers takes an array of ips that are to be used for resolution, this will throw if there's invalid input but preserve the original configuration
landed in 8886c6b |
Is there a need to make these functions invoke callbacks, as getting the data synchronously isn't the best thing to do. |
I struggled with that decision, in fact in my original ticket #3132 that's what I had done, with an eye towards how I do it in my JS implementation of the Ultimately c-ares initializes synchronously when node itself starts, so most of your file operations to determine the resolvers happen at startup, the call to In any JS reimplementation that might happen in the future, it would also make sense to initialize synchronously (on the first require) as otherwise you end up having to queue any incoming requests while you wait for the platform to initialize. |
Would it be better to add optional callbacks, that are called once the servers have been loaded/set? So you're not waiting for a variable to be initialised synchronously. |
Well it's not really an issue for c-ares as everything has already been initialized by the time you are executing javascript. And replacing c-ares with a pure javascript version is still a hypothetical situation for now. Perhaps @bnoordhuis or @isaacs have an opinion on this |
One possible option would be to compile c-ares into JavaScript with Emscripten. I'm not sure wether this would better or worsen performance, but either way, it's an option |
While I find emscripten interesting, it is certainly the wrong way to handle this particular situation. Especially as there are multiple DNS in javascript parsers, including one I've written. The question is if there's enough to gain/solve by using a javascript implementation to offset the overhead of owning the maintenance cost. The vast majority of requests are handled through |
Yeah, a pure javascript dns module would be great. |
getServers returns an array of ips that are currently being used for
resolution
setServers takes an array of ips that are to be used for resolution,
this will throw if there's invalid input but preserve the original
configuration