pmcf 1.38.3 → 1.40.0
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-named-defs +12 -2
- package/package.json +2 -2
- package/src/model.mjs +11 -0
- package/src/owner.mjs +43 -26
- package/types/owner.d.mts +4 -3
package/bin/pmcf-named-defs
CHANGED
|
@@ -58,7 +58,17 @@ async function generateNamedDefs(owner, targetDir) {
|
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
const subnets = [
|
|
62
|
+
...new Set([...owner.networks()].map(n => [...n.subnets()]).flat())
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
console.log(
|
|
66
|
+
owner.fullName,
|
|
67
|
+
domain,
|
|
68
|
+
nameserver?.hostName,
|
|
69
|
+
rname,
|
|
70
|
+
subnets.map(s => `${s.owner.name}/${s.name}`)
|
|
71
|
+
);
|
|
62
72
|
|
|
63
73
|
const SOARecord = createRecord(
|
|
64
74
|
"@",
|
|
@@ -87,7 +97,7 @@ async function generateNamedDefs(owner, targetDir) {
|
|
|
87
97
|
};
|
|
88
98
|
zones.push(zone);
|
|
89
99
|
|
|
90
|
-
for (const subnet of
|
|
100
|
+
for (const subnet of subnets) {
|
|
91
101
|
if (!subnet.isLinkLocal && subnet.prefix) {
|
|
92
102
|
const reverseArpa = reverseArpaAddress(subnet.prefix);
|
|
93
103
|
const reverseZone = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmcf",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.40.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"pacc": "^3.3.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@types/node": "^22.13.
|
|
46
|
+
"@types/node": "^22.13.2",
|
|
47
47
|
"ava": "^6.2.0",
|
|
48
48
|
"c8": "^10.1.3",
|
|
49
49
|
"documentation": "^14.0.3",
|
package/src/model.mjs
CHANGED
|
@@ -32,6 +32,17 @@ export class Location extends Owner {
|
|
|
32
32
|
get network() {
|
|
33
33
|
return [...this.typeList("network")][0] || super.network;
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
*subnets() {
|
|
38
|
+
// yield* super.subnets();
|
|
39
|
+
|
|
40
|
+
for(const network of this.networks()) {
|
|
41
|
+
// console.log(network.toString());
|
|
42
|
+
yield* network.typeList("subnet");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
*/
|
|
35
46
|
}
|
|
36
47
|
|
|
37
48
|
export class Root extends Location {
|
package/src/owner.mjs
CHANGED
|
@@ -105,7 +105,6 @@ export class Owner extends Base {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
addObject(object) {
|
|
108
|
-
this.owner?.addObject(object);
|
|
109
108
|
this._addObject(object.typeName, object.fullName, object);
|
|
110
109
|
}
|
|
111
110
|
|
|
@@ -153,34 +152,17 @@ export class Owner extends Base {
|
|
|
153
152
|
}
|
|
154
153
|
|
|
155
154
|
subnetNamed(name) {
|
|
156
|
-
return this.typeNamed("subnet", name)
|
|
155
|
+
return this.typeNamed("subnet", name);
|
|
157
156
|
}
|
|
158
157
|
|
|
159
|
-
*
|
|
158
|
+
*subnets() {
|
|
160
159
|
if (this.owner) {
|
|
161
160
|
yield* this.owner.subnets();
|
|
162
|
-
} else {
|
|
163
|
-
yield* this.typeList("subnet");
|
|
164
161
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
subnets() {
|
|
168
|
-
if (this !== this.location) {
|
|
169
|
-
return this.location.subnets();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return this.typeList("subnet");
|
|
162
|
+
yield* this.typeList("subnet");
|
|
173
163
|
}
|
|
174
164
|
|
|
175
165
|
addSubnet(address) {
|
|
176
|
-
if (address instanceof Subnet) {
|
|
177
|
-
return address;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (this !== this.location) {
|
|
181
|
-
return this.location.addSubnet(address);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
166
|
const { cidr } = normalizeCIDR(address);
|
|
185
167
|
|
|
186
168
|
if (cidr) {
|
|
@@ -302,8 +284,8 @@ export class Network extends Owner {
|
|
|
302
284
|
kind;
|
|
303
285
|
scope;
|
|
304
286
|
metric;
|
|
305
|
-
bridge;
|
|
306
287
|
gateway;
|
|
288
|
+
#bridge;
|
|
307
289
|
|
|
308
290
|
static get typeName() {
|
|
309
291
|
return "network";
|
|
@@ -317,9 +299,8 @@ export class Network extends Owner {
|
|
|
317
299
|
delete data.subnets;
|
|
318
300
|
}
|
|
319
301
|
|
|
320
|
-
let bridge;
|
|
321
302
|
if (data.bridge) {
|
|
322
|
-
bridge = data.bridge;
|
|
303
|
+
this.bridge = owner.addBridge(this, data.bridge);
|
|
323
304
|
delete data.bridge;
|
|
324
305
|
}
|
|
325
306
|
|
|
@@ -328,8 +309,6 @@ export class Network extends Owner {
|
|
|
328
309
|
if (typeof this.gateway === "string") {
|
|
329
310
|
this.finalize(() => (this.gateway = this.owner.hostNamed(this.gateway)));
|
|
330
311
|
}
|
|
331
|
-
|
|
332
|
-
this.bridge = owner.addBridge(this, bridge);
|
|
333
312
|
}
|
|
334
313
|
|
|
335
314
|
get network() {
|
|
@@ -350,6 +329,40 @@ export class Network extends Owner {
|
|
|
350
329
|
}
|
|
351
330
|
}
|
|
352
331
|
|
|
332
|
+
get bridge() {
|
|
333
|
+
return this.#bridge;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
set bridge(bridge) {
|
|
337
|
+
for (const network of bridge) {
|
|
338
|
+
if (network instanceof Network && network !== this) {
|
|
339
|
+
for (const subnet of this.subnets()) {
|
|
340
|
+
for (const otherSubnet of network.subnets()) {
|
|
341
|
+
if (
|
|
342
|
+
subnet !== otherSubnet &&
|
|
343
|
+
subnet.address === otherSubnet.address
|
|
344
|
+
) {
|
|
345
|
+
/*console.log(
|
|
346
|
+
"SHARE SUBNETS",
|
|
347
|
+
subnet.owner.toString(),
|
|
348
|
+
otherSubnet.owner.toString()
|
|
349
|
+
);*/
|
|
350
|
+
|
|
351
|
+
otherSubnet.owner.addObject(subnet);
|
|
352
|
+
for (const n of otherSubnet.networks) {
|
|
353
|
+
subnet.networks.add(n);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
//console.log(subnet.toString(),[...subnet.networks].map(n=>n.toString()));
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
this.#bridge = bridge;
|
|
364
|
+
}
|
|
365
|
+
|
|
353
366
|
get propertyNames() {
|
|
354
367
|
return [
|
|
355
368
|
...super.propertyNames,
|
|
@@ -387,6 +400,10 @@ export class Subnet extends Base {
|
|
|
387
400
|
owner.addObject(this);
|
|
388
401
|
}
|
|
389
402
|
|
|
403
|
+
get fullName() {
|
|
404
|
+
return this.name;
|
|
405
|
+
}
|
|
406
|
+
|
|
390
407
|
matchesAddress(address) {
|
|
391
408
|
return address.startsWith(this.prefix);
|
|
392
409
|
}
|
package/types/owner.d.mts
CHANGED
|
@@ -20,8 +20,7 @@ export class Owner extends Base {
|
|
|
20
20
|
networkNamed(name: any): any;
|
|
21
21
|
networks(): any;
|
|
22
22
|
subnetNamed(name: any): any;
|
|
23
|
-
|
|
24
|
-
subnets(): any;
|
|
23
|
+
subnets(): Generator<any, void, any>;
|
|
25
24
|
addSubnet(address: any): any;
|
|
26
25
|
subnetForAddress(address: any): any;
|
|
27
26
|
clusterNamed(name: any): any;
|
|
@@ -37,10 +36,12 @@ export class Network extends Owner {
|
|
|
37
36
|
kind: any;
|
|
38
37
|
scope: any;
|
|
39
38
|
metric: any;
|
|
40
|
-
bridge: any;
|
|
41
39
|
gateway: any;
|
|
40
|
+
set bridge(bridge: any);
|
|
41
|
+
get bridge(): any;
|
|
42
42
|
get network(): this;
|
|
43
43
|
addSubnets(value: any): void;
|
|
44
|
+
#private;
|
|
44
45
|
}
|
|
45
46
|
export class Subnet extends Base {
|
|
46
47
|
networks: Set<any>;
|