pmcf 6.35.3 → 6.36.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": "6.35.3",
3
+ "version": "6.36.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -28,7 +28,7 @@ import {
28
28
  addType,
29
29
  FAMILY_IPV4_IPV6
30
30
  } from "pmcf";
31
- import { yesno, writeLines } from "../utils.mjs";
31
+ import { yesno, writeLines } from "../utils.mjs";
32
32
  import {
33
33
  DNSRecord,
34
34
  dnsFullName,
@@ -486,6 +486,7 @@ class bind_view extends bind_object {
486
486
  this._zoneConfigs = new Map();
487
487
  this._zones = new Map();
488
488
 
489
+ const subnets = new Set();
489
490
  const hosts = new Set();
490
491
  const addresses = new Set();
491
492
 
@@ -511,17 +512,31 @@ class bind_view extends bind_object {
511
512
  )
512
513
  );
513
514
 
514
- const reverseZone =
515
- this.hasReverse &&
516
- na.subnet.prefix &&
517
- this._zones.getOrInsertComputed(
518
- reverseArpa(na.subnet.prefix),
515
+ let reverseZone;
516
+
517
+ if (this.hasReverse && na.subnet.prefix) {
518
+ let subnet;
519
+
520
+ for (const s of subnets) {
521
+ if (s.isIncluded(na.subnet)) {
522
+ subnet = s;
523
+ }
524
+ }
525
+
526
+ if (!subnet) {
527
+ subnet = na.subnet;
528
+ subnets.add(subnet);
529
+ }
530
+
531
+ reverseZone = this._zones.getOrInsertComputed(
532
+ reverseArpa(subnet.prefix),
519
533
  domain =>
520
534
  this.intoCatalog(
521
535
  new bind_zone(this, domain, config, locationName),
522
536
  locationName
523
537
  )
524
538
  );
539
+ }
525
540
 
526
541
  if (!hosts.has(host)) {
527
542
  hosts.add(host);
package/src/subnet.mjs CHANGED
@@ -77,6 +77,10 @@ export class Subnet {
77
77
  return this.address;
78
78
  }
79
79
 
80
+ isIncluded(subnet) {
81
+ return matchPrefixIP(this.address, this.prefixLength, subnet.address);
82
+ }
83
+
80
84
  matchesAddress(address) {
81
85
  return matchPrefixIP(this.address, this.prefixLength, address);
82
86
  }