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.
@@ -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
- for (const service of host.services()) {
108
- if (service.master && service.alias) {
109
- zone.records.add(
110
- createRecord(service.alias, "CNAME", `${host.domainName}.`)
111
- );
112
- }
113
-
114
- if (service.srvPrefix) {
115
- zone.records.add(
116
- createRecord(
117
- `${service.srvPrefix}.${host.domainName}.`,
118
- "SRV",
119
- `${String(service.priority).padStart(4)} ${String(
120
- service.weight
121
- ).padStart(3)} ${String(service.port).padStart(5)} ${
122
- host.domainName
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
- zones.push(catalogZone);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "1.31.2",
3
+ "version": "1.32.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
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 ["recordTTL", "soaUpdates", "forwardsTo", "allowedUpdates"];
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.network.prefixLength}` : a
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, bridgeToJSON } from "./utils.mjs";
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?.dns) {
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?.networks) {
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 m = this.ipv4?.match(/\/(\d+)$/);
294
- if (m) {
295
- return parseInt(m[1]);
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
- if (this.ipv4) {
301
- const [addr, bits] = this.ipv4.split(/\//);
302
- const parts = addr.split(/\./);
303
- return parts.slice(0, bits / 8).join(".");
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
- "ipv4",
344
+ "ipAddresses",
312
345
  "prefixLength",
313
346
  "scope",
314
347
  "metric",
@@ -1,3 +1,4 @@
1
1
  export class Cluster extends Owner {
2
+ constructor(owner: any, data: any);
2
3
  }
3
4
  import { Owner } from "./owner.mjs";
package/types/dns.d.mts CHANGED
@@ -2,6 +2,8 @@ export class DNSService extends Base {
2
2
  allowedUpdates: any[];
3
3
  recordTTL: string;
4
4
  soaUpdates: number[];
5
+ hasSVRRecords: boolean;
6
+ hasCatalog: boolean;
5
7
  forwardsTo: any[];
6
8
  services(): AsyncGenerator<any, void, any>;
7
9
  get domains(): any[];
package/types/model.d.mts CHANGED
@@ -59,6 +59,7 @@ export class NetworkInterface extends Base {
59
59
  get ipAddressesWithPrefixLength(): any[];
60
60
  get ipv4Addresses(): any[];
61
61
  get ipv6Addresses(): any[];
62
+ get prefixLength(): any;
62
63
  get scope(): any;
63
64
  get metric(): any;
64
65
  get ssid(): any;
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>;