Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function isOnline(callback) {
require('dns').resolve('www.google.com', function(err) {
if (err) { callback(err, false); }
else callback(null, true);
});
}
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);
}
});
};
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);
}));
});
};
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) {
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));
}
]
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;
}