pmcf 6.20.3 → 6.21.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-info +2 -0
- package/package.json +1 -1
- package/src/common-attributes.mjs +3 -0
- package/src/core-service.mjs +20 -10
- package/src/host.mjs +3 -2
- package/src/services/bind.mjs +27 -24
package/bin/pmcf-info
CHANGED
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
default_attribute_writable,
|
|
4
4
|
default_collection_attribute_writable,
|
|
5
5
|
string_collection_attribute_writable,
|
|
6
|
+
string_set_attribute_writable,
|
|
6
7
|
string_attribute_writable,
|
|
7
8
|
integer_attribute_writable,
|
|
8
9
|
hostname_attribute as hostname_attribute_base,
|
|
@@ -11,6 +12,8 @@ import {
|
|
|
11
12
|
|
|
12
13
|
export const networkAddressType = "network|host|network_interface";
|
|
13
14
|
|
|
15
|
+
export const aliases_attribute = { ...string_set_attribute_writable, name: "aliases" };
|
|
16
|
+
|
|
14
17
|
export const owner_attribute = {
|
|
15
18
|
...default_attribute,
|
|
16
19
|
name: "owner",
|
package/src/core-service.mjs
CHANGED
|
@@ -20,8 +20,11 @@ import {
|
|
|
20
20
|
FAMILY_UNIX,
|
|
21
21
|
FAMILY_DNS
|
|
22
22
|
} from "pmcf";
|
|
23
|
-
import { asArray } from "./utils.mjs";
|
|
24
|
-
import {
|
|
23
|
+
import { asArray, union } from "./utils.mjs";
|
|
24
|
+
import {
|
|
25
|
+
networkAddressAttributes,
|
|
26
|
+
aliases_attribute
|
|
27
|
+
} from "./common-attributes.mjs";
|
|
25
28
|
import {
|
|
26
29
|
serviceTypeEndpoints,
|
|
27
30
|
serviceTypes,
|
|
@@ -72,7 +75,7 @@ export class CoreService extends Base {
|
|
|
72
75
|
name: "extends",
|
|
73
76
|
type: CoreService
|
|
74
77
|
},
|
|
75
|
-
|
|
78
|
+
aliases: aliases_attribute,
|
|
76
79
|
priority: priority_attribute,
|
|
77
80
|
weight: { ...number_attribute_writable, name: "weight" /*default: 1*/ },
|
|
78
81
|
systemdService: { ...string_attribute_writable, name: "systemdService" },
|
|
@@ -84,7 +87,7 @@ export class CoreService extends Base {
|
|
|
84
87
|
addType(this);
|
|
85
88
|
}
|
|
86
89
|
|
|
87
|
-
|
|
90
|
+
_aliases = new Set();
|
|
88
91
|
_weight;
|
|
89
92
|
_port;
|
|
90
93
|
_systemdService;
|
|
@@ -208,12 +211,14 @@ export class CoreService extends Base {
|
|
|
208
211
|
return options.join !== undefined ? res.join(options.join) : res;
|
|
209
212
|
}
|
|
210
213
|
|
|
211
|
-
set
|
|
212
|
-
this.
|
|
214
|
+
set aliases(value) {
|
|
215
|
+
this._aliases = union(value, this._aliases);
|
|
213
216
|
}
|
|
214
217
|
|
|
215
|
-
get
|
|
216
|
-
return this.
|
|
218
|
+
get aliases() {
|
|
219
|
+
return this.expand(
|
|
220
|
+
this.unionFromDirections(["this", "extends"], "_aliases")
|
|
221
|
+
);
|
|
217
222
|
}
|
|
218
223
|
|
|
219
224
|
set port(value) {
|
|
@@ -301,8 +306,13 @@ export class CoreService extends Base {
|
|
|
301
306
|
|
|
302
307
|
dnsRecordsForDomainName(domainName, hasSVRRecords) {
|
|
303
308
|
const records = [];
|
|
304
|
-
|
|
305
|
-
|
|
309
|
+
|
|
310
|
+
if (this.priority >= 390) {
|
|
311
|
+
console.log("DNS SERVICE ALIAS", this.aliases, dnsFullName(domainName));
|
|
312
|
+
|
|
313
|
+
for (const alias of this.aliases) {
|
|
314
|
+
records.push(DNSRecord(alias, "CNAME", dnsFullName(domainName)));
|
|
315
|
+
}
|
|
306
316
|
}
|
|
307
317
|
|
|
308
318
|
if (hasSVRRecords) {
|
package/src/host.mjs
CHANGED
|
@@ -14,7 +14,8 @@ import { addresses, addType, assign } from "pmcf";
|
|
|
14
14
|
import {
|
|
15
15
|
networkAddressAttributes,
|
|
16
16
|
networkInterfaces_attribute,
|
|
17
|
-
hosts_attribute
|
|
17
|
+
hosts_attribute,
|
|
18
|
+
aliases_attribute
|
|
18
19
|
} from "./common-attributes.mjs";
|
|
19
20
|
import { ServiceOwner } from "./service-owner.mjs";
|
|
20
21
|
import { addHook } from "./hooks.mjs";
|
|
@@ -34,7 +35,7 @@ export class Host extends ServiceOwner {
|
|
|
34
35
|
static attributes = {
|
|
35
36
|
...networkAddressAttributes,
|
|
36
37
|
networkInterfaces: networkInterfaces_attribute,
|
|
37
|
-
aliases:
|
|
38
|
+
aliases: aliases_attribute,
|
|
38
39
|
os: {
|
|
39
40
|
...string_attribute_writable,
|
|
40
41
|
name: "os",
|
package/src/services/bind.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
name_attribute,
|
|
11
11
|
string_attribute,
|
|
12
12
|
string_set_attribute,
|
|
13
|
+
boolean_attribute,
|
|
13
14
|
boolean_attribute_writable_true,
|
|
14
15
|
boolean_attribute_writable_false,
|
|
15
16
|
integer_attribute_writable,
|
|
@@ -44,13 +45,18 @@ class bind_zone extends Base {
|
|
|
44
45
|
static attributes = {
|
|
45
46
|
id: { ...name_attribute, name: "id" },
|
|
46
47
|
file: { ...string_attribute, name: "file" },
|
|
47
|
-
records: { ...string_set_attribute, name: "records" }
|
|
48
|
+
records: { ...string_set_attribute, name: "records" },
|
|
49
|
+
foreign: { ...boolean_attribute, name: "foreign" }
|
|
48
50
|
};
|
|
49
51
|
|
|
50
52
|
static {
|
|
51
53
|
addType(this);
|
|
52
54
|
}
|
|
53
55
|
|
|
56
|
+
get isCatalog() {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
|
|
54
60
|
get name() {
|
|
55
61
|
return this.id;
|
|
56
62
|
}
|
|
@@ -68,7 +74,7 @@ class bind_zone extends Base {
|
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
constructor(owner, id, config, location) {
|
|
71
|
-
super();
|
|
77
|
+
super(owner);
|
|
72
78
|
this.id = id;
|
|
73
79
|
this.config = config;
|
|
74
80
|
this.directory = location;
|
|
@@ -84,7 +90,8 @@ class bind_zone extends Base {
|
|
|
84
90
|
|
|
85
91
|
class catalog_zone extends bind_zone {
|
|
86
92
|
static attributes = {
|
|
87
|
-
version: { ...string_attribute, name: "version" }
|
|
93
|
+
version: { ...string_attribute, name: "version" },
|
|
94
|
+
isCatalog: { ...boolean_attribute, name: "isCatalog" }
|
|
88
95
|
};
|
|
89
96
|
|
|
90
97
|
static {
|
|
@@ -115,7 +122,7 @@ class bind_zone_config extends Base {
|
|
|
115
122
|
addType(this);
|
|
116
123
|
}
|
|
117
124
|
|
|
118
|
-
zones = [];
|
|
125
|
+
/** @type {bind_zone[]} */ zones = [];
|
|
119
126
|
|
|
120
127
|
get type() {
|
|
121
128
|
return this.owner.service.serverType;
|
|
@@ -126,10 +133,11 @@ class bind_zone_config extends Base {
|
|
|
126
133
|
this.name = name;
|
|
127
134
|
}
|
|
128
135
|
|
|
129
|
-
async write(outputControl
|
|
136
|
+
async write(outputControl) {
|
|
130
137
|
const dir = outputControl.dir;
|
|
138
|
+
const group = this.owner;
|
|
131
139
|
|
|
132
|
-
console.log(`config: ${group.name}/${this.name}`);
|
|
140
|
+
console.log(`config: ${group.name}/${this.name}${this.foreign ? " foreign" : ""}`);
|
|
133
141
|
|
|
134
142
|
const content = [];
|
|
135
143
|
|
|
@@ -306,13 +314,6 @@ class bind_group extends Base {
|
|
|
306
314
|
get defaultRecords() {
|
|
307
315
|
const service = this.service;
|
|
308
316
|
|
|
309
|
-
/*console.log(
|
|
310
|
-
"nameService",
|
|
311
|
-
service.fullName,
|
|
312
|
-
service.domainName,
|
|
313
|
-
service.address()
|
|
314
|
-
);*/
|
|
315
|
-
|
|
316
317
|
return [
|
|
317
318
|
DNSRecord(
|
|
318
319
|
"@",
|
|
@@ -361,7 +362,6 @@ class bind_group extends Base {
|
|
|
361
362
|
get zones() {
|
|
362
363
|
const entries = [...this.entries];
|
|
363
364
|
|
|
364
|
-
|
|
365
365
|
if (!this._zones && entries.length > 0) {
|
|
366
366
|
this._zoneConfigs = new Map();
|
|
367
367
|
this._zones = new Map();
|
|
@@ -418,6 +418,7 @@ class bind_group extends Base {
|
|
|
418
418
|
domain => new bind_zone_config(this, `${domain}.zone.conf`)
|
|
419
419
|
);
|
|
420
420
|
|
|
421
|
+
config.foreign = true;
|
|
421
422
|
const zone = this._zones.getOrInsertComputed(
|
|
422
423
|
foreignDomain,
|
|
423
424
|
domain =>
|
|
@@ -427,6 +428,8 @@ class bind_group extends Base {
|
|
|
427
428
|
)
|
|
428
429
|
);
|
|
429
430
|
|
|
431
|
+
zone.foreign = true;
|
|
432
|
+
|
|
430
433
|
for (const na of host.networkAddresses(
|
|
431
434
|
na => na.networkInterface.kind !== "loopback"
|
|
432
435
|
)) {
|
|
@@ -448,10 +451,6 @@ class bind_group extends Base {
|
|
|
448
451
|
);
|
|
449
452
|
}
|
|
450
453
|
}
|
|
451
|
-
|
|
452
|
-
/*zone.records.add(
|
|
453
|
-
DNSRecord("outfacing", "PTR", dnsFullName(foreignDomain))
|
|
454
|
-
);*/
|
|
455
454
|
}
|
|
456
455
|
|
|
457
456
|
const sm = new Map();
|
|
@@ -534,7 +533,7 @@ class bind_group extends Base {
|
|
|
534
533
|
|
|
535
534
|
async generateZoneDefs(outputControl) {
|
|
536
535
|
for (const config of this.zoneConfigs.values()) {
|
|
537
|
-
await config.write(outputControl
|
|
536
|
+
await config.write(outputControl);
|
|
538
537
|
}
|
|
539
538
|
|
|
540
539
|
if (this.foreignDomains.size) {
|
|
@@ -549,6 +548,14 @@ class bind_group extends Base {
|
|
|
549
548
|
}
|
|
550
549
|
}
|
|
551
550
|
|
|
551
|
+
/**
|
|
552
|
+
*
|
|
553
|
+
* @param {string} prefix
|
|
554
|
+
* @param {any} objects
|
|
555
|
+
* @param {boolean|string} empty
|
|
556
|
+
* @param {string} indent
|
|
557
|
+
* @returns {string[]}
|
|
558
|
+
*/
|
|
552
559
|
function addressesStatement(prefix, objects, empty = false, indent = "") {
|
|
553
560
|
const body = asArray(objects).map(
|
|
554
561
|
value => `${indent} ${typeof value === "string" ? value : value.name};`
|
|
@@ -664,7 +671,7 @@ export class bind extends ExtraSourceService {
|
|
|
664
671
|
new FileContentProvider(dir + "/", ...permissions)
|
|
665
672
|
);
|
|
666
673
|
|
|
667
|
-
const outputControl =
|
|
674
|
+
const outputControl = { packageData, dir, permissions };
|
|
668
675
|
|
|
669
676
|
for (const group of this.groups.values()) {
|
|
670
677
|
const present = await group.packageContent(outputControl);
|
|
@@ -678,7 +685,3 @@ export class bind extends ExtraSourceService {
|
|
|
678
685
|
}
|
|
679
686
|
}
|
|
680
687
|
}
|
|
681
|
-
|
|
682
|
-
function newOutputControl(packageData, dir, permissions) {
|
|
683
|
-
return { packageData, dir, permissions };
|
|
684
|
-
}
|