pmcf 2.21.0 → 2.21.1

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.21.0",
3
+ "version": "2.21.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -2,6 +2,7 @@ import { writeFile, mkdir } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
3
  import { writeLines, sectionLines } from "../src/utils.mjs";
4
4
  import { addHook } from "./hooks.mjs";
5
+ import { cidrAddresses } from "./network-support.mjs";
5
6
 
6
7
  export async function generateMachineInfo(host, packageData) {
7
8
  const etcDir = join(packageData.dir, "etc");
@@ -40,7 +41,7 @@ export async function generateNetworkDefs(host, packageData) {
40
41
 
41
42
  const networkSections = [sectionLines("Match", { Name: ni.name })];
42
43
 
43
- for (const Address of ni.cidrAddresses) {
44
+ for (const Address of cidrAddresses(ni.networkAddresses())) {
44
45
  networkSections.push(
45
46
  "",
46
47
  sectionLines("Address", {
package/src/host.mjs CHANGED
@@ -435,16 +435,6 @@ export class Host extends Base {
435
435
  return [...this.networkAddresses()].map(na => na.address);
436
436
  }
437
437
 
438
- get cidrAddress() {
439
- return this.cidrAddresses[0];
440
- }
441
-
442
- get cidrAddresses() {
443
- return [...this.networkAddresses()].map(({ address, subnet }) =>
444
- formatCIDR(address, subnet.prefixLength)
445
- );
446
- }
447
-
448
438
  async publicKey(type = "ed25519") {
449
439
  return readFile(join(this.directory, `ssh_host_${type}_key.pub`), "utf8");
450
440
  }
package/src/module.mjs CHANGED
@@ -10,6 +10,7 @@ export * from "./root.mjs";
10
10
  export * from "./address.mjs";
11
11
  export * from "./subnet.mjs";
12
12
  export * from "./network.mjs";
13
+ export * from "./network-support.mjs";
13
14
  export * from "./network-interface.mjs";
14
15
  export * from "./host.mjs";
15
16
  export * from "./types.mjs";
@@ -104,19 +104,9 @@ class SkeletonNetworkInterface extends Base {
104
104
  return this.rawAddresses[0];
105
105
  }
106
106
 
107
- get cidrAddress() {
108
- return this.cidrAddresses[0];
109
- }
110
-
111
107
  get rawAddresses() {
112
108
  return [...this.ipAddresses].map(([address]) => address);
113
109
  }
114
-
115
- get cidrAddresses() {
116
- return [...this.ipAddresses].map(([address, subnet]) =>
117
- formatCIDR(address, subnet.prefixLength)
118
- );
119
- }
120
110
  }
121
111
 
122
112
  export const NetworkInterfaceTypeDefinition = {
@@ -1,3 +1,5 @@
1
+ import { formatCIDR } from "ip-utilties";
2
+
1
3
  export const networkProperties = {
2
4
  scope: {
3
5
  type: "string",
@@ -23,7 +25,12 @@ export const networkProperties = {
23
25
  metric: { type: "number", collection: false, writeable: true, default: 1004 },
24
26
  MTU: { type: "number", collection: false, writeable: true, default: 1500 },
25
27
  gateway: { type: "host", collection: false, writeable: true },
26
- multicastDNS: { type: "boolean", collection: false, writeable: true, default: false }
28
+ multicastDNS: {
29
+ type: "boolean",
30
+ collection: false,
31
+ writeable: true,
32
+ default: false
33
+ }
27
34
  };
28
35
 
29
36
  export const networkAddressProperties = {
@@ -33,3 +40,9 @@ export const networkAddressProperties = {
33
40
  rawAddresses: { type: "string", collection: true, writeable: false },
34
41
  rawAddress: { type: "string", collection: false, writeable: false }
35
42
  };
43
+
44
+ export function cidrAddresses(networkAddresses) {
45
+ return [...networkAddresses].map(na =>
46
+ formatCIDR(na.address, na.subnet.prefixLength)
47
+ );
48
+ }
package/types/host.d.mts CHANGED
@@ -235,8 +235,6 @@ export class Host extends Base {
235
235
  networkAddresses(filter: any): Generator<any, void, any>;
236
236
  get rawAddress(): any;
237
237
  get rawAddresses(): any[];
238
- get cidrAddress(): any;
239
- get cidrAddresses(): any[];
240
238
  publicKey(type?: string): Promise<string>;
241
239
  preparePackages(dir: any): AsyncGenerator<{
242
240
  dir: any;
@@ -10,6 +10,7 @@ export * from "./root.mjs";
10
10
  export * from "./address.mjs";
11
11
  export * from "./subnet.mjs";
12
12
  export * from "./network.mjs";
13
+ export * from "./network-support.mjs";
13
14
  export * from "./network-interface.mjs";
14
15
  export * from "./host.mjs";
15
16
  export * from "./types.mjs";
@@ -719,9 +719,7 @@ declare class SkeletonNetworkInterface extends Base {
719
719
  networkAddresses(filter?: object): Iterable<NetworkAddress>;
720
720
  networkAddress(filter: any): NetworkAddress;
721
721
  get rawAddress(): any;
722
- get cidrAddress(): any;
723
722
  get rawAddresses(): any[];
724
- get cidrAddresses(): any[];
725
723
  }
726
724
  import { Subnet } from "./subnet.mjs";
727
725
  import { Base } from "./base.mjs";
@@ -1,3 +1,4 @@
1
+ export function cidrAddresses(networkAddresses: any): any[];
1
2
  export namespace networkProperties {
2
3
  export namespace scope {
3
4
  export let type: string;