pmcf 2.20.1 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmcf",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.21.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target es2024 --lib esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"ip-utilties": "^1.
|
|
41
|
+
"ip-utilties": "^1.2.0",
|
|
42
42
|
"npm-pkgbuild": "^18.0.1",
|
|
43
43
|
"pacc": "^3.4.0",
|
|
44
44
|
"pkg-dir": "^8.0.0"
|
|
@@ -3,7 +3,8 @@ import {
|
|
|
3
3
|
isIPv6,
|
|
4
4
|
formatCIDR,
|
|
5
5
|
hasWellKnownSubnet,
|
|
6
|
-
normalizeIP
|
|
6
|
+
normalizeIP,
|
|
7
|
+
familyIP
|
|
7
8
|
} from "ip-utilties";
|
|
8
9
|
import { Base } from "./base.mjs";
|
|
9
10
|
import { Subnet } from "./subnet.mjs";
|
|
@@ -18,6 +19,7 @@ import { addType } from "./types.mjs";
|
|
|
18
19
|
* @typedef {object} NetworkAddress
|
|
19
20
|
* @property {NetworkInterface} networkInterface
|
|
20
21
|
* @property {string|Uint8Array|Uint16Array} address
|
|
22
|
+
* @property {string} family
|
|
21
23
|
* @property {Subnet} subnet
|
|
22
24
|
* @property {Set<string>} domainNames
|
|
23
25
|
*/
|
|
@@ -72,35 +74,34 @@ class SkeletonNetworkInterface extends Base {
|
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
/**
|
|
75
|
-
*
|
|
77
|
+
*
|
|
76
78
|
* @param {object} filter
|
|
77
|
-
* @return {Iterable<NetworkAddress>}
|
|
79
|
+
* @return {Iterable<NetworkAddress>}
|
|
78
80
|
*/
|
|
79
|
-
*networkAddresses(filter=
|
|
81
|
+
*networkAddresses(filter = n => true) {
|
|
80
82
|
for (const [address, subnet] of this.ipAddresses) {
|
|
81
83
|
const networkAddress = {
|
|
82
84
|
networkInterface: this,
|
|
83
85
|
domainNames: this.domainNames,
|
|
84
86
|
address,
|
|
87
|
+
family: familyIP(address),
|
|
85
88
|
subnet
|
|
86
89
|
};
|
|
87
90
|
|
|
88
|
-
if(filter(networkAddress)) {
|
|
91
|
+
if (filter(networkAddress)) {
|
|
89
92
|
yield networkAddress;
|
|
90
93
|
}
|
|
91
94
|
}
|
|
92
95
|
}
|
|
93
96
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
get rawIPv4Address() {
|
|
99
|
-
return this.rawAddresses.filter(a => isIPv4(a))[0];
|
|
97
|
+
networkAddress(filter) {
|
|
98
|
+
for (const a of this.networkAddresses(filter)) {
|
|
99
|
+
return a;
|
|
100
|
+
}
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
get
|
|
103
|
-
return this.rawAddresses
|
|
103
|
+
get rawAddress() {
|
|
104
|
+
return this.rawAddresses[0];
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
get cidrAddress() {
|
|
@@ -111,18 +112,6 @@ class SkeletonNetworkInterface extends Base {
|
|
|
111
112
|
return [...this.ipAddresses].map(([address]) => address);
|
|
112
113
|
}
|
|
113
114
|
|
|
114
|
-
get rawIPv4Addresses() {
|
|
115
|
-
return [...this.ipAddresses]
|
|
116
|
-
.filter(([address]) => isIPv4(address))
|
|
117
|
-
.map(([address]) => address);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
get rawIPv6Addresses() {
|
|
121
|
-
return [...this.ipAddresses]
|
|
122
|
-
.filter(([address]) => isIPv6(address))
|
|
123
|
-
.map(([address]) => address);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
115
|
get cidrAddresses() {
|
|
127
116
|
return [...this.ipAddresses].map(([address, subnet]) =>
|
|
128
117
|
formatCIDR(address, subnet.prefixLength)
|
package/src/services/dhcp.mjs
CHANGED
|
@@ -209,7 +209,7 @@ export class DHCPService extends Service {
|
|
|
209
209
|
.map(([k, networkInterface]) => {
|
|
210
210
|
return {
|
|
211
211
|
"hw-address": k,
|
|
212
|
-
"ip-address": networkInterface.
|
|
212
|
+
"ip-address": networkInterface.networkAddress(n => n.family === "IPv4").address,
|
|
213
213
|
hostname: networkInterface.hostName
|
|
214
214
|
};
|
|
215
215
|
})
|
|
@@ -688,6 +688,7 @@ export class LoopbackNetworkInterface extends SkeletonNetworkInterface {
|
|
|
688
688
|
export type NetworkAddress = {
|
|
689
689
|
networkInterface: NetworkInterface;
|
|
690
690
|
address: string | Uint8Array | Uint16Array;
|
|
691
|
+
family: string;
|
|
691
692
|
subnet: Subnet;
|
|
692
693
|
domainNames: Set<string>;
|
|
693
694
|
};
|
|
@@ -695,6 +696,7 @@ export type NetworkAddress = {
|
|
|
695
696
|
* @typedef {object} NetworkAddress
|
|
696
697
|
* @property {NetworkInterface} networkInterface
|
|
697
698
|
* @property {string|Uint8Array|Uint16Array} address
|
|
699
|
+
* @property {string} family
|
|
698
700
|
* @property {Subnet} subnet
|
|
699
701
|
* @property {Set<string>} domainNames
|
|
700
702
|
*/
|
|
@@ -715,13 +717,10 @@ declare class SkeletonNetworkInterface extends Base {
|
|
|
715
717
|
* @return {Iterable<NetworkAddress>}
|
|
716
718
|
*/
|
|
717
719
|
networkAddresses(filter?: object): Iterable<NetworkAddress>;
|
|
720
|
+
networkAddress(filter: any): NetworkAddress;
|
|
718
721
|
get rawAddress(): any;
|
|
719
|
-
get rawIPv4Address(): any;
|
|
720
|
-
get rawIPv6Address(): any;
|
|
721
722
|
get cidrAddress(): any;
|
|
722
723
|
get rawAddresses(): any[];
|
|
723
|
-
get rawIPv4Addresses(): any[];
|
|
724
|
-
get rawIPv6Addresses(): any[];
|
|
725
724
|
get cidrAddresses(): any[];
|
|
726
725
|
}
|
|
727
726
|
import { Subnet } from "./subnet.mjs";
|