nodemailer
Advanced tools
Comparing version 6.6.5 to 6.7.0
# CHANGELOG | ||
## 6.7.0 2021-10-11 | ||
- Updated DNS resolving logic. If there are multiple responses for a A/AAAA record, then loop these randomly instead of only caching the first one | ||
## 6.6.5 2021-09-23 | ||
@@ -4,0 +8,0 @@ |
@@ -15,5 +15,5 @@ /* eslint no-console: 0 */ | ||
const networkInterfaces = (module.exports.networkInterfaces = os.networkInterfaces()); | ||
const resolver = (family, hostname, callback) => { | ||
const networkInterfaces = os.networkInterfaces(); | ||
const familySupported = | ||
@@ -50,12 +50,41 @@ // crux that replaces Object.values(networkInterfaces) as Object.values is not supported in nodejs v6 | ||
const dnsCache = (module.exports.dnsCache = new Map()); | ||
const formatDNSValue = (value, extra) => { | ||
if (!value) { | ||
return Object.assign({}, extra || {}); | ||
} | ||
return Object.assign( | ||
{ | ||
servername: value.servername, | ||
host: | ||
!value.addresses || !value.addresses.length | ||
? null | ||
: value.addresses.length === 1 | ||
? value.addresses[0] | ||
: value.addresses[Math.floor(Math.random() * value.addresses.length)] | ||
}, | ||
extra || {} | ||
); | ||
}; | ||
module.exports.resolveHostname = (options, callback) => { | ||
options = options || {}; | ||
if (!options.host && options.servername) { | ||
options.host = options.servername; | ||
} | ||
if (!options.host || net.isIP(options.host)) { | ||
// nothing to do here | ||
let value = { | ||
host: options.host, | ||
addresses: [options.host], | ||
servername: options.servername || false | ||
}; | ||
return callback(null, value); | ||
return callback( | ||
null, | ||
formatDNSValue(value, { | ||
cached: false | ||
}) | ||
); | ||
} | ||
@@ -68,7 +97,8 @@ | ||
if (!cached.expires || cached.expires >= Date.now()) { | ||
return callback(null, { | ||
host: cached.value.host, | ||
servername: cached.value.servername, | ||
_cached: true | ||
}); | ||
return callback( | ||
null, | ||
formatDNSValue(cached.value, { | ||
cached: true | ||
}) | ||
); | ||
} | ||
@@ -81,11 +111,19 @@ } | ||
// ignore error, use expired value | ||
return callback(null, cached.value); | ||
return callback( | ||
null, | ||
formatDNSValue(cached.value, { | ||
cached: true, | ||
error: err | ||
}) | ||
); | ||
} | ||
return callback(err); | ||
} | ||
if (addresses && addresses.length) { | ||
let value = { | ||
host: addresses[0] || options.host, | ||
addresses, | ||
servername: options.servername || options.host | ||
}; | ||
dnsCache.set(options.host, { | ||
@@ -95,3 +133,9 @@ value, | ||
}); | ||
return callback(null, value); | ||
return callback( | ||
null, | ||
formatDNSValue(value, { | ||
cached: false | ||
}) | ||
); | ||
} | ||
@@ -103,11 +147,19 @@ | ||
// ignore error, use expired value | ||
return callback(null, cached.value); | ||
return callback( | ||
null, | ||
formatDNSValue(cached.value, { | ||
cached: true, | ||
error: err | ||
}) | ||
); | ||
} | ||
return callback(err); | ||
} | ||
if (addresses && addresses.length) { | ||
let value = { | ||
host: addresses[0] || options.host, | ||
addresses, | ||
servername: options.servername || options.host | ||
}; | ||
dnsCache.set(options.host, { | ||
@@ -117,3 +169,9 @@ value, | ||
}); | ||
return callback(null, value); | ||
return callback( | ||
null, | ||
formatDNSValue(value, { | ||
cached: false | ||
}) | ||
); | ||
} | ||
@@ -126,3 +184,9 @@ | ||
// ignore error, use expired value | ||
return callback(null, cached.value); | ||
return callback( | ||
null, | ||
formatDNSValue(cached.value, { | ||
cached: true, | ||
error: err | ||
}) | ||
); | ||
} | ||
@@ -134,9 +198,15 @@ return callback(err); | ||
// nothing was found, fallback to cached value | ||
return callback(null, cached.value); | ||
return callback( | ||
null, | ||
formatDNSValue(cached.value, { | ||
cached: true | ||
}) | ||
); | ||
} | ||
let value = { | ||
host: address || options.host, | ||
addresses: address ? [address] : [options.host], | ||
servername: options.servername || options.host | ||
}; | ||
dnsCache.set(options.host, { | ||
@@ -146,3 +216,9 @@ value, | ||
}); | ||
return callback(null, value); | ||
return callback( | ||
null, | ||
formatDNSValue(value, { | ||
cached: false | ||
}) | ||
); | ||
}); | ||
@@ -152,3 +228,9 @@ } catch (err) { | ||
// ignore error, use expired value | ||
return callback(null, cached.value); | ||
return callback( | ||
null, | ||
formatDNSValue(cached.value, { | ||
cached: true, | ||
error: err | ||
}) | ||
); | ||
} | ||
@@ -155,0 +237,0 @@ return callback(err); |
@@ -264,3 +264,3 @@ 'use strict'; | ||
resolved: resolved.host, | ||
cached: !!resolved._cached | ||
cached: !!resolved.cached | ||
}, | ||
@@ -270,3 +270,3 @@ 'Resolved %s as %s [cache %s]', | ||
resolved.host, | ||
resolved._cached ? 'hit' : 'miss' | ||
resolved.cached ? 'hit' : 'miss' | ||
); | ||
@@ -304,3 +304,3 @@ Object.keys(resolved).forEach(key => { | ||
resolved: resolved.host, | ||
cached: !!resolved._cached | ||
cached: !!resolved.cached | ||
}, | ||
@@ -310,3 +310,3 @@ 'Resolved %s as %s [cache %s]', | ||
resolved.host, | ||
resolved._cached ? 'hit' : 'miss' | ||
resolved.cached ? 'hit' : 'miss' | ||
); | ||
@@ -339,3 +339,3 @@ Object.keys(resolved).forEach(key => { | ||
resolved: resolved.host, | ||
cached: !!resolved._cached | ||
cached: !!resolved.cached | ||
}, | ||
@@ -345,3 +345,3 @@ 'Resolved %s as %s [cache %s]', | ||
resolved.host, | ||
resolved._cached ? 'hit' : 'miss' | ||
resolved.cached ? 'hit' : 'miss' | ||
); | ||
@@ -348,0 +348,0 @@ Object.keys(resolved).forEach(key => { |
{ | ||
"name": "nodemailer", | ||
"version": "6.6.5", | ||
"version": "6.7.0", | ||
"description": "Easy as cake e-mail sending from your Node.js applications", | ||
@@ -23,4 +23,4 @@ "main": "lib/nodemailer.js", | ||
"devDependencies": { | ||
"@aws-sdk/client-ses": "3.33.0", | ||
"aws-sdk": "2.993.0", | ||
"@aws-sdk/client-ses": "3.36.0", | ||
"aws-sdk": "2.1004.0", | ||
"bunyan": "1.8.15", | ||
@@ -37,3 +37,3 @@ "chai": "4.3.4", | ||
"libqp": "1.1.0", | ||
"mocha": "9.1.1", | ||
"mocha": "9.1.2", | ||
"nodemailer-ntlm-auth": "1.0.1", | ||
@@ -40,0 +40,0 @@ "proxy": "1.0.2", |
@@ -13,2 +13,4 @@ # Nodemailer | ||
> Nodemailer supports all Node.js versions starting from Node.js@v6.0.0. Existing test suite does not support such old Node.js versions so all features are not actually tested. From time to time some regression bugs might occur because of this. | ||
#### First review the docs | ||
@@ -15,0 +17,0 @@ |
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
478910
11547
47