pmcf 1.93.0 → 1.94.1

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.93.0",
3
+ "version": "1.94.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -43,7 +43,7 @@
43
43
  "pkg-dir": "^8.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@types/node": "^22.13.10",
46
+ "@types/node": "^22.13.11",
47
47
  "ava": "^6.2.0",
48
48
  "c8": "^10.1.3",
49
49
  "documentation": "^14.0.3",
package/src/dns.mjs CHANGED
@@ -288,7 +288,7 @@ async function generateZoneDefs(dns, packageData) {
288
288
  };
289
289
  configs.push(config);
290
290
 
291
- const locationRecord = DNSRecord("location", "TXT", dns.location.name)
291
+ const locationRecord = DNSRecord("location", "TXT", dns.location.name);
292
292
 
293
293
  const zone = {
294
294
  id: domain,
@@ -322,68 +322,65 @@ async function generateZoneDefs(dns, packageData) {
322
322
  for await (const {
323
323
  address,
324
324
  subnet,
325
- networkInterface
325
+ networkInterface,
326
+ domainName
326
327
  } of dns.owner.networkAddresses()) {
327
328
  const host = networkInterface.host;
328
- const domainName = host.domainNameIn(domain);
329
+ if (
330
+ !addresses.has(address) &&
331
+ (dns.hasLinkLocalAdresses || !isLinkLocal(address))
332
+ ) {
333
+ addresses.add(address);
329
334
 
330
- if (domainName) {
331
- if (
332
- !addresses.has(address) &&
333
- (dns.hasLinkLocalAdresses || !isLinkLocal(address))
334
- ) {
335
- addresses.add(address);
335
+ zone.records.add(
336
+ DNSRecord(
337
+ dnsFullName(domainName),
338
+ isIPv6Address(address) ? "AAAA" : "A",
339
+ normalizeIPAddress(address)
340
+ )
341
+ );
342
+ if (subnet && host.domain === domain) {
343
+ let reverseZone = reverseZones.get(subnet.address);
344
+
345
+ if (!reverseZone) {
346
+ const reverseArpa = reverseArpaAddress(subnet.prefix);
347
+ reverseZone = {
348
+ id: reverseArpa,
349
+ type: "plain",
350
+ file: `${ownerName}/${reverseArpa}.zone`,
351
+ records: new Set([SOARecord, NSRecord])
352
+ };
353
+ config.zones.push(reverseZone);
354
+ reverseZones.set(subnet.address, reverseZone);
355
+ }
336
356
 
337
- zone.records.add(
338
- DNSRecord(
339
- dnsFullName(domainName),
340
- isIPv6Address(address) ? "AAAA" : "A",
341
- normalizeIPAddress(address)
342
- )
343
- );
344
- if (subnet && host.domain === domain) {
345
- let reverseZone = reverseZones.get(subnet.address);
346
-
347
- if (!reverseZone) {
348
- const reverseArpa = reverseArpaAddress(subnet.prefix);
349
- reverseZone = {
350
- id: reverseArpa,
351
- type: "plain",
352
- file: `${ownerName}/${reverseArpa}.zone`,
353
- records: new Set([SOARecord, NSRecord])
354
- };
355
- config.zones.push(reverseZone);
356
- reverseZones.set(subnet.address, reverseZone);
357
- }
358
-
359
- for (const domainName of host.domainNames) {
360
- reverseZone.records.add(
361
- DNSRecord(
362
- dnsFullName(reverseArpaAddress(address)),
363
- "PTR",
364
- dnsFullName(domainName)
365
- )
366
- );
367
- }
357
+ for (const domainName of host.domainNames) {
358
+ reverseZone.records.add(
359
+ DNSRecord(
360
+ dnsFullName(reverseArpaAddress(address)),
361
+ "PTR",
362
+ dnsFullName(domainName)
363
+ )
364
+ );
368
365
  }
369
366
  }
367
+ }
370
368
 
371
- if (!hosts.has(host)) {
372
- hosts.add(host);
369
+ if (!hosts.has(host)) {
370
+ hosts.add(host);
373
371
 
374
- for (const foreignDomainName of host.foreignDomainNames) {
375
- zone.records.add(
376
- DNSRecord("external", "PTR", dnsFullName(foreignDomainName))
377
- );
378
- }
372
+ for (const foreignDomainName of host.foreignDomainNames) {
373
+ zone.records.add(
374
+ DNSRecord("external", "PTR", dnsFullName(foreignDomainName))
375
+ );
376
+ }
379
377
 
380
- for (const service of host.findServices()) {
381
- for (const record of service.dnsRecordsForDomainName(
382
- domainName,
383
- dns.hasSVRRecords
384
- )) {
385
- zone.records.add(record);
386
- }
378
+ for (const service of host.findServices()) {
379
+ for (const record of service.dnsRecordsForDomainName(
380
+ domainName,
381
+ dns.hasSVRRecords
382
+ )) {
383
+ zone.records.add(record);
387
384
  }
388
385
  }
389
386
  }
package/src/host.mjs CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  } from "./utils.mjs";
19
19
  import { objectFilter } from "./filter.mjs";
20
20
  import { addType, types } from "./types.mjs";
21
- import { loadHooks } from "./hooks.mjs";
21
+ import { loadHooks } from "./hooks.mjs";
22
22
  import {
23
23
  generateNetworkDefs,
24
24
  generateMachineInfo,
@@ -187,7 +187,7 @@ export class Host extends Base {
187
187
  }
188
188
 
189
189
  get aliases() {
190
- return this.#aliases;
190
+ return this.extends.reduce((a, c) => a.union(c.aliases), this.#aliases);
191
191
  }
192
192
 
193
193
  set extends(value) {
@@ -282,8 +282,12 @@ export class Host extends Base {
282
282
  }
283
283
 
284
284
  get domainNames() {
285
- return [this.hostName, ...this.aliases].map(n =>
286
- domainName(n, this.domain)
285
+ return new Set(
286
+ [
287
+ ...[...this.networkInterfaces.values()].map(ni => ni.domainName),
288
+ this.hostName,
289
+ ...this.aliases
290
+ ].map(n => domainName(n, this.domain))
287
291
  );
288
292
  }
289
293
 
@@ -291,10 +295,10 @@ export class Host extends Base {
291
295
  return domainName(this.hostName, this.domain);
292
296
  }
293
297
 
294
- domainNameIn(domain) {
298
+ *domainNamesIn(domain) {
295
299
  for (const domainName of this.domainNames) {
296
- if (domain == domainFromDominName(domainName)) {
297
- return domainName;
300
+ if (domain === domainFromDominName(domainName)) {
301
+ yield domainName;
298
302
  }
299
303
  }
300
304
  }
@@ -361,10 +365,10 @@ export class Host extends Base {
361
365
 
362
366
  *networkAddresses() {
363
367
  for (const networkInterface of this.networkInterfaces.values()) {
364
- for (const [address, subnet, domainName] of networkInterface.ipAddresses) {
368
+ for (const [address, subnet] of networkInterface.ipAddresses) {
365
369
  yield {
366
370
  networkInterface,
367
- domainName,
371
+ domainName: networkInterface.domainName,
368
372
  address,
369
373
  subnet
370
374
  };
@@ -397,9 +401,7 @@ export class Host extends Base {
397
401
  async *preparePackages(dir) {
398
402
  const packageData = {
399
403
  dir,
400
- sources: [
401
- new FileContentProvider(dir + "/")[Symbol.asyncIterator]()
402
- ],
404
+ sources: [new FileContentProvider(dir + "/")[Symbol.asyncIterator]()],
403
405
  outputs: this.outputs,
404
406
  properties: {
405
407
  name: `${this.typeName}-${this.owner.name}-${this.name}`,
@@ -412,7 +414,8 @@ export class Host extends Base {
412
414
  provides: [...this.provides],
413
415
  replaces: [`mf-${this.hostName}`, ...this.replaces],
414
416
  backup: "root/.ssh/known_hosts",
415
- hooks: await loadHooks({},
417
+ hooks: await loadHooks(
418
+ {},
416
419
  new URL("host.install", import.meta.url).pathname
417
420
  )
418
421
  }
@@ -421,10 +424,7 @@ export class Host extends Base {
421
424
  await generateNetworkDefs(this, packageData);
422
425
  await generateMachineInfo(this, packageData);
423
426
  await copySshKeys(this, packageData);
424
- await generateKnownHosts(
425
- this.owner.hosts(),
426
- join(dir, "root", ".ssh")
427
- );
427
+ await generateKnownHosts(this.owner.hosts(), join(dir, "root", ".ssh"));
428
428
 
429
429
  yield packageData;
430
430
  }
@@ -545,9 +545,10 @@ export class NetworkInterface extends Base {
545
545
  }
546
546
  }
547
547
 
548
- get domainName()
549
- {
550
- return this.hostName ? [this.hostName,this.host.domain].join('.') : this.host.dmainName;
548
+ get domainName() {
549
+ return this.hostName
550
+ ? [this.hostName, this.host.domain].join(".")
551
+ : this.host.domainName;
551
552
  }
552
553
 
553
554
  get host() {
package/src/utils.mjs CHANGED
@@ -2,6 +2,11 @@ import { writeFile, mkdir } from "node:fs/promises";
2
2
  import { join, dirname, basename } from "node:path";
3
3
 
4
4
  export function domainName(name, defaultDomain) {
5
+
6
+ if(typeof name != "string") {
7
+ console.log(name);
8
+ }
9
+
5
10
  const dcs = name.split(".");
6
11
  return defaultDomain === undefined || dcs.length > 1
7
12
  ? name
@@ -80,6 +85,11 @@ export function isIPv4Address(address) {
80
85
  return address.indexOf(".") >= 0;
81
86
  }
82
87
 
88
+ export function generateEU64(mac)
89
+ {
90
+ //TODO
91
+ }
92
+
83
93
  export function isIPv6Address(address) {
84
94
  return address.indexOf(":") >= 0;
85
95
  }
package/types/host.d.mts CHANGED
@@ -185,8 +185,8 @@ export class Host extends Base {
185
185
  get isTemplate(): true | RegExpMatchArray;
186
186
  get isModel(): boolean;
187
187
  get model(): any;
188
- set aliases(value: Set<any>);
189
- get aliases(): Set<any>;
188
+ set aliases(value: any);
189
+ get aliases(): any;
190
190
  set extends(value: any[]);
191
191
  get extends(): any[];
192
192
  set master(value: boolean);
@@ -200,9 +200,9 @@ export class Host extends Base {
200
200
  get foreignDomainNames(): any[];
201
201
  get foreignDomains(): Set<any>;
202
202
  get domains(): Set<any>;
203
- get domainNames(): any[];
203
+ get domainNames(): Set<any>;
204
204
  get domainName(): any;
205
- domainNameIn(domain: any): any;
205
+ domainNamesIn(domain: any): Generator<any, void, unknown>;
206
206
  get host(): this;
207
207
  named(name: any): any;
208
208
  set networkInterfaces(networkInterface: Map<any, any>);
package/types/utils.d.mts CHANGED
@@ -6,6 +6,7 @@ export function bridgeToJSON(bridge: any): any[];
6
6
  export function asArray(value: any): any[];
7
7
  export function asIterator(value: any): any;
8
8
  export function isIPv4Address(address: any): boolean;
9
+ export function generateEU64(mac: any): void;
9
10
  export function isIPv6Address(address: any): boolean;
10
11
  export function isLinkLocal(address: any): any;
11
12
  export function normalizeIPAddress(address: any): any;