pmcf 1.35.1 → 1.35.3
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/bin/pmcf-named-defs +2 -3
- package/package.json +1 -1
- package/src/owner.mjs +6 -1
- package/src/utils.mjs +27 -2
- package/types/owner.d.mts +1 -0
package/bin/pmcf-named-defs
CHANGED
|
@@ -78,7 +78,7 @@ async function generateNamedDefs(owner, targetDir) {
|
|
|
78
78
|
zones.push(zone);
|
|
79
79
|
|
|
80
80
|
for (const subnet of owner.subnets()) {
|
|
81
|
-
if (subnet.prefix) {
|
|
81
|
+
if (!subnet.isLinkLocal && subnet.prefix) {
|
|
82
82
|
const reverseArpa = reverseArpaAddress(subnet.prefix);
|
|
83
83
|
const reverseZone = {
|
|
84
84
|
id: reverseArpa,
|
|
@@ -108,7 +108,6 @@ async function generateNamedDefs(owner, targetDir) {
|
|
|
108
108
|
);
|
|
109
109
|
hosts.add(host);
|
|
110
110
|
for (const service of host.services()) {
|
|
111
|
-
//console.log(service.name);
|
|
112
111
|
if (service.master && service.alias) {
|
|
113
112
|
zone.records.add(
|
|
114
113
|
createRecord(service.alias, "CNAME", `${host.domainName}.`)
|
|
@@ -133,7 +132,7 @@ async function generateNamedDefs(owner, targetDir) {
|
|
|
133
132
|
|
|
134
133
|
const reverseZone = networkInterface.network.subnet?.reverseZone;
|
|
135
134
|
|
|
136
|
-
if (reverseZone
|
|
135
|
+
if (reverseZone) {
|
|
137
136
|
reverseZone.records.add(
|
|
138
137
|
createRecord(
|
|
139
138
|
reverseArpaAddress(address) + ".",
|
package/package.json
CHANGED
package/src/owner.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { asArray, normalizeCIDR } from "./utils.mjs";
|
|
1
|
+
import { asArray, normalizeCIDR, isLinkLocal } from "./utils.mjs";
|
|
2
2
|
import { Base } from "./base.mjs";
|
|
3
3
|
import { DNSService } from "./dns.mjs";
|
|
4
4
|
|
|
@@ -368,6 +368,11 @@ export class Subnet extends Base {
|
|
|
368
368
|
return address.startsWith(this.prefix);
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
+
get isLinkLocal()
|
|
372
|
+
{
|
|
373
|
+
return isLinkLocal(this.address);
|
|
374
|
+
}
|
|
375
|
+
|
|
371
376
|
get prefix() {
|
|
372
377
|
const [prefix] = this.name.split("/");
|
|
373
378
|
return prefix;
|
package/src/utils.mjs
CHANGED
|
@@ -57,6 +57,30 @@ export function normalizeIPAddress(address) {
|
|
|
57
57
|
return parts.map(s => s.padStart(4, "0")).join(":");
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
function encodeIPv4(address) {
|
|
61
|
+
const octets = [0, 0, 0, 0];
|
|
62
|
+
|
|
63
|
+
let i = 0;
|
|
64
|
+
for (const a of address.split(/\./)) {
|
|
65
|
+
octets[i++] = parseInt(a);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return (octets[0] << 24) + (octets[1] << 16) + (octets[2] << 8) + octets[3];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function decodeIPv4(address, length = 32) {
|
|
72
|
+
const octets = [
|
|
73
|
+
(address >> 24) & 0xff,
|
|
74
|
+
(address >> 16) & 0xff,
|
|
75
|
+
(address >> 8) & 0xff,
|
|
76
|
+
address & 0xff
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
octets.length = Math.ceil(length / 8);
|
|
80
|
+
|
|
81
|
+
return octets.join(".");
|
|
82
|
+
}
|
|
83
|
+
|
|
60
84
|
export function normalizeCIDR(address) {
|
|
61
85
|
let [prefix, prefixLength] = address.split(/\//);
|
|
62
86
|
|
|
@@ -66,8 +90,9 @@ export function normalizeCIDR(address) {
|
|
|
66
90
|
} else {
|
|
67
91
|
if (prefixLength) {
|
|
68
92
|
if (isIPv4Address(prefix)) {
|
|
69
|
-
|
|
70
|
-
|
|
93
|
+
let n = encodeIPv4(prefix);
|
|
94
|
+
n = n & (0xffffffff << (32 - prefixLength));
|
|
95
|
+
prefix = decodeIPv4(n, prefixLength);
|
|
71
96
|
} else {
|
|
72
97
|
prefix = normalizeIPAddress(prefix);
|
|
73
98
|
const parts = prefix.split(/\:/);
|
package/types/owner.d.mts
CHANGED