pmcf 2.22.2 → 2.23.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/bin/pmcf-diagram +2 -2
- package/package.json +1 -1
- package/src/services/dhcp.mjs +16 -14
- package/src/services/dns.mjs +1 -1
- package/src/subnet.mjs +3 -11
- package/types/subnet.d.mts +1 -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/bin/pmcf-diagram
CHANGED
|
@@ -10,7 +10,7 @@ function q(str) {
|
|
|
10
10
|
return str.match(/^\w+$/) ? str : `"${str}"`;
|
|
11
11
|
}
|
|
12
12
|
function id(str) {
|
|
13
|
-
return str.replaceAll(/-/g, "");
|
|
13
|
+
return q(str.replaceAll(/-/g, ""));
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
console.log("graph G {");
|
|
@@ -40,7 +40,7 @@ for await (const network of location.networks()) {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
for await (const na of network.networkAddresses(
|
|
45
45
|
na =>
|
|
46
46
|
na.networkInterface.network === network &&
|
package/package.json
CHANGED
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
|
}
|
package/types/subnet.d.mts
CHANGED
|
@@ -28,11 +28,10 @@ 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;
|