pmcf 1.74.2 → 1.76.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/base.mjs +4 -0
- package/src/dns.mjs +64 -59
- package/src/host.mjs +41 -2
- package/src/owner.mjs +7 -3
- package/src/utils.mjs +19 -2
- package/types/base.d.mts +1 -0
- package/types/dns.d.mts +0 -1
- package/types/host.d.mts +10 -0
- package/types/owner.d.mts +1 -1
- package/types/utils.d.mts +1 -0
package/package.json
CHANGED
package/src/base.mjs
CHANGED
package/src/dns.mjs
CHANGED
|
@@ -99,10 +99,6 @@ export class DNSService extends Base {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
get domains() {
|
|
103
|
-
return [this.owner.domain];
|
|
104
|
-
}
|
|
105
|
-
|
|
106
102
|
async resolvedConfig() {
|
|
107
103
|
return {
|
|
108
104
|
DNS: serviceAddresses(this, {
|
|
@@ -113,7 +109,7 @@ export class DNSService extends Base {
|
|
|
113
109
|
...DNS_SERVICE_FILTER,
|
|
114
110
|
priority: ">=10"
|
|
115
111
|
}).join(" "),
|
|
116
|
-
Domains: this.domains.join(" "),
|
|
112
|
+
Domains: [...this.domains].join(" "),
|
|
117
113
|
DNSSEC: "no",
|
|
118
114
|
MulticastDNS: "yes",
|
|
119
115
|
LLMNR: "no"
|
|
@@ -217,7 +213,7 @@ async function generateZoneDefs(dns, targetDir) {
|
|
|
217
213
|
);
|
|
218
214
|
}
|
|
219
215
|
|
|
220
|
-
console.log(`${nameService}`,nameService.ipAddressOrDomainName);
|
|
216
|
+
console.log(`${nameService}`, nameService.ipAddressOrDomainName);
|
|
221
217
|
//console.log(dns.owner.fullName, domain, nameService.domainName, rname);
|
|
222
218
|
const reverseZones = new Map();
|
|
223
219
|
|
|
@@ -229,7 +225,11 @@ async function generateZoneDefs(dns, targetDir) {
|
|
|
229
225
|
`(${updates})`
|
|
230
226
|
);
|
|
231
227
|
|
|
232
|
-
const NSRecord = createRecord(
|
|
228
|
+
const NSRecord = createRecord(
|
|
229
|
+
"@",
|
|
230
|
+
"NS",
|
|
231
|
+
fullName(nameService.ipAddressOrDomainName)
|
|
232
|
+
);
|
|
233
233
|
|
|
234
234
|
const zone = {
|
|
235
235
|
id: domain,
|
|
@@ -268,65 +268,70 @@ async function generateZoneDefs(dns, targetDir) {
|
|
|
268
268
|
networkInterface
|
|
269
269
|
} of dns.owner.networkAddresses()) {
|
|
270
270
|
const host = networkInterface.host;
|
|
271
|
+
const domainName = host.domainNameIn(domain);
|
|
271
272
|
|
|
272
|
-
if (
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
273
|
+
if (domainName) {
|
|
274
|
+
if (
|
|
275
|
+
!addresses.has(address) &&
|
|
276
|
+
(dns.hasLinkLocalAdresses || !isLinkLocal(address))
|
|
277
|
+
) {
|
|
278
|
+
addresses.add(address);
|
|
277
279
|
|
|
278
|
-
|
|
279
|
-
createRecord(
|
|
280
|
-
fullName(host.domainName),
|
|
281
|
-
isIPv6Address(address) ? "AAAA" : "A",
|
|
282
|
-
normalizeIPAddress(address)
|
|
283
|
-
)
|
|
284
|
-
);
|
|
285
|
-
|
|
286
|
-
if (subnet) {
|
|
287
|
-
let reverseZone = reverseZones.get(subnet.address);
|
|
288
|
-
|
|
289
|
-
if (!reverseZone) {
|
|
290
|
-
const reverseArpa = reverseArpaAddress(subnet.prefix);
|
|
291
|
-
reverseZone = {
|
|
292
|
-
id: reverseArpa,
|
|
293
|
-
type: "plain",
|
|
294
|
-
file: `${dns.owner.name}/${reverseArpa}.zone`,
|
|
295
|
-
records: new Set([SOARecord, NSRecord])
|
|
296
|
-
};
|
|
297
|
-
zones.push(reverseZone);
|
|
298
|
-
reverseZones.set(subnet.address, reverseZone);
|
|
299
|
-
}
|
|
300
|
-
reverseZone.records.add(
|
|
280
|
+
zone.records.add(
|
|
301
281
|
createRecord(
|
|
302
|
-
fullName(
|
|
303
|
-
"
|
|
304
|
-
|
|
282
|
+
fullName(domainName),
|
|
283
|
+
isIPv6Address(address) ? "AAAA" : "A",
|
|
284
|
+
normalizeIPAddress(address)
|
|
305
285
|
)
|
|
306
286
|
);
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
287
|
+
if (subnet && host.domain === domain) {
|
|
288
|
+
let reverseZone = reverseZones.get(subnet.address);
|
|
289
|
+
|
|
290
|
+
if (!reverseZone) {
|
|
291
|
+
const reverseArpa = reverseArpaAddress(subnet.prefix);
|
|
292
|
+
reverseZone = {
|
|
293
|
+
id: reverseArpa,
|
|
294
|
+
type: "plain",
|
|
295
|
+
file: `${dns.owner.name}/${reverseArpa}.zone`,
|
|
296
|
+
records: new Set([SOARecord, NSRecord])
|
|
297
|
+
};
|
|
298
|
+
zones.push(reverseZone);
|
|
299
|
+
reverseZones.set(subnet.address, reverseZone);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
for (const domainName of host.domainNames) {
|
|
303
|
+
reverseZone.records.add(
|
|
304
|
+
createRecord(
|
|
305
|
+
fullName(reverseArpaAddress(address)),
|
|
306
|
+
"PTR",
|
|
307
|
+
fullName(domainName)
|
|
308
|
+
)
|
|
309
|
+
);
|
|
310
|
+
}
|
|
317
311
|
}
|
|
312
|
+
}
|
|
318
313
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
service.
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
314
|
+
if (!hosts.has(host)) {
|
|
315
|
+
hosts.add(host);
|
|
316
|
+
for (const service of host.findServices()) {
|
|
317
|
+
if (service.master && service.alias) {
|
|
318
|
+
zone.records.add(
|
|
319
|
+
createRecord(service.alias, "CNAME", fullName(domainName))
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (dns.hasSVRRecords && service.srvPrefix) {
|
|
324
|
+
zone.records.add(
|
|
325
|
+
createRecord(
|
|
326
|
+
fullName(`${service.srvPrefix}.${domainName}`),
|
|
327
|
+
"SRV",
|
|
328
|
+
service.priority,
|
|
329
|
+
service.weight,
|
|
330
|
+
service.port,
|
|
331
|
+
fullName(host.domainName)
|
|
332
|
+
)
|
|
333
|
+
);
|
|
334
|
+
}
|
|
330
335
|
}
|
|
331
336
|
}
|
|
332
337
|
}
|
package/src/host.mjs
CHANGED
|
@@ -2,14 +2,18 @@ import { readFile } from "node:fs/promises";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { FileContentProvider } from "npm-pkgbuild";
|
|
4
4
|
import { Base } from "./base.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
networkProperties,
|
|
7
|
+
networkAddressProperties
|
|
8
|
+
} from "./network-support.mjs";
|
|
6
9
|
import {
|
|
7
10
|
asArray,
|
|
8
11
|
isIPv4Address,
|
|
9
12
|
isIPv6Address,
|
|
10
13
|
normalizeIPAddress,
|
|
11
14
|
formatCIDR,
|
|
12
|
-
hasWellKnownSubnet
|
|
15
|
+
hasWellKnownSubnet,
|
|
16
|
+
domainFromDominName
|
|
13
17
|
} from "./utils.mjs";
|
|
14
18
|
import { objectFilter } from "./filter.mjs";
|
|
15
19
|
import { addType, types } from "./types.mjs";
|
|
@@ -33,6 +37,8 @@ const HostTypeDefinition = {
|
|
|
33
37
|
writeable: true
|
|
34
38
|
},
|
|
35
39
|
services: { type: "service", collection: true, writeable: true },
|
|
40
|
+
aliases: { type: "string", collection: true, writeable: true },
|
|
41
|
+
|
|
36
42
|
os: { type: "string", collection: false, writeable: true },
|
|
37
43
|
"machine-id": { type: "string", collection: false, writeable: true },
|
|
38
44
|
distribution: { type: "string", collection: false, writeable: true },
|
|
@@ -56,6 +62,7 @@ export class Host extends Base {
|
|
|
56
62
|
priority = 1;
|
|
57
63
|
#services = [];
|
|
58
64
|
#extends = [];
|
|
65
|
+
#aliases = new Set();
|
|
59
66
|
#networkInterfaces = new Map();
|
|
60
67
|
#provides = new Set();
|
|
61
68
|
#replaces = new Set();
|
|
@@ -158,6 +165,18 @@ export class Host extends Base {
|
|
|
158
165
|
return this.extends.find(h => h.isModel);
|
|
159
166
|
}
|
|
160
167
|
|
|
168
|
+
set aliases(value) {
|
|
169
|
+
if (value instanceof Set) {
|
|
170
|
+
this.#aliases = this.#aliases.union(value);
|
|
171
|
+
} else {
|
|
172
|
+
this.#aliases.add(value);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
get aliases() {
|
|
177
|
+
return this.#aliases;
|
|
178
|
+
}
|
|
179
|
+
|
|
161
180
|
set extends(value) {
|
|
162
181
|
this.#extends.push(value);
|
|
163
182
|
}
|
|
@@ -235,12 +254,32 @@ export class Host extends Base {
|
|
|
235
254
|
return parts[parts.length - 1];
|
|
236
255
|
}
|
|
237
256
|
|
|
257
|
+
get domains() {
|
|
258
|
+
const domains = new Set(
|
|
259
|
+
[...this.aliases].map(n => domainFromDominName(n, this.domain))
|
|
260
|
+
);
|
|
261
|
+
domains.add(this.domain);
|
|
262
|
+
return domains;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
get domainNames() {
|
|
266
|
+
return [this.domainName, ...this.aliases];
|
|
267
|
+
}
|
|
268
|
+
|
|
238
269
|
get domainName() {
|
|
239
270
|
const domain = this.domain;
|
|
240
271
|
const hostName = this.hostName;
|
|
241
272
|
return domain ? hostName + "." + domain : hostName;
|
|
242
273
|
}
|
|
243
274
|
|
|
275
|
+
domainNameIn(domain) {
|
|
276
|
+
for (const domainName of this.domainNames) {
|
|
277
|
+
if (domain == domainFromDominName(domainName)) {
|
|
278
|
+
return domainName;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
244
283
|
get host() {
|
|
245
284
|
return this;
|
|
246
285
|
}
|
package/src/owner.mjs
CHANGED
|
@@ -356,9 +356,13 @@ export class Owner extends Base {
|
|
|
356
356
|
return this.#domain || this.owner?.domain;
|
|
357
357
|
}
|
|
358
358
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
359
|
+
get domains() {
|
|
360
|
+
let domains = new Set();
|
|
361
|
+
|
|
362
|
+
for (const object of this.hosts()) {
|
|
363
|
+
domains = domains.union(object.domains);
|
|
362
364
|
}
|
|
365
|
+
|
|
366
|
+
return domains;
|
|
363
367
|
}
|
|
364
368
|
}
|
package/src/utils.mjs
CHANGED
|
@@ -1,13 +1,30 @@
|
|
|
1
1
|
import { writeFile, mkdir } from "node:fs/promises";
|
|
2
2
|
import { join, dirname, basename } from "node:path";
|
|
3
3
|
|
|
4
|
+
export function domainFromDominName(domainName, defaultDomain) {
|
|
5
|
+
const dcs = domainName.split(".");
|
|
6
|
+
|
|
7
|
+
if (dcs.length > 1) {
|
|
8
|
+
dcs.shift();
|
|
9
|
+
return dcs.join(".");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return defaultDomain;
|
|
13
|
+
}
|
|
14
|
+
|
|
4
15
|
export async function writeLines(dir, name, lines) {
|
|
16
|
+
switch (typeof lines) {
|
|
17
|
+
case "undefined":
|
|
18
|
+
return;
|
|
19
|
+
case "string":
|
|
20
|
+
lines = [lines];
|
|
21
|
+
}
|
|
22
|
+
|
|
5
23
|
const full = join(dir, name);
|
|
6
24
|
dir = dirname(full);
|
|
7
25
|
name = basename(full);
|
|
8
|
-
|
|
9
26
|
await mkdir(dir, { recursive: true });
|
|
10
|
-
|
|
27
|
+
|
|
11
28
|
return writeFile(
|
|
12
29
|
join(dir, name),
|
|
13
30
|
[...lines]
|
package/types/base.d.mts
CHANGED
package/types/dns.d.mts
CHANGED
package/types/host.d.mts
CHANGED
|
@@ -51,6 +51,11 @@ export class Host extends Base {
|
|
|
51
51
|
collection: boolean;
|
|
52
52
|
writeable: boolean;
|
|
53
53
|
};
|
|
54
|
+
aliases: {
|
|
55
|
+
type: string;
|
|
56
|
+
collection: boolean;
|
|
57
|
+
writeable: boolean;
|
|
58
|
+
};
|
|
54
59
|
os: {
|
|
55
60
|
type: string;
|
|
56
61
|
collection: boolean;
|
|
@@ -168,6 +173,8 @@ export class Host extends Base {
|
|
|
168
173
|
get isTemplate(): true | RegExpMatchArray;
|
|
169
174
|
get isModel(): boolean;
|
|
170
175
|
get model(): any;
|
|
176
|
+
set aliases(value: Set<any>);
|
|
177
|
+
get aliases(): Set<any>;
|
|
171
178
|
set extends(value: any[]);
|
|
172
179
|
get extends(): any[];
|
|
173
180
|
set master(value: boolean);
|
|
@@ -178,7 +185,10 @@ export class Host extends Base {
|
|
|
178
185
|
get distribution(): any;
|
|
179
186
|
get modelName(): any;
|
|
180
187
|
get hostName(): string;
|
|
188
|
+
get domains(): Set<any>;
|
|
189
|
+
get domainNames(): any[];
|
|
181
190
|
get domainName(): string;
|
|
191
|
+
domainNameIn(domain: any): any;
|
|
182
192
|
get host(): this;
|
|
183
193
|
named(name: any): any;
|
|
184
194
|
set networkInterfaces(networkInterface: Map<any, any>);
|
package/types/owner.d.mts
CHANGED
|
@@ -220,7 +220,7 @@ export class Owner extends Base {
|
|
|
220
220
|
get administratorEmail(): any;
|
|
221
221
|
set domain(value: any);
|
|
222
222
|
get domain(): any;
|
|
223
|
-
domains():
|
|
223
|
+
get domains(): Set<any>;
|
|
224
224
|
#private;
|
|
225
225
|
}
|
|
226
226
|
import { Base } from "./base.mjs";
|
package/types/utils.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export function domainFromDominName(domainName: any, defaultDomain: any): any;
|
|
1
2
|
export function writeLines(dir: any, name: any, lines: any): Promise<void>;
|
|
2
3
|
export function sectionLines(sectionName: any, values: any): string[];
|
|
3
4
|
export function bridgeToJSON(bridge: any): any[];
|