Skip to content

Commit

Permalink
replace resolveMX with nu.get_mx with punycode (#2861)
Browse files Browse the repository at this point in the history
* replace resolveMX with nu.get_mx with punycode, fixes #2778
* require newer haraka-net-utils
  • Loading branch information
msimerson committed Nov 18, 2020
1 parent 9b60d3b commit 4e4a005
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
1 change: 1 addition & 0 deletions Changes.md
Expand Up @@ -42,6 +42,7 @@

### Fixes

* check for punycode domain names when resolving MX, avoid crash #2861
* wait until entire message is spooled when spool_after in use #2840
* hmail: add missing space in temp_fail emitter #2837
* fix outbound config reloading after outbound split #2802
Expand Down
12 changes: 5 additions & 7 deletions outbound/mx_lookup.js
@@ -1,6 +1,7 @@
"use strict";

const dns = require('dns');
const net_utils = require('haraka-net-utils')

exports.lookup_mx = function lookup_mx (domain, cb) {
const mxs = [];
Expand Down Expand Up @@ -44,19 +45,16 @@ exports.lookup_mx = function lookup_mx (domain, cb) {
return 1;
}

dns.resolveMx(domain, (err, addresses) => {
if (process_dns(err, addresses)) {
return;
}
net_utils.get_mx(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;
}
if (process_dns(err2, addresses2)) return;

err2 = new Error("Found nowhere to deliver to");
err2.code = 'NOMX';
cb(err2);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -34,7 +34,7 @@
"haraka-config" : ">=1.0.15",
"haraka-constants" : ">=1.0.5",
"haraka-dsn" : "*",
"haraka-net-utils" : ">=1.1.2",
"haraka-net-utils" : ">=1.2.0",
"haraka-notes" : "*",
"haraka-results" : "^2.0.3",
"haraka-tld" : "*",
Expand Down
2 changes: 1 addition & 1 deletion plugins/mail_from.is_resolvable.js
Expand Up @@ -67,7 +67,7 @@ exports.hook_mail = function (next, connection, params) {
}

// IS: IPv6 compatible
dns.resolveMx(domain, (err, addresses) => {
net_utils.get_mx(domain, (err, addresses) => {
if (!txn) return;
if (err && plugin.mxErr(connection, domain, 'MX', err, mxDone)) return;

Expand Down
3 changes: 2 additions & 1 deletion spf.js
Expand Up @@ -3,6 +3,7 @@

const dns = require('dns');
const ipaddr = require('ipaddr.js');
const net_utils = require('haraka-net-utils')

class SPF {
constructor (count, been_there) {
Expand Down Expand Up @@ -467,7 +468,7 @@ class SPF {
domain = dm[1];
}
// Fetch the MX records for the specified domain
dns.resolveMx(domain, (err, mxes) => {
net_utils.get_mx(domain, (err, mxes) => {
if (err) {
switch (err.code) {
case dns.NOTFOUND:
Expand Down

0 comments on commit 4e4a005

Please sign in to comment.