don't promisify node's dns; fix https://github.com/Daplie/node-greenlock/issues/69
This commit is contained in:
parent
772dd22516
commit
825001bfb8
|
@ -4,8 +4,7 @@ var path = require('path');
|
||||||
var homeRe = new RegExp("^~(\\/|\\\\|\\" + path.sep + ")");
|
var homeRe = new RegExp("^~(\\/|\\\\|\\" + path.sep + ")");
|
||||||
var re = /^[a-zA-Z0-9\.\-]+$/;
|
var re = /^[a-zA-Z0-9\.\-]+$/;
|
||||||
var punycode = require('punycode');
|
var punycode = require('punycode');
|
||||||
var PromiseA = require('bluebird');
|
var dnsResolveMxAsync = require('util').promisify(require('dns').resolveMx);
|
||||||
var dns = PromiseA.promisifyAll(require('dns'));
|
|
||||||
|
|
||||||
module.exports.attachCertInfo = function (results) {
|
module.exports.attachCertInfo = function (results) {
|
||||||
// XXX Note: Parsing the certificate info comes at a great cost (~500kb)
|
// XXX Note: Parsing the certificate info comes at a great cost (~500kb)
|
||||||
|
@ -107,10 +106,10 @@ module.exports.testEmail = function (email) {
|
||||||
if (2 !== parts.length || !parts[0] || !parts[1]) {
|
if (2 !== parts.length || !parts[0] || !parts[1]) {
|
||||||
err = new Error("malformed email address '" + email + "'");
|
err = new Error("malformed email address '" + email + "'");
|
||||||
err.code = 'E_EMAIL';
|
err.code = 'E_EMAIL';
|
||||||
return PromiseA.reject(err);
|
return Promise.reject(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dns.resolveMxAsync(parts[1]).then(function (records) {
|
return dnsResolveMxAsync(parts[1]).then(function (records) {
|
||||||
// records only returns when there is data
|
// records only returns when there is data
|
||||||
if (!records.length) {
|
if (!records.length) {
|
||||||
throw new Error("sanity check fail: success, but no MX records returned");
|
throw new Error("sanity check fail: success, but no MX records returned");
|
||||||
|
@ -120,7 +119,7 @@ module.exports.testEmail = function (email) {
|
||||||
if ('ENODATA' === err.code) {
|
if ('ENODATA' === err.code) {
|
||||||
err = new Error("no MX records found for '" + parts[1] + "'");
|
err = new Error("no MX records found for '" + parts[1] + "'");
|
||||||
err.code = 'E_EMAIL';
|
err.code = 'E_EMAIL';
|
||||||
return PromiseA.reject(err);
|
return Promise.reject(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue