pmcf 4.11.1 → 4.12.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": "4.11.1",
3
+ "version": "4.12.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/dns-utils.mjs CHANGED
@@ -20,9 +20,14 @@ export function sortZoneRecords(a, b) {
20
20
  return order;
21
21
  }
22
22
 
23
- if (a.type === "PTR") {
24
- const toNum = a => {
25
- const s = a.split(".");
23
+ if (
24
+ a.type === "PTR" &&
25
+ b.type === "PTR" &&
26
+ a.key.indexOf(".arpa") > 0 &&
27
+ b.key.indexOf(".arpa") > 0
28
+ ) {
29
+ const toNum = key => {
30
+ const s = key.split(".");
26
31
  s.pop();
27
32
  s.pop();
28
33
  s.pop();
@@ -314,28 +314,32 @@ export class BindService extends ExtraSourceService {
314
314
 
315
315
  yield this.generateZoneDefs(sources, packageData);
316
316
 
317
- const outfacingZonesPackageDir = join(dir, "outfacingZones") + "/";
317
+ const location = "outfacing";
318
+
319
+ const outfacingZonesPackageDir = join(dir, location) + "/";
318
320
 
319
321
  packageData.dir = outfacingZonesPackageDir;
320
322
  packageData.sources = [
321
323
  new FileContentProvider(outfacingZonesPackageDir, ...filePermissions)
322
324
  ];
323
325
  packageData.properties = {
324
- name: `named-zones-${name}-outfacing`,
325
- description: `outfacing zone definitions for ${names}`,
326
+ name: `named-zones-${name}-${location}`,
327
+ description: `${location} zone definitions for ${names}`,
326
328
  access: "private"
327
329
  };
328
330
 
329
- yield* this.generateOutfacingDefs(sources, packageData);
331
+ yield* this.generateOutfacingDefs(sources, packageData, location);
330
332
  }
331
333
 
332
- async *generateOutfacingDefs(sources, packageData) {
334
+ async *generateOutfacingDefs(sources, packageData, location) {
333
335
  const configs = [];
334
336
 
337
+ const view = this.views.internal;
338
+
335
339
  for (const source of sources) {
336
340
  for (const host of source.hosts()) {
337
341
  configs.push(
338
- ...this.outfacingZones(host, this.views.internal, this.defaultRecords)
342
+ ...this.outfacingZones(host, view, this.defaultRecords)
339
343
  );
340
344
  }
341
345
  }
@@ -343,6 +347,12 @@ export class BindService extends ExtraSourceService {
343
347
  const outfacingZones = configs.map(c => c.zones).flat();
344
348
 
345
349
  if (outfacingZones.length) {
350
+ if (this.hasCatalog) {
351
+ const { catalogZone, config } = this.createCatalogZone(location, view, location);
352
+ configs.push(config);
353
+ outfacingZones.forEach(zone=>zone.catalogZone=catalogZone);
354
+ }
355
+
346
356
  addHook(
347
357
  packageData,
348
358
  "post_upgrade",
@@ -357,9 +367,33 @@ export class BindService extends ExtraSourceService {
357
367
  }
358
368
  }
359
369
 
370
+ createCatalogZone(name, view, location) {
371
+ const config = {
372
+ view,
373
+ name: `catalog.${name}.zone.conf`,
374
+ type: "master",
375
+ zones: []
376
+ };
377
+
378
+ const catalogZone = {
379
+ catalog: true,
380
+ id: `catalog.${name}`,
381
+ file: `${location}/catalog.${name}.zone`,
382
+ records: new Set([
383
+ ...this.defaultRecords,
384
+ DNSRecord(dnsFullName(`version.catalog.${name}`), "TXT", '"1"')
385
+ ])
386
+ };
387
+ config.zones.push(catalogZone);
388
+
389
+ return { config, catalogZone };
390
+ }
391
+
360
392
  async generateZoneDefs(sources, packageData) {
361
393
  const configs = [];
362
394
 
395
+ const view = this.views.internal;
396
+
363
397
  for (const source of sources) {
364
398
  console.log(
365
399
  "ZONE",
@@ -372,7 +406,7 @@ export class BindService extends ExtraSourceService {
372
406
  const reverseZones = new Map();
373
407
 
374
408
  const config = {
375
- view: this.views.internal,
409
+ view,
376
410
  name: `${domain}.zone.conf`,
377
411
  type: "master",
378
412
  zones: []
@@ -392,24 +426,9 @@ export class BindService extends ExtraSourceService {
392
426
  config.zones.push(zone);
393
427
 
394
428
  if (this.hasCatalog) {
395
- const catalogConfig = {
396
- view: this.views.internal,
397
- name: `catalog.${domain}.zone.conf`,
398
- type: "master",
399
- zones: []
400
- };
401
- configs.push(catalogConfig);
402
-
403
- zone.catalogZone = {
404
- catalog: true,
405
- id: `catalog.${domain}`,
406
- file: `${locationName}/catalog.${domain}.zone`,
407
- records: new Set([
408
- ...this.defaultRecords,
409
- DNSRecord(dnsFullName(`version.catalog.${domain}`), "TXT", '"1"')
410
- ])
411
- };
412
- catalogConfig.zones.push(zone.catalogZone);
429
+ const { catalogZone, config } = this.createCatalogZone(domain, view, locationName);
430
+ configs.push(config);
431
+ zone.catalogZone = catalogZone;
413
432
  }
414
433
 
415
434
  const hosts = new Set();
@@ -457,7 +476,6 @@ export class BindService extends ExtraSourceService {
457
476
 
458
477
  for (const domainName of domainNames) {
459
478
  if (domainName.endsWith(zone.id) && domainName[0] !== "*") {
460
-
461
479
  zone.records.add(
462
480
  DNSRecord(
463
481
  dnsFullName(domainName),
@@ -9,14 +9,6 @@ const MosquittoServiceTypeDefinition = {
9
9
  owners: ServiceTypeDefinition.owners,
10
10
  key: "name",
11
11
  attributes: {
12
- /*log_timestamp: {
13
- ...boolean_attribute_writable_true,
14
- configurable: true
15
- },
16
- allow_anonymous: {
17
- ...boolean_attribute_writable_true,
18
- configurable: true
19
- },*/
20
12
  listener: {
21
13
  ...port_attribute,
22
14
  writable: true,
@@ -1479,7 +1479,26 @@ 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(sources: any, packageData: any): AsyncGenerator<any, void, unknown>;
1482
+ generateOutfacingDefs(sources: any, packageData: any, location: any): AsyncGenerator<any, void, unknown>;
1483
+ createCatalogZone(name: any, view: any, location: any): {
1484
+ config: {
1485
+ view: any;
1486
+ name: string;
1487
+ type: string;
1488
+ zones: any[];
1489
+ };
1490
+ catalogZone: {
1491
+ catalog: boolean;
1492
+ id: string;
1493
+ file: string;
1494
+ records: Set<{
1495
+ type: any;
1496
+ key: any;
1497
+ values: any[];
1498
+ toString: (maxKeyLength?: number, ttl?: string) => string;
1499
+ }>;
1500
+ };
1501
+ };
1483
1502
  generateZoneDefs(sources: any, packageData: any): Promise<any>;
1484
1503
  outfacingZones(host: any, view: any, records: any): any;
1485
1504
  get defaultRecords(): {