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 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
- console.log(
17
- ` ${q(host.name)} [label="${host.name}|{${[
18
- ...host.networkInterfaces.values()
19
- ]
20
- .filter(ni => !ni.isTemplate && ni.kind !== "loopback")
21
- .map(ni => `<${q(ni.name)}> ${ni.name}`)
22
- .join("|")}}"];`
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
- console.log(` ${[...cluster.members].map(b => `${q(b.host.name)}:${b.name}`).join(" -- ")};`);
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(" } [label=\"${cluster.name}\"];");
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.0",
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.2.0",
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.0",
47
+ "@types/node": "^22.14.1",
48
48
  "ava": "^6.2.0",
49
49
  "c8": "^10.1.3",
50
50
  "documentation": "^14.0.3",
@@ -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?.kind) {
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
  }
@@ -89,6 +89,8 @@ class SkeletonNetworkInterface extends Base {
89
89
  get addresses() {
90
90
  return [...this.ipAddresses].map(([address]) => address);
91
91
  }
92
+
93
+ async systemdDefinitions(packageData) {}
92
94
  }
93
95
 
94
96
  export const NetworkInterfaceTypeDefinition = {
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
- return address.startsWith(this.prefix);
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";