pmcf 6.28.3 → 6.29.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/README.md +26 -26
- package/package.json +2 -2
- package/src/base.mjs +1 -1
- package/src/initialization-context.mjs +11 -1
- package/src/network-address.mjs +7 -0
- package/src/services/bind.mjs +106 -62
- package/src/utils.mjs +13 -2
package/README.md
CHANGED
|
@@ -57,12 +57,12 @@ generates config packages for:
|
|
|
57
57
|
* [Parameters](#parameters-6)
|
|
58
58
|
* [property](#property)
|
|
59
59
|
* [Parameters](#parameters-7)
|
|
60
|
+
* [enabled](#enabled)
|
|
60
61
|
* [priority](#priority)
|
|
61
62
|
* [expression](#expression)
|
|
62
63
|
* [Parameters](#parameters-8)
|
|
63
64
|
* [templateContent](#templatecontent)
|
|
64
65
|
* [Parameters](#parameters-9)
|
|
65
|
-
* [enabled](#enabled)
|
|
66
66
|
* [isTemplate](#istemplate)
|
|
67
67
|
* [expand](#expand)
|
|
68
68
|
* [Parameters](#parameters-10)
|
|
@@ -78,30 +78,30 @@ generates config packages for:
|
|
|
78
78
|
* [domainNames](#domainnames)
|
|
79
79
|
* [InitializationContext](#initializationcontext)
|
|
80
80
|
* [Parameters](#parameters-14)
|
|
81
|
+
* [SkeletonNetworkInterface](#skeletonnetworkinterface)
|
|
82
|
+
* [networkAddresses](#networkaddresses)
|
|
83
|
+
* [Parameters](#parameters-15)
|
|
81
84
|
* [zones](#zones)
|
|
82
85
|
* [type](#type)
|
|
83
86
|
* [addressesStatement](#addressesstatement)
|
|
84
|
-
* [Parameters](#parameters-
|
|
87
|
+
* [Parameters](#parameters-16)
|
|
85
88
|
* [SystemdJournalRemoteService](#systemdjournalremoteservice)
|
|
86
89
|
* [Properties](#properties)
|
|
87
90
|
* [systemdConfigs](#systemdconfigs)
|
|
88
|
-
* [Parameters](#parameters-
|
|
91
|
+
* [Parameters](#parameters-17)
|
|
89
92
|
* [SystemdJournalUploadService](#systemdjournaluploadservice)
|
|
90
93
|
* [Properties](#properties-1)
|
|
91
94
|
* [systemdConfigs](#systemdconfigs-1)
|
|
92
|
-
* [Parameters](#parameters-
|
|
95
|
+
* [Parameters](#parameters-18)
|
|
93
96
|
* [NetworkAddress](#networkaddress)
|
|
94
|
-
* [Parameters](#parameters-
|
|
97
|
+
* [Parameters](#parameters-19)
|
|
95
98
|
* [subnet](#subnet)
|
|
96
99
|
* [networkInterface](#networkinterface)
|
|
97
100
|
* [address](#address)
|
|
98
101
|
* [addresses](#addresses)
|
|
99
|
-
* [Parameters](#parameters-19)
|
|
100
|
-
* [cidrAddresses](#cidraddresses)
|
|
101
102
|
* [Parameters](#parameters-20)
|
|
102
|
-
* [
|
|
103
|
-
* [
|
|
104
|
-
* [Parameters](#parameters-21)
|
|
103
|
+
* [cidrAddresses](#cidraddresses)
|
|
104
|
+
* [Parameters](#parameters-21)
|
|
105
105
|
* [families](#families)
|
|
106
106
|
* [secretName](#secretname)
|
|
107
107
|
* [directHosts](#directhosts)
|
|
@@ -196,6 +196,10 @@ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
|
|
|
196
196
|
|
|
197
197
|
Returns **any** 
|
|
198
198
|
|
|
199
|
+
### enabled
|
|
200
|
+
|
|
201
|
+
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** 
|
|
202
|
+
|
|
199
203
|
### priority
|
|
200
204
|
|
|
201
205
|
Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** 
|
|
@@ -218,10 +222,6 @@ Returns **any** 
|
|
|
218
222
|
|
|
219
223
|
Returns **AsyncIterable\<ContentProvider>** 
|
|
220
224
|
|
|
221
|
-
### enabled
|
|
222
|
-
|
|
223
|
-
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** 
|
|
224
|
-
|
|
225
225
|
### isTemplate
|
|
226
226
|
|
|
227
227
|
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** 
|
|
@@ -296,6 +296,18 @@ Keeps track of all in flight object creations and loose ends during config initi
|
|
|
296
296
|
|
|
297
297
|
* `directory` (optional, default `"/"`)
|
|
298
298
|
|
|
299
|
+
## SkeletonNetworkInterface
|
|
300
|
+
|
|
301
|
+
**Extends ServiceOwner**
|
|
302
|
+
|
|
303
|
+
### networkAddresses
|
|
304
|
+
|
|
305
|
+
#### Parameters
|
|
306
|
+
|
|
307
|
+
* `filter` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `n=>true`)
|
|
308
|
+
|
|
309
|
+
Returns **Iterable<[NetworkAddress](#networkaddress)>** 
|
|
310
|
+
|
|
299
311
|
## zones
|
|
300
312
|
|
|
301
313
|
Type: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<bind\_zone>
|
|
@@ -392,18 +404,6 @@ Returns **Iterable<[string](https://developer.mozilla.org/docs/Web/JavaScript/Re
|
|
|
392
404
|
|
|
393
405
|
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** 
|
|
394
406
|
|
|
395
|
-
## SkeletonNetworkInterface
|
|
396
|
-
|
|
397
|
-
**Extends ServiceOwner**
|
|
398
|
-
|
|
399
|
-
### networkAddresses
|
|
400
|
-
|
|
401
|
-
#### Parameters
|
|
402
|
-
|
|
403
|
-
* `filter` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `n=>true`)
|
|
404
|
-
|
|
405
|
-
Returns **Iterable<[NetworkAddress](#networkaddress)>** 
|
|
406
|
-
|
|
407
407
|
## families
|
|
408
408
|
|
|
409
409
|
Returns **[Set](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** 
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmcf",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.29.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"aggregated-map": "^1.0.10",
|
|
54
54
|
"content-entry-transform": "^1.7.0",
|
|
55
55
|
"ip-utilties": "^3.12.0",
|
|
56
|
-
"npm-pkgbuild": "^20.8.
|
|
56
|
+
"npm-pkgbuild": "^20.8.15",
|
|
57
57
|
"pacc": "^11.2.2",
|
|
58
58
|
"package-directory": "^8.2.0",
|
|
59
59
|
"yaml": "^2.9.0"
|
package/src/base.mjs
CHANGED
|
@@ -166,7 +166,7 @@ export class Base {
|
|
|
166
166
|
if (typeof value?.get === "function") {
|
|
167
167
|
const object = value.get(first);
|
|
168
168
|
if (object) {
|
|
169
|
-
return parts.length
|
|
169
|
+
return parts.length === 0 ? object : object.named(parts.join("/"));
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
}
|
|
@@ -33,6 +33,12 @@ export class InitializationContext {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
const resolved = object.expression(value);
|
|
37
|
+
if (resolved) {
|
|
38
|
+
assign(attribute, object, resolved);
|
|
39
|
+
continue nextOutstanding;
|
|
40
|
+
}
|
|
41
|
+
|
|
36
42
|
this.error(
|
|
37
43
|
`Unknown ${attribute.name}(${attribute.type.name}): "${value}"`
|
|
38
44
|
);
|
|
@@ -178,7 +184,11 @@ export class InitializationContext {
|
|
|
178
184
|
attribute => attribute.type === type && attribute.collection
|
|
179
185
|
)) {
|
|
180
186
|
try {
|
|
181
|
-
return assign(
|
|
187
|
+
return assign(
|
|
188
|
+
attribute,
|
|
189
|
+
owner,
|
|
190
|
+
this.read(create(type, owner, data), data)
|
|
191
|
+
);
|
|
182
192
|
} catch (e) {
|
|
183
193
|
this.error(`Unable to assign ${type.name}.${attribute.name}`, e, data);
|
|
184
194
|
}
|
package/src/network-address.mjs
CHANGED
|
@@ -100,6 +100,13 @@ export class NetworkAddress {
|
|
|
100
100
|
* @returns {Iterable<string>} addresses
|
|
101
101
|
*/
|
|
102
102
|
export function addresses(sources, options) {
|
|
103
|
+
if (sources === undefined) {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
if(sources instanceof Owner) {
|
|
107
|
+
sources = [sources];
|
|
108
|
+
}
|
|
109
|
+
|
|
103
110
|
return [
|
|
104
111
|
...new Set(
|
|
105
112
|
[...sources]
|
package/src/services/bind.mjs
CHANGED
|
@@ -15,8 +15,7 @@ import {
|
|
|
15
15
|
boolean_attribute_writable_true,
|
|
16
16
|
boolean_attribute_writable_false,
|
|
17
17
|
integer_attribute_writable,
|
|
18
|
-
integer_attribute
|
|
19
|
-
name_attribute_writable
|
|
18
|
+
integer_attribute
|
|
20
19
|
} from "pacc";
|
|
21
20
|
import {
|
|
22
21
|
Base,
|
|
@@ -158,12 +157,7 @@ class bind_zone_config extends Base {
|
|
|
158
157
|
content.push(` type ${this.type};`);
|
|
159
158
|
content.push(` file \"${zone.file}\";`);
|
|
160
159
|
content.push(
|
|
161
|
-
addressesStatement(
|
|
162
|
-
"allow-update",
|
|
163
|
-
group.allowedUpdates,
|
|
164
|
-
"none;",
|
|
165
|
-
" "
|
|
166
|
-
)
|
|
160
|
+
addressesStatement("allow-update", group.allowUpdate, "none;", " ")
|
|
167
161
|
);
|
|
168
162
|
content.push(` notify ${yesno(group.notify)};`);
|
|
169
163
|
}
|
|
@@ -189,23 +183,91 @@ class bind_zone_config extends Base {
|
|
|
189
183
|
}
|
|
190
184
|
}
|
|
191
185
|
|
|
192
|
-
class
|
|
186
|
+
class bind_object extends Base {
|
|
193
187
|
static priority = 1;
|
|
194
188
|
static attributes = {
|
|
195
|
-
name: name_attribute_writable,
|
|
196
189
|
order: { ...integer_attribute, name: "order" },
|
|
197
|
-
access: {
|
|
198
|
-
type: bindNetworkAddressTypes,
|
|
199
|
-
name: "access",
|
|
200
|
-
collection: true,
|
|
201
|
-
writable: true,
|
|
202
|
-
deferredExpression: true
|
|
203
|
-
},
|
|
204
190
|
entries: {
|
|
205
191
|
...default_collection_attribute_writable,
|
|
206
192
|
type: NetworkAddress,
|
|
207
193
|
name: "entries",
|
|
208
194
|
deferredExpression: true
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
static {
|
|
199
|
+
addType(this);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
get order() {
|
|
203
|
+
return 0;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
get service() {
|
|
207
|
+
return this.owner;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export class bind_acl extends bind_object {
|
|
212
|
+
static priority = 1;
|
|
213
|
+
|
|
214
|
+
static {
|
|
215
|
+
addType(this);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
async packageContent(outputControl) {
|
|
219
|
+
const acls = addressesStatement(
|
|
220
|
+
`acl ${this.name}`,
|
|
221
|
+
addresses(this.entries, { aggregate: true })
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
if (acls.length) {
|
|
225
|
+
await writeLines(
|
|
226
|
+
join(outputControl.dir, "etc/named"),
|
|
227
|
+
`${this.order}-acl-${this.name}.conf`,
|
|
228
|
+
acls
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const acl_attribute = {
|
|
239
|
+
...default_attribute_writable,
|
|
240
|
+
type: bind_acl,
|
|
241
|
+
name: "acl",
|
|
242
|
+
default: "'any'"
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
class bind_group extends bind_object {
|
|
246
|
+
static priority = 1;
|
|
247
|
+
static attributes = {
|
|
248
|
+
matchClients: {
|
|
249
|
+
...acl_attribute,
|
|
250
|
+
name: "matchClients"
|
|
251
|
+
},
|
|
252
|
+
allowUpdate: {
|
|
253
|
+
...acl_attribute,
|
|
254
|
+
name: "allowUpdate"
|
|
255
|
+
},
|
|
256
|
+
allowQuery: {
|
|
257
|
+
...acl_attribute,
|
|
258
|
+
name: "allowQuery"
|
|
259
|
+
},
|
|
260
|
+
allowQueryCache: {
|
|
261
|
+
...acl_attribute,
|
|
262
|
+
name: "allowQueryCache"
|
|
263
|
+
},
|
|
264
|
+
allowRecursion: {
|
|
265
|
+
...acl_attribute,
|
|
266
|
+
name: "allowRecursion"
|
|
267
|
+
},
|
|
268
|
+
allowTransfer: {
|
|
269
|
+
...acl_attribute,
|
|
270
|
+
name: "allowTransfer"
|
|
209
271
|
},
|
|
210
272
|
domains: {
|
|
211
273
|
...string_set_attribute,
|
|
@@ -232,12 +294,6 @@ class bind_group extends Base {
|
|
|
232
294
|
name: "sharedWith",
|
|
233
295
|
type: bind_group
|
|
234
296
|
},
|
|
235
|
-
allowedUpdates: {
|
|
236
|
-
type: bindNetworkAddressTypes,
|
|
237
|
-
name: "allowedUpdates",
|
|
238
|
-
collection: true,
|
|
239
|
-
writable: true
|
|
240
|
-
},
|
|
241
297
|
notify: { ...boolean_attribute_writable_false, name: "notify" },
|
|
242
298
|
hasCatalog: { ...boolean_attribute_writable_true, name: "hasCatalog" },
|
|
243
299
|
hasReverse: { ...boolean_attribute_writable_false, name: "hasReverse" },
|
|
@@ -257,7 +313,7 @@ class bind_group extends Base {
|
|
|
257
313
|
serial: {
|
|
258
314
|
...integer_attribute_writable,
|
|
259
315
|
name: "serial",
|
|
260
|
-
default: Math.ceil(Date.now() / 1000)
|
|
316
|
+
default: Math.ceil(Date.now() / (1000 * 60)) * 60
|
|
261
317
|
},
|
|
262
318
|
refresh: {
|
|
263
319
|
...duration_attribute_writable,
|
|
@@ -274,7 +330,6 @@ class bind_group extends Base {
|
|
|
274
330
|
}
|
|
275
331
|
|
|
276
332
|
foreignDomains = new Set();
|
|
277
|
-
allowedUpdates = [];
|
|
278
333
|
notify = true;
|
|
279
334
|
hasCatalog = true;
|
|
280
335
|
hasSVRRecords = true;
|
|
@@ -296,10 +351,6 @@ class bind_group extends Base {
|
|
|
296
351
|
return this.sharedWith ? this.sharedWith.order + 1 : 0;
|
|
297
352
|
}
|
|
298
353
|
|
|
299
|
-
get service() {
|
|
300
|
-
return this.owner;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
354
|
get soaUpdates() {
|
|
304
355
|
return [this.serial, this.refresh, this.retry, this.expire, this.minimum];
|
|
305
356
|
}
|
|
@@ -501,36 +552,6 @@ class bind_group extends Base {
|
|
|
501
552
|
))
|
|
502
553
|
);
|
|
503
554
|
|
|
504
|
-
return (
|
|
505
|
-
await Promise.all([
|
|
506
|
-
this.generateACLs(outputControl),
|
|
507
|
-
this.generateZoneDefs(outputControl)
|
|
508
|
-
])
|
|
509
|
-
).find(r => r)
|
|
510
|
-
? true
|
|
511
|
-
: false;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
async generateACLs(outputControl) {
|
|
515
|
-
const acls = addressesStatement(
|
|
516
|
-
`acl ${this.name}`,
|
|
517
|
-
addresses(this.access, { aggregate: true })
|
|
518
|
-
);
|
|
519
|
-
|
|
520
|
-
if (acls.length) {
|
|
521
|
-
await writeLines(
|
|
522
|
-
join(outputControl.dir, "etc/named"),
|
|
523
|
-
`0-acl-${this.name}.conf`,
|
|
524
|
-
acls
|
|
525
|
-
);
|
|
526
|
-
|
|
527
|
-
return true;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
return false;
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
async generateZoneDefs(outputControl) {
|
|
534
555
|
for (const config of this.zoneConfigs.values()) {
|
|
535
556
|
await config.write(outputControl);
|
|
536
557
|
}
|
|
@@ -556,9 +577,20 @@ class bind_group extends Base {
|
|
|
556
577
|
* @returns {(string|string[])[]}
|
|
557
578
|
*/
|
|
558
579
|
function addressesStatement(prefix, objects, empty = false, indent = "") {
|
|
559
|
-
const body = asArray(objects).map(
|
|
560
|
-
|
|
561
|
-
|
|
580
|
+
const body = asArray(objects).map(value => {
|
|
581
|
+
if (typeof value !== "string") {
|
|
582
|
+
if (value.name) {
|
|
583
|
+
value = value.name;
|
|
584
|
+
} else {
|
|
585
|
+
value = value.address;
|
|
586
|
+
|
|
587
|
+
// console.log(value);
|
|
588
|
+
//value = [...value];
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
return `${indent}${value};`;
|
|
593
|
+
});
|
|
562
594
|
|
|
563
595
|
if (body.length) {
|
|
564
596
|
return [`${indent}${prefix} {`, body, `${indent}};`];
|
|
@@ -579,6 +611,12 @@ export class bind extends CoreService {
|
|
|
579
611
|
name: "forwarders",
|
|
580
612
|
deferredExpression: true
|
|
581
613
|
},
|
|
614
|
+
acls: {
|
|
615
|
+
...default_collection_attribute_writable,
|
|
616
|
+
name: "acls",
|
|
617
|
+
type: bind_acl,
|
|
618
|
+
backpointer: owner_attribute
|
|
619
|
+
},
|
|
582
620
|
groups: {
|
|
583
621
|
...default_collection_attribute_writable,
|
|
584
622
|
name: "groups",
|
|
@@ -635,6 +673,7 @@ export class bind extends CoreService {
|
|
|
635
673
|
addType(this);
|
|
636
674
|
}
|
|
637
675
|
|
|
676
|
+
acls = new Map();
|
|
638
677
|
groups = new Map();
|
|
639
678
|
|
|
640
679
|
get serverType() {
|
|
@@ -678,6 +717,11 @@ export class bind extends CoreService {
|
|
|
678
717
|
|
|
679
718
|
const outputControl = { packageData, dir, permissions };
|
|
680
719
|
|
|
720
|
+
for (const acl of this.acls.values()) {
|
|
721
|
+
const present = await acl.packageContent(outputControl);
|
|
722
|
+
hasContent ||= present;
|
|
723
|
+
}
|
|
724
|
+
|
|
681
725
|
for (const group of this.groups.values()) {
|
|
682
726
|
const present = await group.packageContent(outputControl);
|
|
683
727
|
hasContent ||= present;
|
package/src/utils.mjs
CHANGED
|
@@ -77,7 +77,7 @@ export function sectionLines(sectionName, values) {
|
|
|
77
77
|
return lines;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
export function* setionLinesFromAttributeIterator(properties, separator="=") {
|
|
80
|
+
export function* setionLinesFromAttributeIterator(properties, separator = "=") {
|
|
81
81
|
for (const [name, value, path, attribute] of properties) {
|
|
82
82
|
if (attribute.attributes) {
|
|
83
83
|
yield `[${name}]`;
|
|
@@ -96,7 +96,18 @@ export function bridgeToJSON(bridge) {
|
|
|
96
96
|
* @returns {Array<any>}
|
|
97
97
|
*/
|
|
98
98
|
export function asArray(value) {
|
|
99
|
-
|
|
99
|
+
if (value === undefined) {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
if (Array.isArray(value)) {
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (value instanceof Iterator) {
|
|
107
|
+
return [...value];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return [value];
|
|
100
111
|
}
|
|
101
112
|
|
|
102
113
|
/**
|