pmcf 1.75.0 → 1.76.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "1.75.0",
3
+ "version": "1.76.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/base.mjs CHANGED
@@ -268,6 +268,10 @@ export class Base {
268
268
  return this.owner?.domain;
269
269
  }
270
270
 
271
+ get domains() {
272
+ return this.owner?.domains || new Set();;
273
+ }
274
+
271
275
  get administratorEmail() {
272
276
  return this.owner?.administratorEmail;
273
277
  }
package/src/dns.mjs CHANGED
@@ -99,10 +99,6 @@ export class DNSService extends Base {
99
99
  }
100
100
  }
101
101
 
102
- get domains() {
103
- return [this.owner.domain];
104
- }
105
-
106
102
  async resolvedConfig() {
107
103
  return {
108
104
  DNS: serviceAddresses(this, {
@@ -113,7 +109,7 @@ export class DNSService extends Base {
113
109
  ...DNS_SERVICE_FILTER,
114
110
  priority: ">=10"
115
111
  }).join(" "),
116
- Domains: this.domains.join(" "),
112
+ Domains: [...this.domains].join(" "),
117
113
  DNSSEC: "no",
118
114
  MulticastDNS: "yes",
119
115
  LLMNR: "no"
@@ -217,7 +213,7 @@ async function generateZoneDefs(dns, targetDir) {
217
213
  );
218
214
  }
219
215
 
220
- console.log(`${nameService}`,nameService.ipAddressOrDomainName);
216
+ console.log(`${nameService}`, nameService.ipAddressOrDomainName);
221
217
  //console.log(dns.owner.fullName, domain, nameService.domainName, rname);
222
218
  const reverseZones = new Map();
223
219
 
@@ -229,7 +225,11 @@ async function generateZoneDefs(dns, targetDir) {
229
225
  `(${updates})`
230
226
  );
231
227
 
232
- const NSRecord = createRecord("@", "NS", fullName(nameService.ipAddressOrDomainName));
228
+ const NSRecord = createRecord(
229
+ "@",
230
+ "NS",
231
+ fullName(nameService.ipAddressOrDomainName)
232
+ );
233
233
 
234
234
  const zone = {
235
235
  id: domain,
@@ -268,65 +268,70 @@ async function generateZoneDefs(dns, targetDir) {
268
268
  networkInterface
269
269
  } of dns.owner.networkAddresses()) {
270
270
  const host = networkInterface.host;
271
+ const domainName = host.domainNameIn(domain);
271
272
 
272
- if (
273
- !addresses.has(address) &&
274
- (dns.hasLinkLocalAdresses || !isLinkLocal(address))
275
- ) {
276
- addresses.add(address);
273
+ if (domainName) {
274
+ if (
275
+ !addresses.has(address) &&
276
+ (dns.hasLinkLocalAdresses || !isLinkLocal(address))
277
+ ) {
278
+ addresses.add(address);
277
279
 
278
- zone.records.add(
279
- createRecord(
280
- fullName(host.domainName),
281
- isIPv6Address(address) ? "AAAA" : "A",
282
- normalizeIPAddress(address)
283
- )
284
- );
285
-
286
- if (subnet) {
287
- let reverseZone = reverseZones.get(subnet.address);
288
-
289
- if (!reverseZone) {
290
- const reverseArpa = reverseArpaAddress(subnet.prefix);
291
- reverseZone = {
292
- id: reverseArpa,
293
- type: "plain",
294
- file: `${dns.owner.name}/${reverseArpa}.zone`,
295
- records: new Set([SOARecord, NSRecord])
296
- };
297
- zones.push(reverseZone);
298
- reverseZones.set(subnet.address, reverseZone);
299
- }
300
- reverseZone.records.add(
280
+ zone.records.add(
301
281
  createRecord(
302
- fullName(reverseArpaAddress(address)),
303
- "PTR",
304
- fullName(host.domainName)
282
+ fullName(domainName),
283
+ isIPv6Address(address) ? "AAAA" : "A",
284
+ normalizeIPAddress(address)
305
285
  )
306
286
  );
307
- }
308
- }
309
-
310
- if (!hosts.has(host)) {
311
- hosts.add(host);
312
- for (const service of host.findServices()) {
313
- if (service.master && service.alias) {
314
- zone.records.add(
315
- createRecord(service.alias, "CNAME", fullName(host.domainName))
316
- );
287
+ if (subnet && host.domain === domain) {
288
+ let reverseZone = reverseZones.get(subnet.address);
289
+
290
+ if (!reverseZone) {
291
+ const reverseArpa = reverseArpaAddress(subnet.prefix);
292
+ reverseZone = {
293
+ id: reverseArpa,
294
+ type: "plain",
295
+ file: `${dns.owner.name}/${reverseArpa}.zone`,
296
+ records: new Set([SOARecord, NSRecord])
297
+ };
298
+ zones.push(reverseZone);
299
+ reverseZones.set(subnet.address, reverseZone);
300
+ }
301
+
302
+ for (const domainName of host.domainNames) {
303
+ reverseZone.records.add(
304
+ createRecord(
305
+ fullName(reverseArpaAddress(address)),
306
+ "PTR",
307
+ fullName(domainName)
308
+ )
309
+ );
310
+ }
317
311
  }
312
+ }
318
313
 
319
- if (dns.hasSVRRecords && service.srvPrefix) {
320
- zone.records.add(
321
- createRecord(
322
- fullName(`${service.srvPrefix}.${host.domainName}`),
323
- "SRV",
324
- service.priority,
325
- service.weight,
326
- service.port,
327
- fullName(host.domainName)
328
- )
329
- );
314
+ if (!hosts.has(host)) {
315
+ hosts.add(host);
316
+ for (const service of host.findServices()) {
317
+ if (service.master && service.alias) {
318
+ zone.records.add(
319
+ createRecord(service.alias, "CNAME", fullName(domainName))
320
+ );
321
+ }
322
+
323
+ if (dns.hasSVRRecords && service.srvPrefix) {
324
+ zone.records.add(
325
+ createRecord(
326
+ fullName(`${service.srvPrefix}.${domainName}`),
327
+ "SRV",
328
+ service.priority,
329
+ service.weight,
330
+ service.port,
331
+ fullName(host.domainName)
332
+ )
333
+ );
334
+ }
330
335
  }
331
336
  }
332
337
  }
package/src/host.mjs CHANGED
@@ -12,7 +12,8 @@ import {
12
12
  isIPv6Address,
13
13
  normalizeIPAddress,
14
14
  formatCIDR,
15
- hasWellKnownSubnet
15
+ hasWellKnownSubnet,
16
+ domainFromDominName
16
17
  } from "./utils.mjs";
17
18
  import { objectFilter } from "./filter.mjs";
18
19
  import { addType, types } from "./types.mjs";
@@ -36,7 +37,7 @@ const HostTypeDefinition = {
36
37
  writeable: true
37
38
  },
38
39
  services: { type: "service", collection: true, writeable: true },
39
- aliases: { type: "string", collection: false, writeable: true },
40
+ aliases: { type: "string", collection: true, writeable: true },
40
41
 
41
42
  os: { type: "string", collection: false, writeable: true },
42
43
  "machine-id": { type: "string", collection: false, writeable: true },
@@ -255,11 +256,7 @@ export class Host extends Base {
255
256
 
256
257
  get domains() {
257
258
  const domains = new Set(
258
- [...this.aliases].map(n => {
259
- const p = n.split(".");
260
- p.shift();
261
- return p.join(".");
262
- })
259
+ [...this.aliases].map(n => domainFromDominName(n, this.domain))
263
260
  );
264
261
  domains.add(this.domain);
265
262
  return domains;
@@ -275,6 +272,14 @@ export class Host extends Base {
275
272
  return domain ? hostName + "." + domain : hostName;
276
273
  }
277
274
 
275
+ domainNameIn(domain) {
276
+ for (const domainName of this.domainNames) {
277
+ if (domain == domainFromDominName(domainName)) {
278
+ return domainName;
279
+ }
280
+ }
281
+ }
282
+
278
283
  get host() {
279
284
  return this;
280
285
  }
package/src/owner.mjs CHANGED
@@ -356,9 +356,13 @@ export class Owner extends Base {
356
356
  return this.#domain || this.owner?.domain;
357
357
  }
358
358
 
359
- *domains() {
360
- for (const location of this.locations()) {
361
- yield location.domain;
359
+ get domains() {
360
+ let domains = new Set();
361
+
362
+ for (const object of this.hosts()) {
363
+ domains = domains.union(object.domains);
362
364
  }
365
+
366
+ return domains;
363
367
  }
364
368
  }
package/src/utils.mjs CHANGED
@@ -1,10 +1,23 @@
1
1
  import { writeFile, mkdir } from "node:fs/promises";
2
2
  import { join, dirname, basename } from "node:path";
3
3
 
4
+ export function domainFromDominName(domainName, defaultDomain) {
5
+ const dcs = domainName.split(".");
6
+
7
+ if (dcs.length > 1) {
8
+ dcs.shift();
9
+ return dcs.join(".");
10
+ }
11
+
12
+ return defaultDomain;
13
+ }
14
+
4
15
  export async function writeLines(dir, name, lines) {
5
- switch(typeof lines) {
6
- case "undefined": return;
7
- case "string": lines = [lines];
16
+ switch (typeof lines) {
17
+ case "undefined":
18
+ return;
19
+ case "string":
20
+ lines = [lines];
8
21
  }
9
22
 
10
23
  const full = join(dir, name);
package/types/base.d.mts CHANGED
@@ -58,6 +58,7 @@ export class Base {
58
58
  get host(): any;
59
59
  get network(): any;
60
60
  get domain(): any;
61
+ get domains(): any;
61
62
  get administratorEmail(): any;
62
63
  get locales(): any;
63
64
  get country(): any;
package/types/dns.d.mts CHANGED
@@ -83,7 +83,6 @@ export class DNSService extends Base {
83
83
  get trusted(): any[];
84
84
  set forwardsTo(value: any[]);
85
85
  get forwardsTo(): any[];
86
- get domains(): any[];
87
86
  resolvedConfig(): Promise<{
88
87
  DNS: string;
89
88
  FallbackDNS: string;
package/types/host.d.mts CHANGED
@@ -188,6 +188,7 @@ export class Host extends Base {
188
188
  get domains(): Set<any>;
189
189
  get domainNames(): any[];
190
190
  get domainName(): string;
191
+ domainNameIn(domain: any): any;
191
192
  get host(): this;
192
193
  named(name: any): any;
193
194
  set networkInterfaces(networkInterface: Map<any, any>);
package/types/owner.d.mts CHANGED
@@ -220,7 +220,7 @@ export class Owner extends Base {
220
220
  get administratorEmail(): any;
221
221
  set domain(value: any);
222
222
  get domain(): any;
223
- domains(): Generator<any, void, unknown>;
223
+ get domains(): Set<any>;
224
224
  #private;
225
225
  }
226
226
  import { Base } from "./base.mjs";
package/types/utils.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ export function domainFromDominName(domainName: any, defaultDomain: any): any;
1
2
  export function writeLines(dir: any, name: any, lines: any): Promise<void>;
2
3
  export function sectionLines(sectionName: any, values: any): string[];
3
4
  export function bridgeToJSON(bridge: any): any[];