haraka-net-utils
Advanced tools
Comparing version 1.2.1 to 1.2.2
### 1.2.2 - 2020-12-15 | ||
- get_mx: do not include implicit MX | ||
### 1.2.1 - 2020-11-17 | ||
@@ -3,0 +7,0 @@ |
49
index.js
@@ -347,6 +347,6 @@ 'use strict'; | ||
exports.ipv6_bogus = function (ipv6){ | ||
exports.ipv6_bogus = function (ipv6) { | ||
try { | ||
const ipCheck = ipaddr.parse(ipv6); | ||
if (ipCheck.range() !== 'unicast') { return true; } | ||
if (ipCheck.range() !== 'unicast') return true; | ||
return false; | ||
@@ -422,47 +422,12 @@ } | ||
// wrap_mx returns our object with "priority" and "exchange" keys | ||
let wrap_mx = a => a; | ||
const wrap_mx = a => a; | ||
function process_dns (err, addresses) { | ||
if (err) { | ||
// Most likely this is a hostname with no MX record | ||
// Drop through and we'll get the A record instead. | ||
switch (err.code) { | ||
case 'ENODATA': | ||
case 'ENOTFOUND': | ||
return 0; | ||
default: | ||
} | ||
dns.resolveMx(domain, (err, addresses) => { | ||
cb(err, mxs); | ||
for (const addr of addresses) { | ||
mxs.push(wrap_mx(addr)); | ||
} | ||
else if (addresses && addresses.length) { | ||
for (const addr of addresses) { | ||
mxs.push(wrap_mx(addr)); | ||
} | ||
cb(null, mxs); | ||
} | ||
else { | ||
// return zero if we need to keep trying next option | ||
return 0; | ||
} | ||
return 1; | ||
} | ||
dns.resolveMx(domain, (err, addresses) => { | ||
if (process_dns(err, addresses)) return; | ||
// if MX lookup failed, we lookup an A record. To do that we change | ||
// wrap_mx() to return same thing as resolveMx() does. | ||
wrap_mx = a => ({ priority: 0, exchange: a }); | ||
// IS: IPv6 compatible | ||
dns.resolve(domain, (err2, addresses2) => { | ||
if (process_dns(err2, addresses2)) return; | ||
err2 = new Error("Found nowhere to deliver to"); | ||
err2.code = 'NOMX'; | ||
cb(err2, mxs); | ||
}) | ||
cb(err, mxs); | ||
}) | ||
} |
{ | ||
"name": "haraka-net-utils", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "haraka network utilities", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1069,2 +1069,3 @@ | ||
it('gets MX records for a domain', function (done) { | ||
this.timeout(3000) | ||
this.net_utils.get_mx('tnpi.net', (err, mxlist) => { | ||
@@ -1093,18 +1094,2 @@ assert.ifError(err); | ||
}) | ||
it('gets an IP (no MX) for mail-toaster.org', function (done) { | ||
this.net_utils.get_mx('mail-toaster.org', (err, mxlist) => { | ||
assert.equal(mxlist.length, 1); | ||
assert.equal(mxlist[0].exchange, '66.128.51.170'); | ||
done(); | ||
}) | ||
}) | ||
it('gets a MX for über.cadillac.net', function (done) { | ||
this.net_utils.get_mx('über.cadillac.net', (err, mxlist) => { | ||
assert.equal(mxlist.length, 1); | ||
assert.equal(mxlist[0].exchange, '127.0.0.1'); | ||
done(); | ||
}) | ||
}) | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
78692
1355