Skip to content

Commit

Permalink
v1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Mar 1, 2023
1 parent 6846c31 commit 6122e95
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
8 changes: 6 additions & 2 deletions lib/resolve-ip.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const dnsErrors = require('./dns-errors');
const tools = require('./tools');

// we do not reject on error to avoid issues where one failing MX record kills entire sending
function resolve4(mx, dnsResolve = dns.resolve) {
function resolve4(mx, dnsResolve) {
dnsResolve = dnsResolve || dns.resolve;

return new Promise(resolve => {
dnsResolve(mx.exchange, (err, list) => {
if (err && err.code !== 'ENODATA' && err.code !== 'ENOTFOUND') {
Expand All @@ -19,7 +21,9 @@ function resolve4(mx, dnsResolve = dns.resolve) {
});
}

function resolve6(mx, dnsResolve = dns.resolve) {
function resolve6(mx, dnsResolve) {
dnsResolve = dnsResolve || dns.resolve;

return new Promise(resolve => {
dnsResolve(mx.exchange, 'AAAA', (err, list) => {
if (err && err.code !== 'ENODATA' && err.code !== 'ENOTFOUND') {
Expand Down
7 changes: 4 additions & 3 deletions lib/resolve-mx.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ async function resolveMX(delivery) {
}

let domain = delivery.decodedDomain;
const dnsResolve = dnsOptions.resolve || dns.resolve;

dnsOptions.resolve(domain, 'MX', (err, list) => {
dnsResolve(domain, 'MX', (err, list) => {
if (err && err.code !== 'ENODATA' && err.code !== 'ENOTFOUND') {
err.category = 'dns';
err.message = 'DNS error when resolving MX server for ' + domain + ': ' + (dnsErrors[err.code] || err.message);
Expand All @@ -64,7 +65,7 @@ async function resolveMX(delivery) {

if (!list || !list.length) {
// fallback to A
return dnsOptions.resolve(domain, (err, list) => {
return dnsResolve(domain, (err, list) => {
if (err && err.code !== 'ENODATA' && err.code !== 'ENOTFOUND') {
err.message = 'DNS error when resolving MX server for ' + domain + ': ' + (dnsErrors[err.code] || err.message);
err.response = '450 ' + err.message;
Expand All @@ -74,7 +75,7 @@ async function resolveMX(delivery) {

if (!list || (!list.length && !dnsOptions.ignoreIPv6)) {
// fallback to AAAA
return dnsOptions.resolve(domain, 'AAAA', (err, list) => {
return dnsResolve(domain, 'AAAA', (err, list) => {
if (err && err.code !== 'ENODATA' && err.code !== 'ENOTFOUND') {
err.message = 'DNS error when resolving MX server for ' + domain + ': ' + (dnsErrors[err.code] || err.message);
err.response = '450 ' + err.message;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mx-connect",
"version": "1.4.0",
"version": "1.4.1",
"description": "Establish TCP connection to a MX server",
"main": "lib/mx-connect.js",
"scripts": {
Expand Down

0 comments on commit 6122e95

Please sign in to comment.