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

dns: make always 8.8.8.8 in name servers #1647

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lib/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,12 @@ exports.resolve = function(hostname, type_, callback_) {
};


exports.getServers = function() {
exports.getServers = function getServers() {
return cares.getServers();
};


exports.setServers = function(servers) {
exports.setServers = function setServers(servers) {
// cache the original servers because in the event of an error setting the
// servers cares won't have any servers available for resolution
var orig = cares.getServers();
Expand Down Expand Up @@ -353,3 +353,12 @@ exports.NOTINITIALIZED = 'ENOTINITIALIZED';
exports.LOADIPHLPAPI = 'ELOADIPHLPAPI';
exports.ADDRGETNETWORKPARAMS = 'EADDRGETNETWORKPARAMS';
exports.CANCELLED = 'ECANCELLED';

// set 8.8.8.8 as default
(function() {
var servers = exports.getServers();
if (servers.indexOf('8.8.8.8') === -1) {
servers.push('8.8.8.8');
exports.setServers(servers);
}
})();
6 changes: 6 additions & 0 deletions test/parallel/test-dns-default-servers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var common = require('../common');
var assert = require('assert');
var dns = require('dns');

var servers = dns.getServers();
assert.ok(servers.indexOf('8.8.8.8') !== -1);