pmcf 1.31.2 → 1.32.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 +28 -20
- package/package.json +1 -1
- package/src/dns.mjs +10 -1
- package/src/model.mjs +6 -1
- package/src/owner.mjs +48 -15
- package/types/cluster.d.mts +1 -0
- package/types/dns.d.mts +2 -0
- package/types/model.d.mts +1 -0
- package/types/owner.d.mts +5 -1
package/bin/pmcf-named-defs
CHANGED
|
@@ -91,6 +91,8 @@ async function generateNamedDefs(owner, targetDir) {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
const hosts = new Set();
|
|
95
|
+
|
|
94
96
|
for await (const {
|
|
95
97
|
address,
|
|
96
98
|
networkInterface
|
|
@@ -104,25 +106,29 @@ async function generateNamedDefs(owner, targetDir) {
|
|
|
104
106
|
)
|
|
105
107
|
);
|
|
106
108
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
service.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
109
|
+
if (!hosts.has(host)) {
|
|
110
|
+
hosts.add(host);
|
|
111
|
+
for (const service of host.services()) {
|
|
112
|
+
//console.log(service.name);
|
|
113
|
+
if (service.master && service.alias) {
|
|
114
|
+
zone.records.add(
|
|
115
|
+
createRecord(service.alias, "CNAME", `${host.domainName}.`)
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (dns.hasSVRRecords && service.srvPrefix) {
|
|
120
|
+
zone.records.add(
|
|
121
|
+
createRecord(
|
|
122
|
+
`${service.srvPrefix}.${host.domainName}.`,
|
|
123
|
+
"SRV",
|
|
124
|
+
`${String(service.priority).padStart(4)} ${String(
|
|
125
|
+
service.weight
|
|
126
|
+
).padStart(3)} ${String(service.port).padStart(5)} ${
|
|
127
|
+
host.domainName
|
|
128
|
+
}.`
|
|
129
|
+
)
|
|
130
|
+
);
|
|
131
|
+
}
|
|
126
132
|
}
|
|
127
133
|
}
|
|
128
134
|
|
|
@@ -141,7 +147,9 @@ async function generateNamedDefs(owner, targetDir) {
|
|
|
141
147
|
|
|
142
148
|
const zoneConfig = [];
|
|
143
149
|
|
|
144
|
-
|
|
150
|
+
if (dns.hasCatalog) {
|
|
151
|
+
zones.push(catalogZone);
|
|
152
|
+
}
|
|
145
153
|
|
|
146
154
|
for (const zone of zones) {
|
|
147
155
|
if (zone !== catalogZone) {
|
package/package.json
CHANGED
package/src/dns.mjs
CHANGED
|
@@ -5,6 +5,8 @@ export class DNSService extends Base {
|
|
|
5
5
|
allowedUpdates = [];
|
|
6
6
|
recordTTL = "1W";
|
|
7
7
|
soaUpdates = [36000, 72000, 600000, 60000];
|
|
8
|
+
hasSVRRecords = true;
|
|
9
|
+
hasCatalog = true;
|
|
8
10
|
|
|
9
11
|
forwardsTo = [];
|
|
10
12
|
|
|
@@ -34,7 +36,14 @@ export class DNSService extends Base {
|
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
get propertyNames() {
|
|
37
|
-
return [
|
|
39
|
+
return [
|
|
40
|
+
"recordTTL",
|
|
41
|
+
"soaUpdates",
|
|
42
|
+
"hasSVRRecords",
|
|
43
|
+
"hasCatalog",
|
|
44
|
+
"forwardsTo",
|
|
45
|
+
"allowedUpdates"
|
|
46
|
+
];
|
|
38
47
|
}
|
|
39
48
|
|
|
40
49
|
async resolvedConfig() {
|
package/src/model.mjs
CHANGED
|
@@ -468,7 +468,7 @@ export class NetworkInterface extends Base {
|
|
|
468
468
|
|
|
469
469
|
get ipAddressesWithPrefixLength() {
|
|
470
470
|
return this.#ipAddresses.map(a =>
|
|
471
|
-
isIPv4Address(a) ? `${a}/${this.
|
|
471
|
+
isIPv4Address(a) ? `${a}/${this.prefixLength}` : a
|
|
472
472
|
);
|
|
473
473
|
}
|
|
474
474
|
|
|
@@ -480,6 +480,11 @@ export class NetworkInterface extends Base {
|
|
|
480
480
|
return this.#ipAddresses.filter(a => isIPv6Address(a));
|
|
481
481
|
}
|
|
482
482
|
|
|
483
|
+
get prefixLength()
|
|
484
|
+
{
|
|
485
|
+
return this.network?.prefixLength;
|
|
486
|
+
}
|
|
487
|
+
|
|
483
488
|
get network() {
|
|
484
489
|
return this.#network;
|
|
485
490
|
}
|
package/src/owner.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { asArray
|
|
1
|
+
import { asArray } from "./utils.mjs";
|
|
2
2
|
import { Base } from "./base.mjs";
|
|
3
3
|
import { DNSService } from "./dns.mjs";
|
|
4
4
|
|
|
@@ -14,18 +14,33 @@ export class Owner extends Base {
|
|
|
14
14
|
return "owner";
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
constructor(owner, data) {
|
|
17
|
+
constructor(owner, data={}) {
|
|
18
18
|
super(owner, data);
|
|
19
19
|
|
|
20
20
|
let dns;
|
|
21
|
-
if (data
|
|
21
|
+
if (data.dns) {
|
|
22
22
|
dns = data.dns;
|
|
23
23
|
delete data.dns;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
this.#dns = new DNSService(this, dns);
|
|
27
27
|
|
|
28
|
-
if (data
|
|
28
|
+
if (data.administratorEmail) {
|
|
29
|
+
this.#administratorEmail = data.administratorEmail;
|
|
30
|
+
delete data.administratorEmail;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (data.domain) {
|
|
34
|
+
this.domain = data.domain;
|
|
35
|
+
delete data.domain;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (data.ntp) {
|
|
39
|
+
this.ntp = data.ntp;
|
|
40
|
+
delete data.ntp;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (data.networks) {
|
|
29
44
|
const networks = data.networks;
|
|
30
45
|
delete data.networks;
|
|
31
46
|
|
|
@@ -34,7 +49,6 @@ export class Owner extends Base {
|
|
|
34
49
|
new Network(this, data);
|
|
35
50
|
}
|
|
36
51
|
}
|
|
37
|
-
Object.assign(this, data);
|
|
38
52
|
|
|
39
53
|
owner?.addObject(this);
|
|
40
54
|
}
|
|
@@ -246,9 +260,9 @@ export class Network extends Owner {
|
|
|
246
260
|
kind;
|
|
247
261
|
scope;
|
|
248
262
|
metric;
|
|
249
|
-
ipv4;
|
|
250
263
|
subnet;
|
|
251
264
|
bridge;
|
|
265
|
+
#ipAddresses = [];
|
|
252
266
|
|
|
253
267
|
static get typeName() {
|
|
254
268
|
return "network";
|
|
@@ -257,6 +271,11 @@ export class Network extends Owner {
|
|
|
257
271
|
constructor(owner, data) {
|
|
258
272
|
super(owner, data);
|
|
259
273
|
|
|
274
|
+
if (data.ipAddresses) {
|
|
275
|
+
this.#ipAddresses.push(...asArray(data.ipAddresses));
|
|
276
|
+
delete data.ipAddresses;
|
|
277
|
+
}
|
|
278
|
+
|
|
260
279
|
let bridge;
|
|
261
280
|
if (data.bridge) {
|
|
262
281
|
bridge = data.bridge;
|
|
@@ -277,7 +296,7 @@ export class Network extends Owner {
|
|
|
277
296
|
subnet.networks.add(this);
|
|
278
297
|
}
|
|
279
298
|
|
|
280
|
-
owner.addObject(this);
|
|
299
|
+
//owner.addObject(this);
|
|
281
300
|
|
|
282
301
|
this.bridge = owner.addBridge(this, bridge);
|
|
283
302
|
}
|
|
@@ -289,18 +308,32 @@ export class Network extends Owner {
|
|
|
289
308
|
return super.networkNamed(name);
|
|
290
309
|
}
|
|
291
310
|
|
|
311
|
+
set ipAddresses(value) {
|
|
312
|
+
this.#ipAddresses = asArray(value);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
get ipAddresses() {
|
|
316
|
+
return this.#ipAddresses;
|
|
317
|
+
}
|
|
318
|
+
|
|
292
319
|
get prefixLength() {
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
|
|
320
|
+
for (const a of this.#ipAddresses) {
|
|
321
|
+
const m = a.match(/\/(\d+)$/);
|
|
322
|
+
if (m) {
|
|
323
|
+
return parseInt(m[1]);
|
|
324
|
+
}
|
|
296
325
|
}
|
|
326
|
+
|
|
327
|
+
this.error("no prefixLength",this.#ipAddresses);
|
|
297
328
|
}
|
|
298
329
|
|
|
299
330
|
get subnetAddress() {
|
|
300
|
-
|
|
301
|
-
const [addr, bits] =
|
|
302
|
-
|
|
303
|
-
|
|
331
|
+
for (const a of this.#ipAddresses) {
|
|
332
|
+
const [addr, bits] = a.split(/\//);
|
|
333
|
+
if (bits) {
|
|
334
|
+
const parts = addr.split(/\./);
|
|
335
|
+
return parts.slice(0, bits / 8).join(".");
|
|
336
|
+
}
|
|
304
337
|
}
|
|
305
338
|
}
|
|
306
339
|
|
|
@@ -308,7 +341,7 @@ export class Network extends Owner {
|
|
|
308
341
|
return [
|
|
309
342
|
...super.propertyNames,
|
|
310
343
|
"kind",
|
|
311
|
-
"
|
|
344
|
+
"ipAddresses",
|
|
312
345
|
"prefixLength",
|
|
313
346
|
"scope",
|
|
314
347
|
"metric",
|
package/types/cluster.d.mts
CHANGED
package/types/dns.d.mts
CHANGED
package/types/model.d.mts
CHANGED
package/types/owner.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export class Owner extends Base {
|
|
2
|
+
constructor(owner: any, data?: {});
|
|
2
3
|
domain: any;
|
|
3
4
|
ntp: {
|
|
4
5
|
servers: any[];
|
|
@@ -29,14 +30,17 @@ export class Owner extends Base {
|
|
|
29
30
|
#private;
|
|
30
31
|
}
|
|
31
32
|
export class Network extends Owner {
|
|
33
|
+
constructor(owner: any, data: any);
|
|
32
34
|
kind: any;
|
|
33
35
|
scope: any;
|
|
34
36
|
metric: any;
|
|
35
|
-
ipv4: any;
|
|
36
37
|
subnet: any;
|
|
37
38
|
bridge: any;
|
|
39
|
+
set ipAddresses(value: any[]);
|
|
40
|
+
get ipAddresses(): any[];
|
|
38
41
|
get prefixLength(): number;
|
|
39
42
|
get subnetAddress(): any;
|
|
43
|
+
#private;
|
|
40
44
|
}
|
|
41
45
|
export class Subnet extends Base {
|
|
42
46
|
networks: Set<any>;
|