How to use the dns.resolve function in dns

To help you get started, we’ve selected a few dns examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pex-gl / pex / lib / init / init.js View on Github external
function isOnline(callback) {
    require('dns').resolve('www.google.com', function(err) {
        if (err) { callback(err, false); }
        else callback(null, true);
    });
}
github kuno / GeoIP / country.js View on Github external
var _id_by_domain = function(data, domain, callback) {
    var country_id;
    var ipnum;
    dns.resolve(domain, rrtype='A', function(err, addresses) {
        if (err) {throw err;}
        ipnum = ip2long(addresses[0]);
        country_id = seek_country(data, ipnum) - GEOIP_COUNTRY_BEGIN;
        if (country_id !== false) {
            callback(null, country_id);
        }
    });
};
github handshake-org / hsd / lib / net / dns.js View on Github external
return new Promise((resolve, reject) => {
    dns.resolve(host, 'A', to((err, result) => {
      if (err) {
        reject(err);
        return;
      }

      if (result.length === 0) {
        reject(new Error('No DNS results.'));
        return;
      }

      resolve(result);
    }));
  });
};
github Reactive-Extensions / rxjs-node / lib / rx_dns.js View on Github external
exports.resolve = function(domain, rrtype) {
    var subject = new Rx.AsyncSubject(),
    handler = function(err, addresses) {
        if (err) {
            subject.onError(err);
        } else {
            subject.onNext(addresses);
            subject.onCompleted();
        }
    };
    dns.resolve(domain, rrtype, handler);
    return subject;
};
exports.resolve4 = function(domain) {
github tmpfs / async-validate / doc / example / state.js View on Github external
function lookup(cb) {
            function resolve(err, addr) {
              if(err && err.code === 'ENOTFOUND') {
                this.raise(
                  '%s: could not resolve dns for domain %s',
                  this.field,
                  this.state.email.domain);
              }else if(err) {
                return cb(err); 
              }
              this.state.addr = addr;
              cb(); 
            }
            dns.resolve(this.state.email.domain, resolve.bind(this));
          }
        ]
github w3c / Mobile-Checker / lib / checkremote.js View on Github external
function all_addrs(data) {
	var deferred = Q.defer();
	dns.resolve(data.host, function(err, addrs) {
		if (err) deferred.resolve(err);
		data['addrs'] = addrs;
		deferred.resolve(data);
	});
	return deferred.promise;
}

dns

A DNS Server with a REST API

MIT
Latest version published 10 years ago

Package Health Score

44 / 100
Full package analysis