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

haraka-net-utils

Package Overview
Dependencies
Maintainers
4
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

haraka-net-utils - npm Package Compare versions

Comparing version 1.3.2 to 1.3.3

3

Changes.md
#### 1.N.N - YYYY-MM-DD
#### 1.3.3 - 2021-12-20
- refactored is_local_host function to return a promise instead of using a callback #65
#### 1.3.2 - 2021-12-20

@@ -6,0 +9,0 @@

24

index.js

@@ -143,16 +143,16 @@ 'use strict';

exports.is_local_host = function (host, done) {
exports.is_local_host = async function (host) {
if (net.isIP(host)) {
done([], this.is_local_ip(host));
return;
return this.is_local_ip(host);
}
return new Promise((resolve, reject) => {
const self = this;
const self = this;
this.get_ips_by_host(host, function (errors, ips) {
if (errors.length) {
done(errors, undefined);
}
else {
done([], ips.length ? self.is_local_ip(ips[0]) : false);
}
this.get_ips_by_host(host, function (errors, ips) {
// don't reject if some IPs have been found (get_ips_by_host can return errors say for IPv6 but work for IPv4)
if (errors && errors.length && (!ips || !ips.length)) {
return reject(errors);
}
resolve(ips.length ? self.is_local_ip(ips[0]) : false);
});
});

@@ -168,3 +168,3 @@ }

console.error(`invalid IP address: ${ip}`);
// console.error(`invalid IP address: ${ip}`);
return false;

@@ -171,0 +171,0 @@ }

{
"name": "haraka-net-utils",
"version": "1.3.2",
"version": "1.3.3",
"description": "haraka network utilities",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -85,7 +85,6 @@

function _is_local_host (done, host, expected) {
net_utils.is_local_host(host, function (errors, is_local_host) {
assert.strictEqual(expected, is_local_host);
done();
});
async function _is_local_host (done, host, expected) {
const is_local_host = await net_utils.is_local_host(host);
assert.strictEqual(expected, is_local_host);
done();
}

@@ -124,4 +123,4 @@

it('invalid host string', function (done) {
_is_local_host(done, 'invalid host string', undefined);
it('invalid host string', async function () {
await assert.rejects(net_utils.is_local_host('invalid host string'));
})

@@ -128,0 +127,0 @@ })

Sorry, the diff of this file is not supported yet

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