pmcf 2.22.3 → 2.24.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/README.md +22 -2
- package/package.json +1 -1
- package/src/network-interface.mjs +7 -3
- package/src/services/dhcp.mjs +16 -14
- package/src/services/dns.mjs +1 -1
- package/src/subnet.mjs +7 -11
- package/types/network-interface.d.mts +1 -5
- package/types/subnet.d.mts +3 -2
package/README.md
CHANGED
|
@@ -21,13 +21,21 @@
|
|
|
21
21
|
### Table of Contents
|
|
22
22
|
|
|
23
23
|
* [NetworkAddress](#networkaddress)
|
|
24
|
+
* [Parameters](#parameters)
|
|
24
25
|
* [Properties](#properties)
|
|
26
|
+
* [subnet](#subnet)
|
|
27
|
+
* [networkInterface](#networkinterface)
|
|
28
|
+
* [address](#address)
|
|
25
29
|
* [networkAddresses](#networkaddresses)
|
|
26
|
-
* [Parameters](#parameters)
|
|
30
|
+
* [Parameters](#parameters-1)
|
|
27
31
|
|
|
28
32
|
## NetworkAddress
|
|
29
33
|
|
|
30
|
-
|
|
34
|
+
### Parameters
|
|
35
|
+
|
|
36
|
+
* `networkInterface`  
|
|
37
|
+
* `address`  
|
|
38
|
+
* `subnet`  
|
|
31
39
|
|
|
32
40
|
### Properties
|
|
33
41
|
|
|
@@ -37,6 +45,18 @@ Type: [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Globa
|
|
|
37
45
|
* `subnet` **Subnet** 
|
|
38
46
|
* `domainNames` **[Set](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** 
|
|
39
47
|
|
|
48
|
+
### subnet
|
|
49
|
+
|
|
50
|
+
Type: Subnet
|
|
51
|
+
|
|
52
|
+
### networkInterface
|
|
53
|
+
|
|
54
|
+
Type: NetworkInterface
|
|
55
|
+
|
|
56
|
+
### address
|
|
57
|
+
|
|
58
|
+
Type: ([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) | [Uint16Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array))
|
|
59
|
+
|
|
40
60
|
## networkAddresses
|
|
41
61
|
|
|
42
62
|
### Parameters
|
package/package.json
CHANGED
|
@@ -5,7 +5,11 @@ import {
|
|
|
5
5
|
formatCIDR
|
|
6
6
|
} from "ip-utilties";
|
|
7
7
|
import { Base } from "./base.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
Subnet,
|
|
10
|
+
SUBNET_LOCALHOST_IPV4,
|
|
11
|
+
SUBNET_LOCALHOST_IPV6
|
|
12
|
+
} from "./subnet.mjs";
|
|
9
13
|
import {
|
|
10
14
|
networkProperties,
|
|
11
15
|
networkAddressProperties
|
|
@@ -314,8 +318,8 @@ const LoopbackNetworkInterfaceTypeDefinition = {
|
|
|
314
318
|
};
|
|
315
319
|
|
|
316
320
|
const _localAddresses = new Map([
|
|
317
|
-
["127.0.0.1",
|
|
318
|
-
["::1",
|
|
321
|
+
["127.0.0.1", SUBNET_LOCALHOST_IPV4],
|
|
322
|
+
["::1", SUBNET_LOCALHOST_IPV6]
|
|
319
323
|
]);
|
|
320
324
|
|
|
321
325
|
export class LoopbackNetworkInterface extends SkeletonNetworkInterface {
|
package/src/services/dhcp.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { FileContentProvider } from "npm-pkgbuild";
|
|
3
|
-
import { isIPv4, isIPv6 } from "ip-utilties";
|
|
4
3
|
import {
|
|
5
4
|
Service,
|
|
6
5
|
ServiceTypeDefinition,
|
|
@@ -73,10 +72,14 @@ export class DHCPService extends Service {
|
|
|
73
72
|
|
|
74
73
|
console.log("kea", host.name, network.name);
|
|
75
74
|
|
|
76
|
-
const dnsServerEndpoints = serviceEndpoints(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
const dnsServerEndpoints = serviceEndpoints(
|
|
76
|
+
network,
|
|
77
|
+
{
|
|
78
|
+
type: "dns",
|
|
79
|
+
priority: "<10"
|
|
80
|
+
},
|
|
81
|
+
endpoint => endpoint.networkInterface.kind !== "loopback"
|
|
82
|
+
);
|
|
80
83
|
|
|
81
84
|
const packageData = {
|
|
82
85
|
dir,
|
|
@@ -147,7 +150,7 @@ export class DHCPService extends Service {
|
|
|
147
150
|
return {
|
|
148
151
|
name: domain,
|
|
149
152
|
"dns-servers": dnsServerEndpoints
|
|
150
|
-
.filter(endpoint =>
|
|
153
|
+
.filter(endpoint => endpoint.family === "IPv4")
|
|
151
154
|
.map(endpoint => {
|
|
152
155
|
return { "ip-address": endpoint.address };
|
|
153
156
|
})
|
|
@@ -191,7 +194,6 @@ export class DHCPService extends Service {
|
|
|
191
194
|
subnets.add(subnet);
|
|
192
195
|
}
|
|
193
196
|
}
|
|
194
|
-
//console.log([...subnets].filter(s => s.isIPv4).map(s => s.address));
|
|
195
197
|
|
|
196
198
|
const hwmap = new Map();
|
|
197
199
|
const hostNames = new Set();
|
|
@@ -217,11 +219,11 @@ export class DHCPService extends Service {
|
|
|
217
219
|
})
|
|
218
220
|
.sort((a, b) => a.hostname.localeCompare(b.hostname));
|
|
219
221
|
|
|
220
|
-
const listenInterfaces =
|
|
222
|
+
const listenInterfaces = family =>
|
|
221
223
|
this.endpoints(
|
|
222
224
|
endpoint =>
|
|
223
225
|
endpoint.type === "dhcp" &&
|
|
224
|
-
|
|
226
|
+
endpoint.family === family &&
|
|
225
227
|
endpoint.networkInterface.kind !== "loopback"
|
|
226
228
|
).map(
|
|
227
229
|
endpoint => `${endpoint.networkInterface.name}/${endpoint.address}`
|
|
@@ -231,7 +233,7 @@ export class DHCPService extends Service {
|
|
|
231
233
|
Dhcp4: {
|
|
232
234
|
...commonConfig,
|
|
233
235
|
"interfaces-config": {
|
|
234
|
-
interfaces: listenInterfaces(
|
|
236
|
+
interfaces: listenInterfaces("IPv4")
|
|
235
237
|
},
|
|
236
238
|
"multi-threading": {
|
|
237
239
|
"enable-multi-threading": false
|
|
@@ -244,7 +246,7 @@ export class DHCPService extends Service {
|
|
|
244
246
|
{
|
|
245
247
|
name: "domain-name-servers",
|
|
246
248
|
data: dnsServerEndpoints
|
|
247
|
-
.filter(endpoint =>
|
|
249
|
+
.filter(endpoint => endpoint.family === "IPv4")
|
|
248
250
|
.map(endpoint => endpoint.address)
|
|
249
251
|
.join(",")
|
|
250
252
|
},
|
|
@@ -254,7 +256,7 @@ export class DHCPService extends Service {
|
|
|
254
256
|
}
|
|
255
257
|
],
|
|
256
258
|
subnet4: [...subnets]
|
|
257
|
-
.filter(s => s.
|
|
259
|
+
.filter(s => s.family==='IPv4')
|
|
258
260
|
.map((subnet, index) => {
|
|
259
261
|
return {
|
|
260
262
|
id: index + 1,
|
|
@@ -277,7 +279,7 @@ export class DHCPService extends Service {
|
|
|
277
279
|
Dhcp6: {
|
|
278
280
|
...commonConfig,
|
|
279
281
|
"interfaces-config": {
|
|
280
|
-
interfaces: listenInterfaces(
|
|
282
|
+
interfaces: listenInterfaces("IPv6")
|
|
281
283
|
},
|
|
282
284
|
"control-socket": {
|
|
283
285
|
"socket-type": "unix",
|
|
@@ -288,7 +290,7 @@ export class DHCPService extends Service {
|
|
|
288
290
|
{
|
|
289
291
|
name: "dns-servers",
|
|
290
292
|
data: dnsServerEndpoints
|
|
291
|
-
.filter(endpoint =>
|
|
293
|
+
.filter(endpoint => endpoint.family === "IPv6")
|
|
292
294
|
.map(endpoint => endpoint.address)
|
|
293
295
|
.join(",")
|
|
294
296
|
}
|
package/src/services/dns.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { createHmac } from "node:crypto";
|
|
3
3
|
import { FileContentProvider } from "npm-pkgbuild";
|
|
4
|
-
import { isIPv6, isLinkLocal,
|
|
4
|
+
import { isIPv6, isLinkLocal, reverseArpa } from "ip-utilties";
|
|
5
5
|
import { writeLines } from "../utils.mjs";
|
|
6
6
|
import { DNSRecord, dnsFullName } from "../dns-utils.mjs";
|
|
7
7
|
import { addType } from "../types.mjs";
|
package/src/subnet.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
normalizeCIDR,
|
|
3
3
|
isLinkLocal,
|
|
4
|
-
isIPv4,
|
|
5
|
-
isIPv6,
|
|
6
4
|
rangeIP,
|
|
7
|
-
decodeIP
|
|
5
|
+
decodeIP,
|
|
6
|
+
familyIP
|
|
8
7
|
} from "ip-utilties";
|
|
9
8
|
import { Base } from "./base.mjs";
|
|
10
9
|
import { addType } from "./types.mjs";
|
|
@@ -45,6 +44,7 @@ export class Subnet extends Base {
|
|
|
45
44
|
this.prefix = prefix;
|
|
46
45
|
this.prefixLength = prefixLength;
|
|
47
46
|
this.longPrefix = longPrefix;
|
|
47
|
+
this.family = familyIP(address);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
get fullName() {
|
|
@@ -59,14 +59,6 @@ export class Subnet extends Base {
|
|
|
59
59
|
return isLinkLocal(this.address);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
get isIPv4() {
|
|
63
|
-
return isIPv4(this.address);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
get isIPv6() {
|
|
67
|
-
return isIPv6(this.address);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
62
|
get addressRange() {
|
|
71
63
|
return rangeIP(this.prefix, this.prefixLength, 1, 1).map(a => decodeIP(a));
|
|
72
64
|
}
|
|
@@ -91,6 +83,10 @@ export class Subnet extends Base {
|
|
|
91
83
|
}
|
|
92
84
|
}
|
|
93
85
|
|
|
86
|
+
const _owner = { addObject() {} };
|
|
87
|
+
export const SUBNET_LOCALHOST_IPV4 = new Subnet(_owner, "127.0.0.1/8");
|
|
88
|
+
export const SUBNET_LOCALHOST_IPV6 = new Subnet(_owner, "::1/128");
|
|
89
|
+
|
|
94
90
|
export function subnets(sources) {
|
|
95
91
|
const all = new Set();
|
|
96
92
|
|
|
@@ -695,11 +695,7 @@ export class LoopbackNetworkInterface extends SkeletonNetworkInterface {
|
|
|
695
695
|
get kind(): string;
|
|
696
696
|
get scope(): string;
|
|
697
697
|
get hostName(): string;
|
|
698
|
-
get ipAddresses(): Map<string,
|
|
699
|
-
address: string;
|
|
700
|
-
prefix: string;
|
|
701
|
-
prefixLength: number;
|
|
702
|
-
}>;
|
|
698
|
+
get ipAddresses(): Map<string, Subnet>;
|
|
703
699
|
}
|
|
704
700
|
import { Subnet } from "./subnet.mjs";
|
|
705
701
|
declare class SkeletonNetworkInterface extends Base {
|
package/types/subnet.d.mts
CHANGED
|
@@ -28,14 +28,15 @@ export class Subnet extends Base {
|
|
|
28
28
|
prefix: any;
|
|
29
29
|
prefixLength: any;
|
|
30
30
|
longPrefix: any;
|
|
31
|
+
family: any;
|
|
31
32
|
get fullName(): string;
|
|
32
33
|
matchesAddress(address: any): any;
|
|
33
34
|
get isLinkLocal(): any;
|
|
34
|
-
get isIPv4(): any;
|
|
35
|
-
get isIPv6(): any;
|
|
36
35
|
get addressRange(): any;
|
|
37
36
|
get address(): string;
|
|
38
37
|
get longAddress(): string;
|
|
39
38
|
_traverse(...args: any[]): boolean;
|
|
40
39
|
}
|
|
40
|
+
export const SUBNET_LOCALHOST_IPV4: Subnet;
|
|
41
|
+
export const SUBNET_LOCALHOST_IPV6: Subnet;
|
|
41
42
|
import { Base } from "./base.mjs";
|