haraka-net-utils
Advanced tools
Comparing version 1.4.0 to 1.4.1
#### N.N.N - YYYY-MM-DD | ||
### [1.4.1] - 2022-07-22 | ||
### [1.4.0] - 2022-07-22 | ||
- feat(get_mx): use async/await | ||
@@ -181,2 +180,2 @@ - feat(get_mx): call w/o callback for promise API | ||
[1.3.7]: https://github.com/haraka/haraka-net-utils/releases/tag/1.3.7 | ||
[1.4.0]: https://github.com/haraka/haraka-net-utils/releases/tag/1.4.0 | ||
[1.4.1]: https://github.com/haraka/haraka-net-utils/releases/tag/1.4.1 |
12
index.js
@@ -340,11 +340,9 @@ 'use strict'; | ||
// for callback API | ||
if (done) { | ||
if (done) { // legacy callback API | ||
Promise.all(promises).then((r) => { done(errors, Array.from(ips)) }) | ||
return | ||
} | ||
// promise API | ||
// if (process.env.DEBUG && errors.length) console.error(errors) | ||
return Promise.all(promises).then(r => { return Array.from(ips) }) | ||
else { // promise API | ||
// if (process.env.DEBUG && errors.length) console.error(errors) | ||
return Promise.all(promises).then(r => { return Array.from(ips) }) | ||
} | ||
} | ||
@@ -351,0 +349,0 @@ |
{ | ||
"name": "haraka-net-utils", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "haraka network utilities", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -95,11 +95,30 @@ [![CI][ci-img]][ci-url] | ||
### get_ips_by_host | ||
Returns an array of all the IPv4 and IPv6 addresses of the provided hostname. | ||
```js | ||
try { | ||
const ips = await net_utils.get_ips_by_host(domain) | ||
for (const ip of ips) { | ||
// do something with the IPs | ||
} | ||
} | ||
catch (err) { | ||
// handle any errors | ||
} | ||
``` | ||
### get_mx | ||
```js | ||
net_utils.get_mx(domain, (err, mxList) => { | ||
if (err) // handle any errors | ||
try { | ||
const mxList = await net_utils.get_mx(domain) | ||
for (const mx of mxList) { | ||
// do something with each mx | ||
} | ||
}) | ||
} | ||
catch (err) { | ||
// handle any errors | ||
} | ||
``` | ||
@@ -106,0 +125,0 @@ |
81181
133
1483