pmcf 6.28.4 → 6.29.1
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/initialization-context.mjs +11 -1
- package/src/network-address.mjs +7 -0
- package/src/services/bind.mjs +107 -63
package/package.json
CHANGED
|
@@ -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,14 +294,8 @@ 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
|
-
hasCatalog: { ...
|
|
298
|
+
hasCatalog: { ...boolean_attribute_writable_false, name: "hasCatalog" },
|
|
243
299
|
hasReverse: { ...boolean_attribute_writable_false, name: "hasReverse" },
|
|
244
300
|
hasSVRRecords: {
|
|
245
301
|
...boolean_attribute_writable_false,
|
|
@@ -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;
|