🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@rjweb/utils

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rjweb/utils - npm Package Compare versions

Comparing version

to
1.11.4

5

CHANGELOG.md

@@ -0,1 +1,6 @@

## 1.11.4
- Make subnet parser fix the initial ip
- Rename `<Subnet>.mask` to `<Subnet>.subnetmask`
## 1.11.3

@@ -2,0 +7,0 @@

68

lib/cjs/network.js

@@ -75,2 +75,3 @@ "use strict";

this.type = subnet.type;
this.subnetmask = subnet.subnetmask;
return;

@@ -89,2 +90,17 @@ }

this.iFirst = new IPAddress(content);
const subnetmask = new Uint8Array(4);
let netmask = this.netmask;
for (let i = 0; i < 4; i++) {
if (netmask > 0) {
let bits = netmask > 8 ? 8 : netmask;
subnetmask[i] = (1 << bits) - 1 << 8 - bits;
netmask -= bits;
} else {
subnetmask[i] = 0;
}
}
this.subnetmask = subnetmask;
for (let i = 0; i < this.iFirst.rawData.length; i++) {
this.iFirst.rawData[i] &= subnetmask[i];
}
break;

@@ -99,2 +115,17 @@ }

this.iFirst = new IPAddress(content);
const subnetmask = new Uint16Array(8);
let netmask = this.netmask;
for (let i = 0; i < 8; i++) {
if (netmask > 0) {
let bits = netmask > 16 ? 16 : netmask;
subnetmask[i] = (1 << bits) - 1 << 16 - bits;
netmask -= bits;
} else {
subnetmask[i] = 0;
}
}
this.subnetmask = subnetmask;
for (let i = 0; i < this.iFirst.rawData.length; i++) {
this.iFirst.rawData[i] &= subnetmask[i];
}
break;

@@ -131,3 +162,3 @@ }

if (this.type === 4) {
const mask = this.mask();
const mask = this.subnetmask;
const net2 = new Uint8Array(4);

@@ -139,3 +170,3 @@ for (let i = 0; i < 4; i++) {

} else {
const mask = this.mask();
const mask = this.subnetmask;
const net2 = new Uint16Array(8);

@@ -160,35 +191,2 @@ for (let i = 0; i < 8; i++) {

/**
* Get the Subnet Mask
* @since 1.11.0
*/
mask() {
if (this.type === 4) {
const mask = new Uint8Array(4);
let subnet = this.netmask;
for (let i = 0; i < 4; i++) {
if (subnet > 0) {
let bits = subnet > 8 ? 8 : subnet;
mask[i] = (1 << bits) - 1 << 8 - bits;
subnet -= bits;
} else {
mask[i] = 0;
}
}
return mask;
} else {
const mask = new Uint16Array(8);
let subnet = this.netmask;
for (let i = 0; i < 8; i++) {
if (subnet > 0) {
let bits = subnet > 16 ? 16 : subnet;
mask[i] = (1 << bits) - 1 << 16 - bits;
subnet -= bits;
} else {
mask[i] = 0;
}
}
return mask;
}
}
/**
* Check if the Subnet includes another IP address or subnet

@@ -195,0 +193,0 @@ * @since 1.11.0

{
"name": "@rjweb/utils",
"version": "1.11.3",
"version": "1.11.4",
"description": "Easy and Lightweight Utilities",

@@ -5,0 +5,0 @@ "module": "lib/esm/index.js",

@@ -33,2 +33,3 @@ import * as net from "net";

this.type = subnet.type;
this.subnetmask = subnet.subnetmask;
return;

@@ -47,2 +48,17 @@ }

this.iFirst = new IPAddress(content);
const subnetmask = new Uint8Array(4);
let netmask = this.netmask;
for (let i = 0; i < 4; i++) {
if (netmask > 0) {
let bits = netmask > 8 ? 8 : netmask;
subnetmask[i] = (1 << bits) - 1 << 8 - bits;
netmask -= bits;
} else {
subnetmask[i] = 0;
}
}
this.subnetmask = subnetmask;
for (let i = 0; i < this.iFirst.rawData.length; i++) {
this.iFirst.rawData[i] &= subnetmask[i];
}
break;

@@ -57,2 +73,17 @@ }

this.iFirst = new IPAddress(content);
const subnetmask = new Uint16Array(8);
let netmask = this.netmask;
for (let i = 0; i < 8; i++) {
if (netmask > 0) {
let bits = netmask > 16 ? 16 : netmask;
subnetmask[i] = (1 << bits) - 1 << 16 - bits;
netmask -= bits;
} else {
subnetmask[i] = 0;
}
}
this.subnetmask = subnetmask;
for (let i = 0; i < this.iFirst.rawData.length; i++) {
this.iFirst.rawData[i] &= subnetmask[i];
}
break;

@@ -89,3 +120,3 @@ }

if (this.type === 4) {
const mask = this.mask();
const mask = this.subnetmask;
const net2 = new Uint8Array(4);

@@ -97,3 +128,3 @@ for (let i = 0; i < 4; i++) {

} else {
const mask = this.mask();
const mask = this.subnetmask;
const net2 = new Uint16Array(8);

@@ -118,35 +149,2 @@ for (let i = 0; i < 8; i++) {

/**
* Get the Subnet Mask
* @since 1.11.0
*/
mask() {
if (this.type === 4) {
const mask = new Uint8Array(4);
let subnet = this.netmask;
for (let i = 0; i < 4; i++) {
if (subnet > 0) {
let bits = subnet > 8 ? 8 : subnet;
mask[i] = (1 << bits) - 1 << 8 - bits;
subnet -= bits;
} else {
mask[i] = 0;
}
}
return mask;
} else {
const mask = new Uint16Array(8);
let subnet = this.netmask;
for (let i = 0; i < 8; i++) {
if (subnet > 0) {
let bits = subnet > 16 ? 16 : subnet;
mask[i] = (1 << bits) - 1 << 16 - bits;
subnet -= bits;
} else {
mask[i] = 0;
}
}
return mask;
}
}
/**
* Check if the Subnet includes another IP address or subnet

@@ -153,0 +151,0 @@ * @since 1.11.0

{
"name": "@rjweb/utils",
"version": "1.11.3",
"version": "1.11.4",
"description": "Easy and Lightweight Utilities",

@@ -5,0 +5,0 @@ "module": "lib/esm/index.js",

@@ -51,2 +51,6 @@ /// <reference types="node" />

/**
* The Subnet Mask of the Subnet
* @since 1.11.4
*/ subnetmask: Type extends 4 ? Type extends 6 ? Uint8Array | Uint16Array : Uint8Array : Uint16Array;
/**
* Whether this is an IPv4 Subnet

@@ -72,6 +76,2 @@ * @since 1.7.0

/**
* Get the Subnet Mask
* @since 1.11.0
*/ mask(): Type extends 4 ? Type extends 6 ? Uint8Array | Uint16Array : Uint8Array : Uint16Array;
/**
* Check if the Subnet includes another IP address or subnet

@@ -78,0 +78,0 @@ * @since 1.11.0

{
"name": "@rjweb/utils",
"version": "1.11.3",
"version": "1.11.4",
"description": "Easy and Lightweight Utilities",

@@ -5,0 +5,0 @@ "module": "lib/esm/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet