pmcf 1.23.1 → 1.23.3
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-host-defs +3 -2
- package/bin/pmcf-location-defs +2 -1
- package/bin/pmcf-named-defs +4 -4
- package/bin/pmcf-network +1 -1
- package/package.json +1 -1
- package/src/base.mjs +4 -4
- package/src/model.mjs +9 -16
- package/types/base.d.mts +1 -1
- package/types/model.d.mts +1 -3
package/bin/pmcf-host-defs
CHANGED
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
import { writeFile, mkdir, copyFile, glob } from "node:fs/promises";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
+
import { Host } from "pmcf";
|
|
5
6
|
import { writeLines, sectionLines } from "../src/utils.mjs";
|
|
6
|
-
import { prepare } from "../src/cmd.mjs";
|
|
7
|
+
import { prepare, } from "../src/cmd.mjs";
|
|
7
8
|
|
|
8
9
|
const { world, args, options } = prepare();
|
|
9
10
|
|
|
10
11
|
const hostName = args[0];
|
|
11
12
|
|
|
12
|
-
const host = await world.
|
|
13
|
+
const host = await world.load(hostName,{ type: Host });
|
|
13
14
|
|
|
14
15
|
await generateNetworkDefs(host, options.output);
|
|
15
16
|
await generateMachineInfo(host, options.output);
|
package/bin/pmcf-location-defs
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import { mkdir, copyFile } from "node:fs/promises";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
+
import { Location } from "pmcf";
|
|
5
6
|
import { writeLines, sectionLines } from "../src/utils.mjs";
|
|
6
7
|
import { prepare } from "../src/cmd.mjs";
|
|
7
8
|
|
|
8
9
|
const { world, args, options } = prepare();
|
|
9
10
|
|
|
10
|
-
const location = await world.
|
|
11
|
+
const location = await world.load(args[0], { type: Location });
|
|
11
12
|
|
|
12
13
|
await generateLocationDefs(location, options.output);
|
|
13
14
|
|
package/bin/pmcf-named-defs
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { createHmac } from "node:crypto";
|
|
5
|
+
import { Location } from "pmcf";
|
|
5
6
|
import { writeLines, isIPv4Address } from "../src/utils.mjs";
|
|
6
7
|
import { prepare } from "../src/cmd.mjs";
|
|
7
8
|
|
|
8
9
|
const { world, args, options } = prepare();
|
|
9
10
|
|
|
10
|
-
const location = await world.
|
|
11
|
+
const location = await world.load(args[0], { type: Location });
|
|
11
12
|
const updates = [
|
|
12
13
|
Math.ceil(Date.now() / 1000),
|
|
13
14
|
36000,
|
|
@@ -30,10 +31,9 @@ console.log("description", `named defintions for ${location.name}`);
|
|
|
30
31
|
|
|
31
32
|
async function generateNamedDefs(location, targetDir) {
|
|
32
33
|
const dns = location.dns;
|
|
33
|
-
const domain = location.domain;
|
|
34
34
|
const ttl = dns.recordTTL;
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
for (const domain of dns.domains) {
|
|
37
37
|
const zones = [];
|
|
38
38
|
const records = new Set();
|
|
39
39
|
|
|
@@ -48,7 +48,7 @@ async function generateNamedDefs(location, targetDir) {
|
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
console.log(location.name,
|
|
51
|
+
console.log(location.name, domain, nameserver?.hostName, rname);
|
|
52
52
|
|
|
53
53
|
const catalogZone = {
|
|
54
54
|
id: `catalog.${domain}`,
|
package/bin/pmcf-network
CHANGED
package/package.json
CHANGED
package/src/base.mjs
CHANGED
|
@@ -58,15 +58,15 @@ export class Base {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
get location() {
|
|
61
|
-
return this.owner
|
|
61
|
+
return this.owner?.location;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
get host() {
|
|
65
|
-
return this.owner
|
|
65
|
+
return this.owner?.host;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
return this.owner
|
|
68
|
+
get network() {
|
|
69
|
+
return this.owner?.network;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
#directory;
|
package/src/model.mjs
CHANGED
|
@@ -92,7 +92,7 @@ export class Owner extends Base {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
networkNamed(name) {
|
|
96
96
|
return this.#networks.get(name);
|
|
97
97
|
}
|
|
98
98
|
|
|
@@ -128,7 +128,7 @@ export class Owner extends Base {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
for (const name of asArray(destinationNetworks)) {
|
|
131
|
-
const other = this.
|
|
131
|
+
const other = this.networkNamed(name);
|
|
132
132
|
if (other) {
|
|
133
133
|
bridge.add(other);
|
|
134
134
|
other.bridge = bridge;
|
|
@@ -147,13 +147,13 @@ export class Owner extends Base {
|
|
|
147
147
|
this.info(bridgeToJSON(bridge));
|
|
148
148
|
for (const network of bridge) {
|
|
149
149
|
if (typeof network === "string") {
|
|
150
|
-
const other = this.
|
|
150
|
+
const other = this.networkNamed(network);
|
|
151
151
|
|
|
152
152
|
if (other) {
|
|
153
153
|
bridge.delete(network);
|
|
154
154
|
bridge.add(other);
|
|
155
155
|
other.bridge = bridge;
|
|
156
|
-
this.info("RESOLVE", network, other, bridgeToJSON(bridge));
|
|
156
|
+
//this.info("RESOLVE", network, other, bridgeToJSON(bridge));
|
|
157
157
|
} else {
|
|
158
158
|
this.error(`Unresolvabale bridge network`, network);
|
|
159
159
|
}
|
|
@@ -326,14 +326,6 @@ export class World extends Owner {
|
|
|
326
326
|
yield location.domain;
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
|
-
|
|
330
|
-
async location(name) {
|
|
331
|
-
return this.load(name, { type: Location });
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
async host(name) {
|
|
335
|
-
return this.load(name, { type: Host });
|
|
336
|
-
}
|
|
337
329
|
}
|
|
338
330
|
|
|
339
331
|
export class Location extends Owner {
|
|
@@ -443,12 +435,12 @@ export class Host extends Base {
|
|
|
443
435
|
|
|
444
436
|
static async prepareData(world, data) {
|
|
445
437
|
if (data.location) {
|
|
446
|
-
data.location = await world.
|
|
438
|
+
data.location = await world.load(data.location, { type: Location });
|
|
447
439
|
}
|
|
448
440
|
|
|
449
441
|
if (data.extends) {
|
|
450
442
|
data.extends = await Promise.all(
|
|
451
|
-
asArray(data.extends).map(e => world.
|
|
443
|
+
asArray(data.extends).map(e => world.load(e, { type: Host }))
|
|
452
444
|
);
|
|
453
445
|
}
|
|
454
446
|
|
|
@@ -745,7 +737,7 @@ export class NetworkInterface extends Base {
|
|
|
745
737
|
}
|
|
746
738
|
|
|
747
739
|
if (data.network) {
|
|
748
|
-
let network = owner.owner.
|
|
740
|
+
let network = owner.owner.networkNamed(data.network);
|
|
749
741
|
|
|
750
742
|
if (network) {
|
|
751
743
|
this.network = network;
|
|
@@ -790,7 +782,7 @@ export class NetworkInterface extends Base {
|
|
|
790
782
|
|
|
791
783
|
set network(networkOrName) {
|
|
792
784
|
if (!(networkOrName instanceof Network)) {
|
|
793
|
-
let network = this.owner.owner.
|
|
785
|
+
let network = this.owner.owner.networkNamed(networkOrName);
|
|
794
786
|
|
|
795
787
|
if (network) {
|
|
796
788
|
this.#network = network;
|
|
@@ -983,6 +975,7 @@ export class Service extends Base {
|
|
|
983
975
|
return [
|
|
984
976
|
...super.propertyNames,
|
|
985
977
|
"ipAddresses",
|
|
978
|
+
"addresses",
|
|
986
979
|
"port",
|
|
987
980
|
"protocol",
|
|
988
981
|
"alias",
|
package/types/base.d.mts
CHANGED
package/types/model.d.mts
CHANGED
|
@@ -9,7 +9,7 @@ export class Owner extends Base {
|
|
|
9
9
|
addHost(host: any): void;
|
|
10
10
|
service(filter: any): Promise<any>;
|
|
11
11
|
services(filter: any): AsyncGenerator<any, void, unknown>;
|
|
12
|
-
|
|
12
|
+
networkNamed(name: any): any;
|
|
13
13
|
networks(): AsyncGenerator<any, void, unknown>;
|
|
14
14
|
addNetwork(network: any): void;
|
|
15
15
|
addBridge(network: any, destinationNetworks: any): any;
|
|
@@ -40,8 +40,6 @@ export class World extends Owner {
|
|
|
40
40
|
locations(): AsyncGenerator<Location, void, unknown>;
|
|
41
41
|
hosts(): AsyncGenerator<Host, void, unknown>;
|
|
42
42
|
domains(): AsyncGenerator<any, void, unknown>;
|
|
43
|
-
location(name: any): Promise<any>;
|
|
44
|
-
host(name: any): Promise<any>;
|
|
45
43
|
#private;
|
|
46
44
|
}
|
|
47
45
|
export class Location extends Owner {
|