mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
48 lines
1.1 KiB
JavaScript
48 lines
1.1 KiB
JavaScript
function callback (promise) {
|
|
return function () {
|
|
if (arguments[0] instanceof Error) {
|
|
promise.emitError.apply(promise, arguments);
|
|
} else {
|
|
promise.emitSuccess.apply(promise, arguments);
|
|
}
|
|
}
|
|
}
|
|
|
|
exports.resolve4 = function (domain) {
|
|
var promise = new process.Promise();
|
|
process.dns.resolve4(domain, callback(promise));
|
|
return promise;
|
|
};
|
|
|
|
exports.resolve6 = function (domain) {
|
|
var promise = new process.Promise();
|
|
process.dns.resolve6(domain, callback(promise));
|
|
return promise;
|
|
};
|
|
|
|
exports.reverse = function (ip) {
|
|
var promise = new process.Promise();
|
|
process.dns.reverse(ip, callback(promise));
|
|
return promise;
|
|
};
|
|
|
|
// ERROR CODES
|
|
|
|
// timeout, SERVFAIL or similar.
|
|
exports.TEMPFAIL = process.dns.TEMPFAIL;
|
|
|
|
// got garbled reply.
|
|
exports.PROTOCOL = process.dns.PROTOCOL;
|
|
|
|
// domain does not exists.
|
|
exports.NXDOMAIN = process.dns.NXDOMAIN;
|
|
|
|
// domain exists but no data of reqd type.
|
|
exports.NODATA = process.dns.NODATA;
|
|
|
|
// out of memory while processing.
|
|
exports.NOMEM = process.dns.NOMEM;
|
|
|
|
// the query is malformed.
|
|
exports.BADQUERY = process.dns.BADQUERY;
|