Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mx-connect

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mx-connect - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

4

lib/mx-connect.js

@@ -8,2 +8,3 @@ 'use strict';

const net = require('net');
const dns = require('dns');

@@ -38,3 +39,4 @@ module.exports = (options, callback) => {

preferIPv6: false,
blockLocalAddresses: false
blockLocalAddresses: false,
resolve: dns.resolve
},

@@ -41,0 +43,0 @@

@@ -9,5 +9,5 @@ 'use strict';

// we do not reject on error to avoid issues where one failing MX record kills entire sending
function resolve4(mx) {
function resolve4(mx, dnsResolve = dns.resolve) {
return new Promise(resolve => {
dns.resolve4(mx.exchange, (err, list) => {
dnsResolve(mx.exchange, (err, list) => {
if (err && err.code !== 'ENODATA' && err.code !== 'ENOTFOUND') {

@@ -23,5 +23,5 @@ mx.A = [].concat({ error: err, exchange: mx.exchange });

function resolve6(mx) {
function resolve6(mx, dnsResolve = dns.resolve) {
return new Promise(resolve => {
dns.resolve6(mx.exchange, (err, list) => {
dnsResolve(mx.exchange, 'AAAA', (err, list) => {
if (err && err.code !== 'ENODATA' && err.code !== 'ENOTFOUND') {

@@ -85,5 +85,5 @@ mx.AAAA = [].concat({ error: err, exchange: mx.exchange });

if (!net.isIP(entry.exchange)) {
resolveAddresses.push(resolve4(entry));
resolveAddresses.push(resolve4(entry, dnsOptions.resolve));
if (!dnsOptions.ignoreIPv6) {
resolveAddresses.push(resolve6(entry));
resolveAddresses.push(resolve6(entry, dnsOptions.resolve));
}

@@ -90,0 +90,0 @@ } else if (net.isIPv4(entry.exchange)) {

@@ -13,3 +13,4 @@ 'use strict';

let dnsOptions = delivery.dnsOptions || {
ignoreIPv6: false
ignoreIPv6: false,
resolve: dns.resolve
};

@@ -56,3 +57,3 @@

dns.resolveMx(domain, (err, list) => {
dnsOptions.resolve(domain, 'MX', (err, list) => {
if (err && err.code !== 'ENODATA' && err.code !== 'ENOTFOUND') {

@@ -68,3 +69,3 @@ err.category = 'dns';

// fallback to A
return dns.resolve4(domain, (err, list) => {
return dnsOptions.resolve(domain, (err, list) => {
if (err && err.code !== 'ENODATA' && err.code !== 'ENOTFOUND') {

@@ -79,3 +80,3 @@ err.message = 'DNS error when resolving MX server for ' + domain + ': ' + (dnsErrors[err.code] || err.message);

// fallback to AAAA
return dns.resolve6(domain, (err, list) => {
return dnsOptions.resolve(domain, 'AAAA', (err, list) => {
if (err && err.code !== 'ENODATA' && err.code !== 'ENOTFOUND') {

@@ -82,0 +83,0 @@ err.message = 'DNS error when resolving MX server for ' + domain + ': ' + (dnsErrors[err.code] || err.message);

{
"name": "mx-connect",
"version": "1.2.0",
"version": "1.3.0",
"description": "Establish TCP connection to a MX server",

@@ -26,11 +26,11 @@ "main": "lib/mx-connect.js",

"eslint-config-nodemailer": "1.2.0",
"eslint-config-prettier": "6.11.0",
"grunt": "1.1.0",
"grunt-cli": "1.3.2",
"grunt-contrib-nodeunit": "2.1.0",
"grunt-eslint": "23.0.0"
"eslint-config-prettier": "8.6.0",
"grunt": "1.6.1",
"grunt-cli": "1.4.3",
"grunt-contrib-nodeunit": "4.0.0",
"grunt-eslint": "24.0.1"
},
"dependencies": {
"ipaddr.js": "1.9.1"
"ipaddr.js": "2.0.1"
}
}

@@ -57,2 +57,3 @@ # mx-connect

- **blockLocalAddresses** (boolean, defaults to `false`) If true then refuses to connect to IP addresses that are either in loopback, private network or attached to the server. People put every kind of stuff in MX records, you do not want to flood your loopback interface because someone thought it is a great idea to set 127.0.0.1 as the MX server
- **resolve** (function, defaults to `dns.resolve`, callback-style)
- **mx** is a resolved MX object or an array of MX objects to skip DNS resolving. Useful if you want to connect to a specific host.

@@ -59,0 +60,0 @@ - **exchange** is the hostname of the MX

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc