pmcf 2.29.0 → 2.29.2
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/bin/pmcf-diagram +30 -10
- package/package.json +3 -3
- package/src/host-utils.mjs +3 -1
- package/src/host.mjs +12 -0
- package/src/network-interface.mjs +2 -0
- package/src/subnet.mjs +9 -2
- package/types/host.d.mts +1 -0
- package/types/network-interface.d.mts +1 -0
package/bin/pmcf-diagram
CHANGED
|
@@ -13,14 +13,16 @@ function q(str) {
|
|
|
13
13
|
console.log("graph G {");
|
|
14
14
|
console.log(" node [shape=record];");
|
|
15
15
|
for await (const host of location.hosts()) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
if (host.clusters.size === 0) {
|
|
17
|
+
console.log(
|
|
18
|
+
` ${q(host.name)} [label="${host.name}|{${[
|
|
19
|
+
...host.networkInterfaces.values()
|
|
20
|
+
]
|
|
21
|
+
.filter(ni => !ni.isTemplate && ni.kind !== "loopback")
|
|
22
|
+
.map(ni => `<${q(ni.name)}> ${ni.name}`)
|
|
23
|
+
.join("|")}}"];`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
for await (const network of location.networks()) {
|
|
@@ -47,9 +49,27 @@ for await (const network of location.networks()) {
|
|
|
47
49
|
for await (const cluster of location.clusters()) {
|
|
48
50
|
console.log(` subgraph cluster_${cluster.name} {`);
|
|
49
51
|
|
|
50
|
-
|
|
52
|
+
for (const ni of cluster.members) {
|
|
53
|
+
const host = ni.host;
|
|
54
|
+
console.log(
|
|
55
|
+
` ${q(host.name)} [label="${host.name}|{${[
|
|
56
|
+
...host.networkInterfaces.values()
|
|
57
|
+
]
|
|
58
|
+
.filter(ni => !ni.isTemplate && ni.kind !== "loopback")
|
|
59
|
+
.map(ni => `<${q(ni.name)}> ${ni.name}`)
|
|
60
|
+
.join("|")}}"];`
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/*
|
|
65
|
+
console.log(
|
|
66
|
+
` ${[...cluster.members]
|
|
67
|
+
.map(b => `${q(b.host.name)}:${b.name}`)
|
|
68
|
+
.join(" -- ")};`
|
|
69
|
+
|
|
70
|
+
);*/
|
|
51
71
|
|
|
52
|
-
console.log(
|
|
72
|
+
console.log(` } [label="${cluster.name}"];`);
|
|
53
73
|
}
|
|
54
74
|
|
|
55
75
|
for (const bridge of location.bridges) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmcf",
|
|
3
|
-
"version": "2.29.
|
|
3
|
+
"version": "2.29.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -38,13 +38,13 @@
|
|
|
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.3.0",
|
|
42
42
|
"npm-pkgbuild": "^18.0.1",
|
|
43
43
|
"pacc": "^3.4.0",
|
|
44
44
|
"pkg-dir": "^8.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@types/node": "^22.14.
|
|
47
|
+
"@types/node": "^22.14.1",
|
|
48
48
|
"ava": "^6.2.0",
|
|
49
49
|
"c8": "^10.1.3",
|
|
50
50
|
"documentation": "^14.0.3",
|
package/src/host-utils.mjs
CHANGED
|
@@ -26,6 +26,8 @@ export async function generateNetworkDefs(host, packageData) {
|
|
|
26
26
|
const networkDir = join(packageData.dir, "etc/systemd/network");
|
|
27
27
|
|
|
28
28
|
for (const ni of host.networkInterfaces.values()) {
|
|
29
|
+
await ni.systemdDefinitions(packageData);
|
|
30
|
+
|
|
29
31
|
switch (ni.kind) {
|
|
30
32
|
case "loopback":
|
|
31
33
|
continue;
|
|
@@ -101,7 +103,7 @@ export async function generateNetworkDefs(host, packageData) {
|
|
|
101
103
|
|
|
102
104
|
await writeLines(networkDir, `${ni.name}.network`, networkSections);
|
|
103
105
|
|
|
104
|
-
switch (ni
|
|
106
|
+
switch (ni.kind) {
|
|
105
107
|
case "wifi": {
|
|
106
108
|
const d = join(packageData.dir, "etc/wpa_supplicant");
|
|
107
109
|
await mkdir(d, { recursive: true });
|
package/src/host.mjs
CHANGED
|
@@ -324,6 +324,18 @@ export class Host extends Base {
|
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
+
get clusters() {
|
|
328
|
+
const clusters = new Set();
|
|
329
|
+
|
|
330
|
+
for (const ni of this.networkInterfaces.values()) {
|
|
331
|
+
if (ni.cluster) {
|
|
332
|
+
clusters.add(ni.cluster);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return clusters;
|
|
337
|
+
}
|
|
338
|
+
|
|
327
339
|
get host() {
|
|
328
340
|
return this;
|
|
329
341
|
}
|
package/src/subnet.mjs
CHANGED
|
@@ -3,7 +3,8 @@ import {
|
|
|
3
3
|
isLinkLocal,
|
|
4
4
|
rangeIP,
|
|
5
5
|
decodeIP,
|
|
6
|
-
familyIP
|
|
6
|
+
familyIP,
|
|
7
|
+
matchPrefixIP
|
|
7
8
|
} from "ip-utilties";
|
|
8
9
|
import { Base } from "./base.mjs";
|
|
9
10
|
import { addType } from "./types.mjs";
|
|
@@ -52,7 +53,13 @@ export class Subnet extends Base {
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
matchesAddress(address) {
|
|
55
|
-
|
|
56
|
+
try {
|
|
57
|
+
return matchPrefixIP(this.address, this.prefixLength, address);
|
|
58
|
+
} catch (e) {
|
|
59
|
+
console.error(e, address, this.address, this.prefixLength);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return false;
|
|
56
63
|
}
|
|
57
64
|
|
|
58
65
|
get isLinkLocal() {
|
package/types/host.d.mts
CHANGED
|
@@ -225,6 +225,7 @@ export class Host extends Base {
|
|
|
225
225
|
get domainNames(): Set<any>;
|
|
226
226
|
get domainName(): any;
|
|
227
227
|
domainNamesIn(domain: any): Generator<any, void, unknown>;
|
|
228
|
+
get clusters(): Set<any>;
|
|
228
229
|
get host(): this;
|
|
229
230
|
named(name: any): any;
|
|
230
231
|
get networks(): Set<any>;
|
|
@@ -1350,6 +1350,7 @@ declare class SkeletonNetworkInterface extends Base {
|
|
|
1350
1350
|
networkAddress(filter: any): NetworkAddress;
|
|
1351
1351
|
get address(): any;
|
|
1352
1352
|
get addresses(): any[];
|
|
1353
|
+
systemdDefinitions(packageData: any): Promise<void>;
|
|
1353
1354
|
}
|
|
1354
1355
|
import { Base } from "pmcf";
|
|
1355
1356
|
import { NetworkAddress } from "pmcf";
|