pmcf 2.39.9 → 2.40.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/services/bind.mjs +67 -34
- package/types/services/bind.d.mts +7 -0
package/package.json
CHANGED
package/src/services/bind.mjs
CHANGED
|
@@ -221,10 +221,10 @@ export class BINDService extends ExtraSourceService {
|
|
|
221
221
|
const names = sources.map(a => a.fullName).join(" ");
|
|
222
222
|
|
|
223
223
|
const name = this.owner.owner.name;
|
|
224
|
-
const
|
|
224
|
+
const configPackageDir = join(dir, "config") + "/";
|
|
225
225
|
const packageData = {
|
|
226
|
-
dir:
|
|
227
|
-
sources: [new FileContentProvider(
|
|
226
|
+
dir: configPackageDir,
|
|
227
|
+
sources: [new FileContentProvider(configPackageDir)],
|
|
228
228
|
outputs: this.outputs,
|
|
229
229
|
properties: {
|
|
230
230
|
name: `named-${name}`,
|
|
@@ -241,7 +241,7 @@ export class BINDService extends ExtraSourceService {
|
|
|
241
241
|
|
|
242
242
|
if (forwarders.length) {
|
|
243
243
|
await writeLines(
|
|
244
|
-
join(
|
|
244
|
+
join(configPackageDir, "etc/named/options"),
|
|
245
245
|
`forwarders.conf`,
|
|
246
246
|
addressesStatement("forwarders", forwarders)
|
|
247
247
|
);
|
|
@@ -264,15 +264,15 @@ export class BINDService extends ExtraSourceService {
|
|
|
264
264
|
].flat();
|
|
265
265
|
|
|
266
266
|
if (acls.length) {
|
|
267
|
-
await writeLines(join(
|
|
267
|
+
await writeLines(join(configPackageDir, "etc/named"), `0-acl-${name}.conf`, acls);
|
|
268
268
|
}
|
|
269
269
|
if (forwarders.length || acls.length) {
|
|
270
270
|
yield packageData;
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
const
|
|
273
|
+
const zonesPackageDir = join(dir, "zones") + "/";
|
|
274
274
|
|
|
275
|
-
packageData.dir =
|
|
275
|
+
packageData.dir = zonesPackageDir;
|
|
276
276
|
packageData.properties = {
|
|
277
277
|
name: `named-zones-${name}`,
|
|
278
278
|
description: `zone definitions for ${names}`,
|
|
@@ -284,7 +284,7 @@ export class BINDService extends ExtraSourceService {
|
|
|
284
284
|
|
|
285
285
|
packageData.sources = [
|
|
286
286
|
new FileContentProvider(
|
|
287
|
-
|
|
287
|
+
zonesPackageDir,
|
|
288
288
|
{
|
|
289
289
|
mode: 0o644,
|
|
290
290
|
owner: "named",
|
|
@@ -300,34 +300,44 @@ export class BINDService extends ExtraSourceService {
|
|
|
300
300
|
|
|
301
301
|
await this.generateZoneDefs(sources, packageData);
|
|
302
302
|
|
|
303
|
-
|
|
304
|
-
}
|
|
303
|
+
const foreignZonesPackageDir = join(dir, "foreignZones") + "/";
|
|
305
304
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
305
|
+
packageData.dir = foreignZonesPackageDir;
|
|
306
|
+
packageData.properties = {
|
|
307
|
+
name: `named-foreign-zones-${name}`,
|
|
308
|
+
description: `foreign zone definitions for ${names}`,
|
|
309
|
+
dependencies: [`named-zones-${name}`],
|
|
310
|
+
access: "private",
|
|
311
|
+
hooks: {}
|
|
312
|
+
};
|
|
309
313
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
314
|
+
packageData.sources = [
|
|
315
|
+
new FileContentProvider(
|
|
316
|
+
foreignZonesPackageDir,
|
|
317
|
+
{
|
|
318
|
+
mode: 0o644,
|
|
319
|
+
owner: "named",
|
|
320
|
+
group: "named"
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
mode: 0o755,
|
|
324
|
+
owner: "named",
|
|
325
|
+
group: "named"
|
|
326
|
+
}
|
|
327
|
+
)
|
|
328
|
+
];
|
|
317
329
|
|
|
318
|
-
|
|
319
|
-
"@",
|
|
320
|
-
"NS",
|
|
321
|
-
dnsFullName(nameService.ipAddressOrDomainName)
|
|
322
|
-
);
|
|
330
|
+
await this.generateForeignDefs(sources, packageData);
|
|
323
331
|
|
|
324
|
-
|
|
332
|
+
yield packageData;
|
|
333
|
+
}
|
|
325
334
|
|
|
335
|
+
async generateForeignDefs(sources, packageData) {
|
|
326
336
|
const configs = [];
|
|
327
337
|
|
|
328
338
|
for (const source of sources) {
|
|
329
339
|
for (const host of source.hosts()) {
|
|
330
|
-
configs.push(...this.foreignDomainZones(host,
|
|
340
|
+
configs.push(...this.foreignDomainZones(host, this.defaultRecords));
|
|
331
341
|
}
|
|
332
342
|
}
|
|
333
343
|
|
|
@@ -337,15 +347,18 @@ export class BINDService extends ExtraSourceService {
|
|
|
337
347
|
addHook(
|
|
338
348
|
packageData.properties.hooks,
|
|
339
349
|
"post_upgrade",
|
|
340
|
-
/* `rm -f ${foreignZones.map(
|
|
341
|
-
zone => `/var/lib/named/${zone.file}.jnl`
|
|
342
|
-
)}\n` + */
|
|
343
350
|
`/usr/bin/named-hostname-info ${foreignZones
|
|
344
351
|
.map(zone => zone.id)
|
|
345
352
|
.join(" ")}|/usr/bin/named-hostname-update`
|
|
346
353
|
);
|
|
347
354
|
}
|
|
348
355
|
|
|
356
|
+
await this.writeZones(packageData, configs);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
async generateZoneDefs(sources, packageData) {
|
|
360
|
+
const configs = [];
|
|
361
|
+
|
|
349
362
|
for (const source of sources) {
|
|
350
363
|
console.log(
|
|
351
364
|
"LOCAL DOMAINS",
|
|
@@ -369,7 +382,7 @@ export class BINDService extends ExtraSourceService {
|
|
|
369
382
|
const zone = {
|
|
370
383
|
id: domain,
|
|
371
384
|
file: `${locationName}/${domain}.zone`,
|
|
372
|
-
records: new Set([
|
|
385
|
+
records: new Set([...this.defaultRecords, locationRecord])
|
|
373
386
|
};
|
|
374
387
|
config.zones.push(zone);
|
|
375
388
|
|
|
@@ -384,8 +397,7 @@ export class BINDService extends ExtraSourceService {
|
|
|
384
397
|
id: `catalog.${domain}`,
|
|
385
398
|
file: `${locationName}/catalog.${domain}.zone`,
|
|
386
399
|
records: new Set([
|
|
387
|
-
|
|
388
|
-
NSRecord,
|
|
400
|
+
...this.defaultRecords,
|
|
389
401
|
DNSRecord(dnsFullName(`version.catalog.${domain}`), "TXT", '"1"')
|
|
390
402
|
])
|
|
391
403
|
};
|
|
@@ -432,7 +444,7 @@ export class BINDService extends ExtraSourceService {
|
|
|
432
444
|
id,
|
|
433
445
|
type: "plain",
|
|
434
446
|
file: `${locationName}/${id}.zone`,
|
|
435
|
-
records: new Set(
|
|
447
|
+
records: new Set(this.defaultRecords)
|
|
436
448
|
};
|
|
437
449
|
config.zones.push(reverseZone);
|
|
438
450
|
reverseZones.set(subnet.address, reverseZone);
|
|
@@ -511,6 +523,27 @@ export class BINDService extends ExtraSourceService {
|
|
|
511
523
|
});
|
|
512
524
|
}
|
|
513
525
|
|
|
526
|
+
get defaultRecords() {
|
|
527
|
+
const nameService = this.findService({ type: "dns", priority: "<10" });
|
|
528
|
+
const rname = this.administratorEmail.replace(/@/, ".");
|
|
529
|
+
|
|
530
|
+
const SOARecord = DNSRecord(
|
|
531
|
+
"@",
|
|
532
|
+
"SOA",
|
|
533
|
+
dnsFullName(nameService.domainName),
|
|
534
|
+
dnsFullName(rname),
|
|
535
|
+
`(${[...this.soaUpdates].join(" ")})`
|
|
536
|
+
);
|
|
537
|
+
|
|
538
|
+
const NSRecord = DNSRecord(
|
|
539
|
+
"@",
|
|
540
|
+
"NS",
|
|
541
|
+
dnsFullName(nameService.ipAddressOrDomainName)
|
|
542
|
+
);
|
|
543
|
+
|
|
544
|
+
return [SOARecord, NSRecord];
|
|
545
|
+
}
|
|
546
|
+
|
|
514
547
|
async writeZones(packageData, configs) {
|
|
515
548
|
for (const config of configs) {
|
|
516
549
|
console.log(`config: ${config.name}`);
|
|
@@ -392,8 +392,15 @@ export class BINDService extends ExtraSourceService {
|
|
|
392
392
|
access: string;
|
|
393
393
|
};
|
|
394
394
|
}, void, unknown>;
|
|
395
|
+
generateForeignDefs(sources: any, packageData: any): Promise<void>;
|
|
395
396
|
generateZoneDefs(sources: any, packageData: any): Promise<void>;
|
|
396
397
|
foreignDomainZones(host: any, records: any): any;
|
|
398
|
+
get defaultRecords(): {
|
|
399
|
+
type: any;
|
|
400
|
+
key: any;
|
|
401
|
+
values: any[];
|
|
402
|
+
toString: (maxKeyLength?: number, ttl?: string) => string;
|
|
403
|
+
}[];
|
|
397
404
|
writeZones(packageData: any, configs: any): Promise<void>;
|
|
398
405
|
}
|
|
399
406
|
import { ExtraSourceService } from "pmcf";
|