pmcf 1.10.0 → 1.12.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 +45 -39
- package/types/model.d.mts +6 -5
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
|
}
|
|
@@ -867,15 +863,15 @@ export class Subnet extends Base {
|
|
|
867
863
|
}
|
|
868
864
|
|
|
869
865
|
const ServiceTypes = {
|
|
870
|
-
dns: {
|
|
871
|
-
ldap: {
|
|
872
|
-
http: {
|
|
873
|
-
https: {
|
|
874
|
-
rtsp: {
|
|
875
|
-
smtp: {
|
|
876
|
-
ssh: {
|
|
877
|
-
imap: {
|
|
878
|
-
imaps: {
|
|
866
|
+
dns: { protocol: "udp", port: 53 },
|
|
867
|
+
ldap: { protocol: "tcp", port: 389 },
|
|
868
|
+
http: { protocol: "tcp", port: 80 },
|
|
869
|
+
https: { protocol: "tcp", port: 443 },
|
|
870
|
+
rtsp: { protocol: "tcp", port: 554 },
|
|
871
|
+
smtp: { protocol: "tcp", port: 25 },
|
|
872
|
+
ssh: { protocol: "tcp", port: 22 },
|
|
873
|
+
imap: { protocol: "tcp", port: 143 },
|
|
874
|
+
imaps: { protocol: "tcp", port: 993 },
|
|
879
875
|
dhcp: {}
|
|
880
876
|
};
|
|
881
877
|
|
|
@@ -945,8 +941,16 @@ export class Service extends Base {
|
|
|
945
941
|
return this;
|
|
946
942
|
}
|
|
947
943
|
|
|
944
|
+
get protocol()
|
|
945
|
+
{
|
|
946
|
+
return ServiceTypes[this.type]?.protocol;
|
|
947
|
+
}
|
|
948
|
+
|
|
948
949
|
get srvPrefix() {
|
|
949
|
-
|
|
950
|
+
const st = ServiceTypes[this.type];
|
|
951
|
+
if(st) {
|
|
952
|
+
return `_${this.type}._${st.protocol}`;
|
|
953
|
+
}
|
|
950
954
|
}
|
|
951
955
|
|
|
952
956
|
get ipAddress() {
|
|
@@ -977,6 +981,8 @@ export class Service extends Base {
|
|
|
977
981
|
return [
|
|
978
982
|
...super.propertyNames,
|
|
979
983
|
"ipAddress",
|
|
984
|
+
"port",
|
|
985
|
+
"protocol",
|
|
980
986
|
"alias",
|
|
981
987
|
"type",
|
|
982
988
|
"master",
|
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
|
}
|
|
@@ -137,7 +135,8 @@ export class Subnet extends Base {
|
|
|
137
135
|
}
|
|
138
136
|
export class Service extends Base {
|
|
139
137
|
alias: any;
|
|
140
|
-
get
|
|
138
|
+
get protocol(): any;
|
|
139
|
+
get srvPrefix(): string;
|
|
141
140
|
get ipAddress(): any;
|
|
142
141
|
get port(): any;
|
|
143
142
|
get priority(): any;
|
|
@@ -149,6 +148,8 @@ export class Service extends Base {
|
|
|
149
148
|
declare class DNSService {
|
|
150
149
|
constructor(owner: any, data: any);
|
|
151
150
|
owner: any;
|
|
151
|
+
allowedUpdates: any[];
|
|
152
|
+
recordTTL: string;
|
|
152
153
|
forwardsTo: any[];
|
|
153
154
|
services(): AsyncGenerator<any, void, any>;
|
|
154
155
|
}
|