pmcf 4.12.3 → 4.13.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 +1 -1
- package/src/dns-utils.mjs +0 -1
- package/src/services/bind.mjs +76 -76
- package/types/services/bind.d.mts +4 -22
package/package.json
CHANGED
package/src/dns-utils.mjs
CHANGED
package/src/services/bind.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
1
|
+
import { join, dirname } from "node:path";
|
|
2
2
|
import { createHmac } from "node:crypto";
|
|
3
3
|
import { FileContentProvider } from "npm-pkgbuild";
|
|
4
4
|
import { isLinkLocal, reverseArpa } from "ip-utilties";
|
|
@@ -311,7 +311,7 @@ export class BindService extends ExtraSourceService {
|
|
|
311
311
|
access: "private"
|
|
312
312
|
};
|
|
313
313
|
|
|
314
|
-
yield this.generateZoneDefs(
|
|
314
|
+
yield this.generateZoneDefs(newOutputControl(packageData), sources);
|
|
315
315
|
|
|
316
316
|
const location = "outfacing";
|
|
317
317
|
|
|
@@ -327,50 +327,38 @@ export class BindService extends ExtraSourceService {
|
|
|
327
327
|
access: "private"
|
|
328
328
|
};
|
|
329
329
|
|
|
330
|
-
yield* this.generateOutfacingDefs(
|
|
330
|
+
yield* this.generateOutfacingDefs(newOutputControl(packageData), sources);
|
|
331
331
|
}
|
|
332
332
|
|
|
333
|
-
async *generateOutfacingDefs(
|
|
334
|
-
const configs = [];
|
|
335
|
-
|
|
336
|
-
const view = this.views.internal;
|
|
337
|
-
|
|
333
|
+
async *generateOutfacingDefs(outputControl, sources) {
|
|
338
334
|
for (const source of sources) {
|
|
339
335
|
for (const host of source.hosts()) {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
if (outfacingZones.length) {
|
|
347
|
-
if (this.hasCatalog) {
|
|
348
|
-
const { catalogZone, config } = this.createCatalogZone(
|
|
349
|
-
location,
|
|
350
|
-
view,
|
|
351
|
-
location
|
|
336
|
+
this.outfacingZones(
|
|
337
|
+
outputControl,
|
|
338
|
+
host,
|
|
339
|
+
this.views.internal,
|
|
340
|
+
this.defaultRecords
|
|
352
341
|
);
|
|
353
|
-
configs.push(config);
|
|
354
|
-
outfacingZones.forEach(zone => (zone.catalogZone = catalogZone));
|
|
355
342
|
}
|
|
343
|
+
}
|
|
356
344
|
|
|
345
|
+
if (outputControl.configs.length) {
|
|
357
346
|
addHook(
|
|
358
|
-
packageData,
|
|
347
|
+
outputControl.packageData,
|
|
359
348
|
"post_upgrade",
|
|
360
|
-
`/usr/bin/named-hostname-update ${
|
|
361
|
-
.map(zone => zone.id)
|
|
349
|
+
`/usr/bin/named-hostname-update ${outputControl.configs
|
|
350
|
+
.map(config => config.zones.map(zone => zone.id))
|
|
351
|
+
.flat()
|
|
362
352
|
.join(" ")}`
|
|
363
353
|
);
|
|
364
354
|
|
|
365
|
-
await this.writeZones(packageData, configs);
|
|
355
|
+
await this.writeZones(outputControl.packageData, outputControl.configs);
|
|
366
356
|
|
|
367
|
-
yield packageData;
|
|
357
|
+
yield outputControl.packageData;
|
|
368
358
|
}
|
|
369
359
|
}
|
|
370
360
|
|
|
371
|
-
async generateZoneDefs(
|
|
372
|
-
const configs = [];
|
|
373
|
-
|
|
361
|
+
async generateZoneDefs(outputControl, sources) {
|
|
374
362
|
const view = this.views.internal;
|
|
375
363
|
|
|
376
364
|
for (const source of sources) {
|
|
@@ -390,10 +378,11 @@ export class BindService extends ExtraSourceService {
|
|
|
390
378
|
type: "master",
|
|
391
379
|
zones: []
|
|
392
380
|
};
|
|
393
|
-
configs.push(config);
|
|
381
|
+
outputControl.configs.push(config);
|
|
394
382
|
|
|
395
383
|
const zone = {
|
|
396
384
|
id: domain,
|
|
385
|
+
config,
|
|
397
386
|
file: `${locationName}/${domain}.zone`,
|
|
398
387
|
records: new Set(this.defaultRecords)
|
|
399
388
|
};
|
|
@@ -404,15 +393,7 @@ export class BindService extends ExtraSourceService {
|
|
|
404
393
|
|
|
405
394
|
config.zones.push(zone);
|
|
406
395
|
|
|
407
|
-
|
|
408
|
-
const { catalogZone, config } = this.createCatalogZone(
|
|
409
|
-
domain,
|
|
410
|
-
view,
|
|
411
|
-
locationName
|
|
412
|
-
);
|
|
413
|
-
configs.push(config);
|
|
414
|
-
zone.catalogZone = catalogZone;
|
|
415
|
-
}
|
|
396
|
+
this.assignCatalog(outputControl, zone, domain);
|
|
416
397
|
|
|
417
398
|
const hosts = new Set();
|
|
418
399
|
const addresses = new Set();
|
|
@@ -449,12 +430,15 @@ export class BindService extends ExtraSourceService {
|
|
|
449
430
|
const id = reverseArpa(subnet.prefix);
|
|
450
431
|
reverseZone = {
|
|
451
432
|
id,
|
|
433
|
+
config,
|
|
452
434
|
type: "plain",
|
|
453
435
|
file: `${locationName}/${id}.zone`,
|
|
454
436
|
records: new Set(this.defaultRecords)
|
|
455
437
|
};
|
|
456
438
|
config.zones.push(reverseZone);
|
|
457
439
|
reverseZones.set(subnet, reverseZone);
|
|
440
|
+
|
|
441
|
+
this.assignCatalog(outputControl, reverseZone, domain);
|
|
458
442
|
}
|
|
459
443
|
|
|
460
444
|
for (const domainName of domainNames) {
|
|
@@ -505,7 +489,7 @@ export class BindService extends ExtraSourceService {
|
|
|
505
489
|
}
|
|
506
490
|
}
|
|
507
491
|
}
|
|
508
|
-
configs.push({
|
|
492
|
+
outputControl.configs.push({
|
|
509
493
|
view: this.views.protected,
|
|
510
494
|
inView: this.views.protected.inView,
|
|
511
495
|
name: config.name,
|
|
@@ -514,13 +498,13 @@ export class BindService extends ExtraSourceService {
|
|
|
514
498
|
}
|
|
515
499
|
}
|
|
516
500
|
|
|
517
|
-
await this.writeZones(packageData, configs);
|
|
501
|
+
await this.writeZones(outputControl.packageData, outputControl.configs);
|
|
518
502
|
|
|
519
|
-
return packageData;
|
|
503
|
+
return outputControl.packageData;
|
|
520
504
|
}
|
|
521
505
|
|
|
522
|
-
outfacingZones(host, view, records) {
|
|
523
|
-
|
|
506
|
+
outfacingZones(outputControl, host, view, records) {
|
|
507
|
+
host.foreignDomainNames.map(domain => {
|
|
524
508
|
const wildcard = domain.startsWith("*.");
|
|
525
509
|
if (wildcard) {
|
|
526
510
|
domain = domain.substring(2);
|
|
@@ -528,7 +512,7 @@ export class BindService extends ExtraSourceService {
|
|
|
528
512
|
|
|
529
513
|
const zone = {
|
|
530
514
|
id: domain,
|
|
531
|
-
file:
|
|
515
|
+
file: `${host.location.name}/outfacing/${domain}.zone`,
|
|
532
516
|
records: new Set(records)
|
|
533
517
|
};
|
|
534
518
|
const config = {
|
|
@@ -537,6 +521,8 @@ export class BindService extends ExtraSourceService {
|
|
|
537
521
|
type: "master",
|
|
538
522
|
zones: [zone]
|
|
539
523
|
};
|
|
524
|
+
zone.config = config;
|
|
525
|
+
outputControl.configs.push(config);
|
|
540
526
|
|
|
541
527
|
if (this.hasLocationRecord) {
|
|
542
528
|
zone.records.add(DNSRecord("location", "TXT", host.location.name));
|
|
@@ -555,30 +541,51 @@ export class BindService extends ExtraSourceService {
|
|
|
555
541
|
}
|
|
556
542
|
}
|
|
557
543
|
|
|
558
|
-
|
|
544
|
+
this.assignCatalog(
|
|
545
|
+
outputControl,
|
|
546
|
+
zone,
|
|
547
|
+
`outfacting.${host.location.name}`
|
|
548
|
+
);
|
|
559
549
|
});
|
|
560
550
|
}
|
|
561
551
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
type: "master",
|
|
567
|
-
zones: []
|
|
568
|
-
};
|
|
552
|
+
assignCatalog(outputControl, zone, name) {
|
|
553
|
+
if (!this.hasCatalog) {
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
569
556
|
|
|
570
|
-
const
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
557
|
+
const directory = dirname(zone.file);
|
|
558
|
+
|
|
559
|
+
let catalogZone = outputControl.catalogs.get(directory);
|
|
560
|
+
|
|
561
|
+
if (!catalogZone) {
|
|
562
|
+
catalogZone = {
|
|
563
|
+
catalog: true,
|
|
564
|
+
id: `catalog.${name}`,
|
|
565
|
+
file: `${directory}/catalog.${name}.zone`,
|
|
566
|
+
records: new Set([
|
|
567
|
+
...this.defaultRecords,
|
|
568
|
+
DNSRecord(dnsFullName(`version.catalog.${name}`), "TXT", '"2"')
|
|
569
|
+
])
|
|
570
|
+
};
|
|
571
|
+
outputControl.catalogs.set(directory, catalogZone);
|
|
572
|
+
const config = {
|
|
573
|
+
view: zone.config.view,
|
|
574
|
+
name: `catalog.${name}.zone.conf`,
|
|
575
|
+
type: "master",
|
|
576
|
+
zones: [catalogZone]
|
|
577
|
+
};
|
|
578
|
+
catalogZone.config = config;
|
|
579
|
+
outputControl.configs.push(config);
|
|
580
|
+
}
|
|
581
|
+
zone.catalogZone = catalogZone;
|
|
582
|
+
|
|
583
|
+
const hash = createHmac("sha1", zone.id).digest("hex");
|
|
584
|
+
catalogZone.records.add(
|
|
585
|
+
DNSRecord(`${hash}.zones.${zone.id}.`, "PTR", dnsFullName(zone.id))
|
|
586
|
+
);
|
|
580
587
|
|
|
581
|
-
return
|
|
588
|
+
return catalogZone;
|
|
582
589
|
}
|
|
583
590
|
|
|
584
591
|
get defaultRecords() {
|
|
@@ -606,17 +613,6 @@ export class BindService extends ExtraSourceService {
|
|
|
606
613
|
for (const zone of config.zones) {
|
|
607
614
|
console.log(` file: ${zone.file}`);
|
|
608
615
|
|
|
609
|
-
if (zone.catalogZone) {
|
|
610
|
-
const hash = createHmac("md5", zone.id).digest("hex");
|
|
611
|
-
zone.catalogZone.records.add(
|
|
612
|
-
DNSRecord(
|
|
613
|
-
`${hash}.zones.catalog.${zone.id}.`,
|
|
614
|
-
"PTR",
|
|
615
|
-
dnsFullName(zone.id)
|
|
616
|
-
)
|
|
617
|
-
);
|
|
618
|
-
}
|
|
619
|
-
|
|
620
616
|
content.push(`zone \"${zone.id}\" {`);
|
|
621
617
|
|
|
622
618
|
if (config.inView) {
|
|
@@ -659,3 +655,7 @@ export class BindService extends ExtraSourceService {
|
|
|
659
655
|
}
|
|
660
656
|
}
|
|
661
657
|
}
|
|
658
|
+
|
|
659
|
+
function newOutputControl(packageData) {
|
|
660
|
+
return { configs: [], catalogs: new Map(), packageData };
|
|
661
|
+
}
|
|
@@ -1479,28 +1479,10 @@ export class BindService extends ExtraSourceService {
|
|
|
1479
1479
|
set excludeInterfaceKinds(value: Set<any>);
|
|
1480
1480
|
get excludeInterfaceKinds(): Set<any>;
|
|
1481
1481
|
preparePackages(dir: any): AsyncGenerator<any, void, unknown>;
|
|
1482
|
-
generateOutfacingDefs(
|
|
1483
|
-
generateZoneDefs(
|
|
1484
|
-
outfacingZones(host: any, view: any, records: any):
|
|
1485
|
-
|
|
1486
|
-
config: {
|
|
1487
|
-
view: any;
|
|
1488
|
-
name: string;
|
|
1489
|
-
type: string;
|
|
1490
|
-
zones: any[];
|
|
1491
|
-
};
|
|
1492
|
-
catalogZone: {
|
|
1493
|
-
catalog: boolean;
|
|
1494
|
-
id: string;
|
|
1495
|
-
file: string;
|
|
1496
|
-
records: Set<{
|
|
1497
|
-
type: any;
|
|
1498
|
-
key: any;
|
|
1499
|
-
values: any[];
|
|
1500
|
-
toString: (maxKeyLength?: number, ttl?: string) => string;
|
|
1501
|
-
}>;
|
|
1502
|
-
};
|
|
1503
|
-
};
|
|
1482
|
+
generateOutfacingDefs(outputControl: any, sources: any): AsyncGenerator<any, void, unknown>;
|
|
1483
|
+
generateZoneDefs(outputControl: any, sources: any): Promise<any>;
|
|
1484
|
+
outfacingZones(outputControl: any, host: any, view: any, records: any): void;
|
|
1485
|
+
assignCatalog(outputControl: any, zone: any, name: any): any;
|
|
1504
1486
|
get defaultRecords(): {
|
|
1505
1487
|
type: any;
|
|
1506
1488
|
key: any;
|