pmcf 1.92.0 → 1.94.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.92.0",
3
+ "version": "1.94.0",
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/cluster.mjs CHANGED
@@ -186,7 +186,7 @@ export class Cluster extends Host {
186
186
  `${this.name}-master.target`,
187
187
  [
188
188
  "[Unit]",
189
- `Description=Target for master state of cluster ${this.name}`,
189
+ `Description=master state of cluster ${this.name}`,
190
190
  "PartOf=keepalived.service",
191
191
  `Conflicts=${this.name}-fault.target`
192
192
  ]
@@ -197,7 +197,7 @@ export class Cluster extends Host {
197
197
  `${this.name}-backup.target`,
198
198
  [
199
199
  "[Unit]",
200
- `Description=Target for backup state of cluster ${this.name}`,
200
+ `Description=backup state of cluster ${this.name}`,
201
201
  "PartOf=keepalived.service",
202
202
  `Conflicts=${this.name}-fault.target`
203
203
  ]
@@ -208,7 +208,7 @@ export class Cluster extends Host {
208
208
  `${this.name}-fault.target`,
209
209
  [
210
210
  "[Unit]",
211
- `Description=Target for fault state of cluster ${this.name}`,
211
+ `Description=fault state of cluster ${this.name}`,
212
212
  `Conflicts=${this.name}-master.target ${this.name}-backup.target`
213
213
  ]
214
214
  );
package/src/dns.mjs CHANGED
@@ -288,10 +288,12 @@ async function generateZoneDefs(dns, packageData) {
288
288
  };
289
289
  configs.push(config);
290
290
 
291
+ const locationRecord = DNSRecord("location", "TXT", dns.location.name);
292
+
291
293
  const zone = {
292
294
  id: domain,
293
295
  file: `${ownerName}/${domain}.zone`,
294
- records: new Set([SOARecord, NSRecord])
296
+ records: new Set([SOARecord, NSRecord, locationRecord])
295
297
  };
296
298
  config.zones.push(zone);
297
299
 
@@ -320,61 +322,65 @@ async function generateZoneDefs(dns, packageData) {
320
322
  for await (const {
321
323
  address,
322
324
  subnet,
323
- networkInterface
325
+ networkInterface,
326
+ domainName
324
327
  } of dns.owner.networkAddresses()) {
325
328
  const host = networkInterface.host;
326
- const domainName = host.domainNameIn(domain);
329
+ if (
330
+ !addresses.has(address) &&
331
+ (dns.hasLinkLocalAdresses || !isLinkLocal(address))
332
+ ) {
333
+ addresses.add(address);
334
+
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
+ }
327
356
 
328
- if (domainName) {
329
- if (
330
- !addresses.has(address) &&
331
- (dns.hasLinkLocalAdresses || !isLinkLocal(address))
332
- ) {
333
- addresses.add(address);
357
+ for (const domainName of host.domainNames) {
358
+ reverseZone.records.add(
359
+ DNSRecord(
360
+ dnsFullName(reverseArpaAddress(address)),
361
+ "PTR",
362
+ dnsFullName(domainName)
363
+ )
364
+ );
365
+ }
366
+ }
367
+ }
368
+
369
+ if (!hosts.has(host)) {
370
+ hosts.add(host);
334
371
 
372
+ for (const foreignDomainName of host.foreignDomainNames) {
335
373
  zone.records.add(
336
- DNSRecord(
337
- dnsFullName(domainName),
338
- isIPv6Address(address) ? "AAAA" : "A",
339
- normalizeIPAddress(address)
340
- )
374
+ DNSRecord("external", "PTR", dnsFullName(foreignDomainName))
341
375
  );
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
- }
356
-
357
- for (const domainName of host.domainNames) {
358
- reverseZone.records.add(
359
- DNSRecord(
360
- dnsFullName(reverseArpaAddress(address)),
361
- "PTR",
362
- dnsFullName(domainName)
363
- )
364
- );
365
- }
366
- }
367
376
  }
368
377
 
369
- if (!hosts.has(host)) {
370
- hosts.add(host);
371
- for (const service of host.findServices()) {
372
- for (const record of service.dnsRecordsForDomainName(
373
- domainName,
374
- dns.hasSVRRecords
375
- )) {
376
- zone.records.add(record);
377
- }
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);
378
384
  }
379
385
  }
380
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,
@@ -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
  }
@@ -364,6 +368,7 @@ export class Host extends Base {
364
368
  for (const [address, subnet] of networkInterface.ipAddresses) {
365
369
  yield {
366
370
  networkInterface,
371
+ domainName: networkInterface.domainName,
367
372
  address,
368
373
  subnet
369
374
  };
@@ -396,9 +401,7 @@ export class Host extends Base {
396
401
  async *preparePackages(dir) {
397
402
  const packageData = {
398
403
  dir,
399
- sources: [
400
- new FileContentProvider(dir + "/")[Symbol.asyncIterator]()
401
- ],
404
+ sources: [new FileContentProvider(dir + "/")[Symbol.asyncIterator]()],
402
405
  outputs: this.outputs,
403
406
  properties: {
404
407
  name: `${this.typeName}-${this.owner.name}-${this.name}`,
@@ -411,7 +414,8 @@ export class Host extends Base {
411
414
  provides: [...this.provides],
412
415
  replaces: [`mf-${this.hostName}`, ...this.replaces],
413
416
  backup: "root/.ssh/known_hosts",
414
- hooks: await loadHooks({},
417
+ hooks: await loadHooks(
418
+ {},
415
419
  new URL("host.install", import.meta.url).pathname
416
420
  )
417
421
  }
@@ -420,10 +424,7 @@ export class Host extends Base {
420
424
  await generateNetworkDefs(this, packageData);
421
425
  await generateMachineInfo(this, packageData);
422
426
  await copySshKeys(this, packageData);
423
- await generateKnownHosts(
424
- this.owner.hosts(),
425
- join(dir, "root", ".ssh")
426
- );
427
+ await generateKnownHosts(this.owner.hosts(), join(dir, "root", ".ssh"));
427
428
 
428
429
  yield packageData;
429
430
  }
@@ -437,6 +438,7 @@ const NetworkInterfaceTypeDefinition = {
437
438
  properties: {
438
439
  ...networkProperties,
439
440
  ...networkAddressProperties,
441
+ hostName: { type: "string", collection: false, writeable: true },
440
442
  ipAddresses: { type: "string", collection: true, writeable: true },
441
443
 
442
444
  hwaddr: { type: "string", collection: false, writeable: true },
@@ -464,6 +466,7 @@ export class NetworkInterface extends Base {
464
466
  #kind;
465
467
  arpbridge;
466
468
  hwaddr;
469
+ hostName;
467
470
 
468
471
  constructor(owner, data) {
469
472
  super(owner, data);
@@ -542,6 +545,12 @@ export class NetworkInterface extends Base {
542
545
  }
543
546
  }
544
547
 
548
+ get domainName() {
549
+ return this.hostName
550
+ ? [this.hostName, this.host.domain].join(".")
551
+ : this.host.domainName;
552
+ }
553
+
545
554
  get host() {
546
555
  return this.owner;
547
556
  }
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
@@ -200,15 +200,16 @@ 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>);
209
209
  get networkInterfaces(): Map<any, any>;
210
210
  networkAddresses(): Generator<{
211
211
  networkInterface: any;
212
+ domainName: any;
212
213
  address: any;
213
214
  subnet: any;
214
215
  }, void, unknown>;
@@ -282,6 +283,11 @@ export class NetworkInterface extends Base {
282
283
  };
283
284
  };
284
285
  properties: {
286
+ hostName: {
287
+ type: string;
288
+ collection: boolean;
289
+ writeable: boolean;
290
+ };
285
291
  ipAddresses: {
286
292
  type: string;
287
293
  collection: boolean;
@@ -366,6 +372,7 @@ export class NetworkInterface extends Base {
366
372
  };
367
373
  arpbridge: any;
368
374
  hwaddr: any;
375
+ hostName: any;
369
376
  addSubnet(address: any): any;
370
377
  set ipAddresses(value: Map<any, any>);
371
378
  get ipAddresses(): Map<any, any>;
@@ -378,6 +385,7 @@ export class NetworkInterface extends Base {
378
385
  subnetForAddress(address: any): any;
379
386
  get gateway(): any;
380
387
  get gatewayAddress(): any;
388
+ get domainName(): any;
381
389
  get network_interface(): this;
382
390
  set network(network: any);
383
391
  get network(): 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;