pmcf 1.10.0 → 1.11.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/bin/pmcf-named-defs +3 -3
- package/package.json +1 -1
- package/src/model.mjs +25 -29
- package/types/model.d.mts +4 -4
package/bin/pmcf-named-defs
CHANGED
|
@@ -8,7 +8,6 @@ import { prepare } from "../src/cmd.mjs";
|
|
|
8
8
|
const { world, args, options } = prepare();
|
|
9
9
|
|
|
10
10
|
const location = await world.location(args[0] || "SW");
|
|
11
|
-
const ttl = location.dnsRecordTTL;
|
|
12
11
|
const updates = [
|
|
13
12
|
Math.ceil(Date.now() / 1000),
|
|
14
13
|
36000,
|
|
@@ -30,7 +29,9 @@ console.log("description", `named defintions for ${location.name}`);
|
|
|
30
29
|
}*/
|
|
31
30
|
|
|
32
31
|
async function generateNamedDefs(location, targetDir) {
|
|
32
|
+
const dns = location.dns;
|
|
33
33
|
const domain = location.domain;
|
|
34
|
+
const ttl = dns.recordTTL;
|
|
34
35
|
|
|
35
36
|
if (domain) {
|
|
36
37
|
const zones = [];
|
|
@@ -157,9 +158,8 @@ async function generateNamedDefs(location, targetDir) {
|
|
|
157
158
|
zoneConfig.push(` type master;`);
|
|
158
159
|
zoneConfig.push(` file \"${zone.file}\";`);
|
|
159
160
|
|
|
160
|
-
const u = location.dnsAllowedUpdates;
|
|
161
161
|
zoneConfig.push(
|
|
162
|
-
` allow-update { ${
|
|
162
|
+
` allow-update { ${dns.allowedUpdates.length ? dns.allowedUpdates.join(";") : "none"}; };`
|
|
163
163
|
);
|
|
164
164
|
zoneConfig.push(` notify yes;`);
|
|
165
165
|
zoneConfig.push(`};`);
|
package/package.json
CHANGED
package/src/model.mjs
CHANGED
|
@@ -148,6 +148,25 @@ export class Owner extends Base {
|
|
|
148
148
|
this.addObject(host);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
async service(filter) {
|
|
152
|
+
let best;
|
|
153
|
+
for await (const service of this.services(filter)) {
|
|
154
|
+
if (!best || service.priority < best.priority) {
|
|
155
|
+
best = service;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return best;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async *services(filter) {
|
|
163
|
+
for await (const host of this.hosts()) {
|
|
164
|
+
for await (const service of host.services(filter)) {
|
|
165
|
+
yield service;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
151
170
|
network(name) {
|
|
152
171
|
return this.#networks.get(name);
|
|
153
172
|
}
|
|
@@ -396,7 +415,11 @@ export class World extends Owner {
|
|
|
396
415
|
|
|
397
416
|
class DNSService {
|
|
398
417
|
owner;
|
|
418
|
+
|
|
419
|
+
allowedUpdates = [];
|
|
420
|
+
recordTTL = "1W";
|
|
399
421
|
forwardsTo = [];
|
|
422
|
+
|
|
400
423
|
constructor(owner, data) {
|
|
401
424
|
this.owner = owner;
|
|
402
425
|
Object.assign(this, data);
|
|
@@ -408,9 +431,8 @@ class DNSService {
|
|
|
408
431
|
yield* this.owner.services(filter);
|
|
409
432
|
|
|
410
433
|
for (const s of this.forwardsTo) {
|
|
411
|
-
const
|
|
412
|
-
|
|
413
|
-
yield* host.services(filter);
|
|
434
|
+
const owner = await this.owner.world.load(s);
|
|
435
|
+
yield* owner.services(filter);
|
|
414
436
|
}
|
|
415
437
|
}
|
|
416
438
|
}
|
|
@@ -459,24 +481,6 @@ export class Location extends Owner {
|
|
|
459
481
|
return this.#dns;
|
|
460
482
|
}
|
|
461
483
|
|
|
462
|
-
async service(filter) {
|
|
463
|
-
let best;
|
|
464
|
-
for await (const service of this.services(filter)) {
|
|
465
|
-
if (!best || service.priority < best.priority) {
|
|
466
|
-
best = service;
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
return best;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
async *services(filter) {
|
|
474
|
-
for await (const host of this.hosts()) {
|
|
475
|
-
for await (const service of host.services(filter)) {
|
|
476
|
-
yield service;
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
484
|
|
|
481
485
|
async *networkAddresses() {
|
|
482
486
|
for await (const host of this.hosts()) {
|
|
@@ -486,14 +490,6 @@ export class Location extends Owner {
|
|
|
486
490
|
}
|
|
487
491
|
}
|
|
488
492
|
|
|
489
|
-
get dnsAllowedUpdates() {
|
|
490
|
-
return this.dns?.allowedUpdates || [];
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
get dnsRecordTTL() {
|
|
494
|
-
return this.dns?.recordTTL || "1W";
|
|
495
|
-
}
|
|
496
|
-
|
|
497
493
|
get administratorEmail() {
|
|
498
494
|
return this.#administratorEmail || "admin@" + this.domain;
|
|
499
495
|
}
|
package/types/model.d.mts
CHANGED
|
@@ -31,6 +31,8 @@ export class Owner extends Base {
|
|
|
31
31
|
hosts(): AsyncGenerator<any, void, unknown>;
|
|
32
32
|
addObject(object: any): void;
|
|
33
33
|
addHost(host: any): void;
|
|
34
|
+
service(filter: any): Promise<any>;
|
|
35
|
+
services(filter: any): AsyncGenerator<any, void, unknown>;
|
|
34
36
|
network(name: any): any;
|
|
35
37
|
networks(): AsyncGenerator<any, void, unknown>;
|
|
36
38
|
addNetwork(network: any): void;
|
|
@@ -76,11 +78,7 @@ export class Location extends Owner {
|
|
|
76
78
|
servers: any[];
|
|
77
79
|
};
|
|
78
80
|
get dns(): DNSService;
|
|
79
|
-
service(filter: any): Promise<any>;
|
|
80
|
-
services(filter: any): AsyncGenerator<any, void, unknown>;
|
|
81
81
|
networkAddresses(): AsyncGenerator<any, void, unknown>;
|
|
82
|
-
get dnsAllowedUpdates(): any;
|
|
83
|
-
get dnsRecordTTL(): any;
|
|
84
82
|
get administratorEmail(): any;
|
|
85
83
|
#private;
|
|
86
84
|
}
|
|
@@ -149,6 +147,8 @@ export class Service extends Base {
|
|
|
149
147
|
declare class DNSService {
|
|
150
148
|
constructor(owner: any, data: any);
|
|
151
149
|
owner: any;
|
|
150
|
+
allowedUpdates: any[];
|
|
151
|
+
recordTTL: string;
|
|
152
152
|
forwardsTo: any[];
|
|
153
153
|
services(): AsyncGenerator<any, void, any>;
|
|
154
154
|
}
|