pmcf 2.21.0 → 2.21.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/package.json +1 -1
- package/src/host-utils.mjs +2 -1
- package/src/host.mjs +0 -10
- package/src/module.mjs +1 -0
- package/src/network-interface.mjs +0 -10
- package/src/network-support.mjs +14 -1
- package/src/service.mjs +10 -4
- package/types/host.d.mts +0 -2
- package/types/module.d.mts +1 -0
- package/types/network-interface.d.mts +0 -2
- package/types/network-support.d.mts +1 -0
- package/types/service.d.mts +2 -1
package/package.json
CHANGED
package/src/host-utils.mjs
CHANGED
|
@@ -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.
|
|
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 = {
|
package/src/network-support.mjs
CHANGED
|
@@ -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: {
|
|
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/src/service.mjs
CHANGED
|
@@ -173,10 +173,6 @@ export class Service extends Base {
|
|
|
173
173
|
this._ipAddresses = value;
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
get addresses() {
|
|
177
|
-
return this.rawAddresses.map(a => `${a}:${this.port}`);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
176
|
get networks() {
|
|
181
177
|
return this.server.networks;
|
|
182
178
|
}
|
|
@@ -328,12 +324,22 @@ export class Endpoint {
|
|
|
328
324
|
return `${this.rawAddress}[${this.port}]`;
|
|
329
325
|
}
|
|
330
326
|
|
|
327
|
+
get socketAddress()
|
|
328
|
+
{
|
|
329
|
+
return `${this.address}:${this.port}`;
|
|
330
|
+
}
|
|
331
|
+
|
|
331
332
|
get hostName() {
|
|
332
333
|
return this.networkInterface.hostName;
|
|
333
334
|
}
|
|
334
335
|
|
|
335
336
|
#rawAddress;
|
|
336
337
|
|
|
338
|
+
get address()
|
|
339
|
+
{
|
|
340
|
+
return this.#rawAddress ?? this.networkInterface.rawAddress;
|
|
341
|
+
}
|
|
342
|
+
|
|
337
343
|
get rawAddress() {
|
|
338
344
|
return this.#rawAddress ?? this.networkInterface.rawAddress;
|
|
339
345
|
}
|
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;
|
package/types/module.d.mts
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";
|
|
@@ -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";
|
package/types/service.d.mts
CHANGED
|
@@ -311,7 +311,6 @@ export class Service extends Base {
|
|
|
311
311
|
get rawAddresses(): any;
|
|
312
312
|
get rawAddress(): any;
|
|
313
313
|
set ipAddresses(value: any);
|
|
314
|
-
get addresses(): any;
|
|
315
314
|
get networks(): any;
|
|
316
315
|
get endpoints(): any[];
|
|
317
316
|
findEndpoints(filter: any): Generator<any, void, any>;
|
|
@@ -336,7 +335,9 @@ export class Endpoint {
|
|
|
336
335
|
service: any;
|
|
337
336
|
networkInterface: any;
|
|
338
337
|
toString(): string;
|
|
338
|
+
get socketAddress(): string;
|
|
339
339
|
get hostName(): any;
|
|
340
|
+
get address(): any;
|
|
340
341
|
set rawAddress(value: any);
|
|
341
342
|
get rawAddress(): any;
|
|
342
343
|
#private;
|