pmcf 6.18.2 → 6.20.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 +20 -20
- package/package.json +1 -1
- package/src/network-address.mjs +26 -14
- package/src/network-interfaces/network-interface.mjs +9 -2
- package/src/services/bind.mjs +201 -267
package/README.md
CHANGED
|
@@ -78,27 +78,27 @@ 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
|
* [type](#type)
|
|
82
85
|
* [SystemdJournalRemoteService](#systemdjournalremoteservice)
|
|
83
86
|
* [Properties](#properties)
|
|
84
87
|
* [systemdConfigs](#systemdconfigs)
|
|
85
|
-
* [Parameters](#parameters-
|
|
88
|
+
* [Parameters](#parameters-16)
|
|
86
89
|
* [SystemdJournalUploadService](#systemdjournaluploadservice)
|
|
87
90
|
* [Properties](#properties-1)
|
|
88
91
|
* [systemdConfigs](#systemdconfigs-1)
|
|
89
|
-
* [Parameters](#parameters-
|
|
92
|
+
* [Parameters](#parameters-17)
|
|
90
93
|
* [NetworkAddress](#networkaddress)
|
|
91
|
-
* [Parameters](#parameters-
|
|
94
|
+
* [Parameters](#parameters-18)
|
|
92
95
|
* [subnet](#subnet)
|
|
93
96
|
* [networkInterface](#networkinterface)
|
|
94
97
|
* [address](#address)
|
|
95
98
|
* [addresses](#addresses)
|
|
96
|
-
* [Parameters](#parameters-18)
|
|
97
|
-
* [cidrAddresses](#cidraddresses)
|
|
98
99
|
* [Parameters](#parameters-19)
|
|
99
|
-
* [
|
|
100
|
-
* [
|
|
101
|
-
* [Parameters](#parameters-20)
|
|
100
|
+
* [cidrAddresses](#cidraddresses)
|
|
101
|
+
* [Parameters](#parameters-20)
|
|
102
102
|
* [families](#families)
|
|
103
103
|
* [secretName](#secretname)
|
|
104
104
|
* [directHosts](#directhosts)
|
|
@@ -293,6 +293,18 @@ Keeps track of all in flight object creations and loose ends during config initi
|
|
|
293
293
|
|
|
294
294
|
* `directory` (optional, default `"/"`)
|
|
295
295
|
|
|
296
|
+
## SkeletonNetworkInterface
|
|
297
|
+
|
|
298
|
+
**Extends ServiceOwner**
|
|
299
|
+
|
|
300
|
+
### networkAddresses
|
|
301
|
+
|
|
302
|
+
#### Parameters
|
|
303
|
+
|
|
304
|
+
* `filter` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `n=>true`)
|
|
305
|
+
|
|
306
|
+
Returns **Iterable<[NetworkAddress](#networkaddress)>** 
|
|
307
|
+
|
|
296
308
|
## type
|
|
297
309
|
|
|
298
310
|
Type of the group.
|
|
@@ -374,18 +386,6 @@ Returns **Iterable<[string](https://developer.mozilla.org/docs/Web/JavaScript/Re
|
|
|
374
386
|
|
|
375
387
|
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)>** 
|
|
376
388
|
|
|
377
|
-
## SkeletonNetworkInterface
|
|
378
|
-
|
|
379
|
-
**Extends ServiceOwner**
|
|
380
|
-
|
|
381
|
-
### networkAddresses
|
|
382
|
-
|
|
383
|
-
#### Parameters
|
|
384
|
-
|
|
385
|
-
* `filter` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `n=>true`)
|
|
386
|
-
|
|
387
|
-
Returns **Iterable<[NetworkAddress](#networkaddress)>** 
|
|
388
|
-
|
|
389
389
|
## families
|
|
390
390
|
|
|
391
391
|
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
package/src/network-address.mjs
CHANGED
|
@@ -14,20 +14,20 @@ import { NetworkInterface } from "./network-interfaces/network-interface.mjs";
|
|
|
14
14
|
*
|
|
15
15
|
*/
|
|
16
16
|
export class NetworkAddress {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
static name = "network-address";
|
|
18
|
+
static priority = 1;
|
|
19
|
+
static key = "address";
|
|
20
|
+
static attributes = {
|
|
21
|
+
address: { ...name_attribute, name: "address" },
|
|
22
|
+
cidrAddress: { ...string_attribute, name: "cidrAddress" },
|
|
23
|
+
networkInterface: {
|
|
24
|
+
...default_attribute,
|
|
25
|
+
name: "networkInterface",
|
|
26
|
+
type: "network_interface"
|
|
27
|
+
},
|
|
28
|
+
family: { ...string_attribute, name: "family" }
|
|
29
|
+
};
|
|
30
|
+
|
|
31
31
|
static {
|
|
32
32
|
addType(this);
|
|
33
33
|
}
|
|
@@ -48,10 +48,18 @@ export class NetworkAddress {
|
|
|
48
48
|
this.subnet = subnet;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
get host() {
|
|
52
|
+
return this.networkInterface.host;
|
|
53
|
+
}
|
|
54
|
+
|
|
51
55
|
get domainNames() {
|
|
52
56
|
return this.networkInterface.domainNames;
|
|
53
57
|
}
|
|
54
58
|
|
|
59
|
+
get domains() {
|
|
60
|
+
return this.networkInterface.domains;
|
|
61
|
+
}
|
|
62
|
+
|
|
55
63
|
get family() {
|
|
56
64
|
return familyIP(this.address);
|
|
57
65
|
}
|
|
@@ -60,6 +68,10 @@ export class NetworkAddress {
|
|
|
60
68
|
return formatCIDR(this.address, this.subnet.prefixLength);
|
|
61
69
|
}
|
|
62
70
|
|
|
71
|
+
get fullName() {
|
|
72
|
+
return `${this.networkInterface.fullName}/${decodeIP(this.address)}`;
|
|
73
|
+
}
|
|
74
|
+
|
|
63
75
|
toString() {
|
|
64
76
|
return `${this.networkInterface.fullName} ${decodeIP(this.address)}`;
|
|
65
77
|
}
|
|
@@ -107,10 +107,17 @@ export class NetworkInterface extends SkeletonNetworkInterface {
|
|
|
107
107
|
set hostName(value) {
|
|
108
108
|
this._hostName = value;
|
|
109
109
|
}
|
|
110
|
+
|
|
111
|
+
get domains() {
|
|
112
|
+
if (!this.host) {
|
|
113
|
+
return new Set();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return this.host.localDomains;
|
|
117
|
+
}
|
|
110
118
|
|
|
111
119
|
get domainNames() {
|
|
112
|
-
if(!this.host) {
|
|
113
|
-
//console.log("NO HOST",this.fullName);
|
|
120
|
+
if (!this.host) {
|
|
114
121
|
return new Set();
|
|
115
122
|
}
|
|
116
123
|
return this.hostName
|
package/src/services/bind.mjs
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { join, dirname } from "node:path";
|
|
2
2
|
import { createHmac } from "node:crypto";
|
|
3
3
|
import { FileContentProvider } from "npm-pkgbuild";
|
|
4
|
-
import {
|
|
5
|
-
isLinkLocal,
|
|
6
|
-
reverseArpa,
|
|
7
|
-
FAMILY_IPV4,
|
|
8
|
-
FAMILY_IPV6
|
|
9
|
-
} from "ip-utilties";
|
|
4
|
+
import { reverseArpa, FAMILY_IPV4, FAMILY_IPV6 } from "ip-utilties";
|
|
10
5
|
import {
|
|
11
6
|
default_collection_attribute,
|
|
12
7
|
default_collection_attribute_writable,
|
|
@@ -14,7 +9,6 @@ import {
|
|
|
14
9
|
duration_attribute_writable,
|
|
15
10
|
name_attribute,
|
|
16
11
|
string_attribute,
|
|
17
|
-
string_set_attribute_writable,
|
|
18
12
|
string_set_attribute,
|
|
19
13
|
boolean_attribute_writable_true,
|
|
20
14
|
boolean_attribute_writable_false,
|
|
@@ -40,6 +34,7 @@ import {
|
|
|
40
34
|
} from "../dns-utils.mjs";
|
|
41
35
|
import { addHook } from "../hooks.mjs";
|
|
42
36
|
import { owner_attribute } from "../common-attributes.mjs";
|
|
37
|
+
import { NetworkAddress } from "../network-address.mjs";
|
|
43
38
|
|
|
44
39
|
const bindNetworkAddressTypes = networkAddressType + "|bind_group";
|
|
45
40
|
|
|
@@ -68,25 +63,48 @@ class bind_zone extends Base {
|
|
|
68
63
|
return this.id;
|
|
69
64
|
}
|
|
70
65
|
|
|
71
|
-
get directory() {
|
|
72
|
-
return this.source.name;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
66
|
get file() {
|
|
76
67
|
return `${this.directory}/${this.domain}.zone`;
|
|
77
68
|
}
|
|
78
69
|
|
|
79
|
-
constructor(owner, id, config,
|
|
70
|
+
constructor(owner, id, config, location) {
|
|
80
71
|
super();
|
|
81
72
|
this.id = id;
|
|
82
73
|
this.config = config;
|
|
83
|
-
this.
|
|
74
|
+
this.directory = location;
|
|
84
75
|
this.records = new Set(owner.defaultRecords);
|
|
85
76
|
|
|
77
|
+
if (owner.hasLocationRecord) {
|
|
78
|
+
this.records.add(DNSRecord("location", "TXT", location));
|
|
79
|
+
}
|
|
80
|
+
|
|
86
81
|
config.zones.push(this);
|
|
87
82
|
}
|
|
88
83
|
}
|
|
89
84
|
|
|
85
|
+
class catalog_zone extends bind_zone {
|
|
86
|
+
static attributes = {
|
|
87
|
+
version: { ...string_attribute, name: "version" }
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
static {
|
|
91
|
+
addType(this);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
constructor(owner, id, config, location) {
|
|
95
|
+
super(owner, id, config, location);
|
|
96
|
+
this.records.add(DNSRecord("version", "TXT", `"${this.version}"`));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
get isCatalog() {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
get version() {
|
|
104
|
+
return "2";
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
90
108
|
class bind_zone_config extends Base {
|
|
91
109
|
static priority = 1;
|
|
92
110
|
static attributes = {
|
|
@@ -104,10 +122,57 @@ class bind_zone_config extends Base {
|
|
|
104
122
|
}
|
|
105
123
|
|
|
106
124
|
constructor(owner, name) {
|
|
107
|
-
super();
|
|
108
|
-
this.owner = owner;
|
|
125
|
+
super(owner);
|
|
109
126
|
this.name = name;
|
|
110
127
|
}
|
|
128
|
+
|
|
129
|
+
async write(outputControl, group) {
|
|
130
|
+
const dir = outputControl.dir;
|
|
131
|
+
|
|
132
|
+
console.log(`config: ${group.name}/${this.name}`);
|
|
133
|
+
|
|
134
|
+
const content = [];
|
|
135
|
+
|
|
136
|
+
for (const zone of this.zones) {
|
|
137
|
+
console.log(` file: ${zone.file}`);
|
|
138
|
+
|
|
139
|
+
content.push(`zone \"${zone.id}\" {`);
|
|
140
|
+
|
|
141
|
+
if (group.sharedWith) {
|
|
142
|
+
content.push(` in-view ${group.sharedWith.name};`);
|
|
143
|
+
} else {
|
|
144
|
+
content.push(` type ${this.type};`);
|
|
145
|
+
content.push(` file \"${zone.file}\";`);
|
|
146
|
+
content.push(
|
|
147
|
+
addressesStatement(
|
|
148
|
+
"allow-update",
|
|
149
|
+
group.allowedUpdates,
|
|
150
|
+
"none;",
|
|
151
|
+
" "
|
|
152
|
+
)
|
|
153
|
+
);
|
|
154
|
+
content.push(` notify ${yesno(group.notify)};`);
|
|
155
|
+
}
|
|
156
|
+
content.push(`};`, "");
|
|
157
|
+
|
|
158
|
+
let maxKeyLength = 0;
|
|
159
|
+
for (const r of zone.records) {
|
|
160
|
+
if (r.key.length > maxKeyLength) {
|
|
161
|
+
maxKeyLength = r.key.length;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
await writeLines(
|
|
166
|
+
join(dir, "var/lib/named"),
|
|
167
|
+
zone.file,
|
|
168
|
+
[...zone.records]
|
|
169
|
+
.sort(sortZoneRecords)
|
|
170
|
+
.map(r => r.toString(maxKeyLength, group.recordTTL))
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
await writeLines(join(dir, `etc/named/${group.name}`), this.name, content);
|
|
175
|
+
}
|
|
111
176
|
}
|
|
112
177
|
|
|
113
178
|
class bind_group extends Base {
|
|
@@ -121,19 +186,11 @@ class bind_group extends Base {
|
|
|
121
186
|
collection: true,
|
|
122
187
|
writable: true
|
|
123
188
|
},
|
|
124
|
-
excludeInterfaceKinds: {
|
|
125
|
-
...string_set_attribute_writable,
|
|
126
|
-
name: "excludeInterfaceKinds"
|
|
127
|
-
},
|
|
128
|
-
exclude: {
|
|
129
|
-
...default_collection_attribute_writable,
|
|
130
|
-
name: "exclude",
|
|
131
|
-
type: networkAddressType
|
|
132
|
-
},
|
|
133
189
|
entries: {
|
|
134
190
|
...default_collection_attribute_writable,
|
|
135
|
-
type:
|
|
136
|
-
name: "entries"
|
|
191
|
+
type: NetworkAddress,
|
|
192
|
+
name: "entries",
|
|
193
|
+
expression: true
|
|
137
194
|
},
|
|
138
195
|
domains: {
|
|
139
196
|
...string_set_attribute,
|
|
@@ -203,22 +260,26 @@ class bind_group extends Base {
|
|
|
203
260
|
|
|
204
261
|
access = [];
|
|
205
262
|
allowedUpdates = [];
|
|
206
|
-
entries = [];
|
|
207
|
-
zoneConfigs = [];
|
|
208
|
-
exclude = new Set();
|
|
209
|
-
excludeInterfaceKinds = new Set();
|
|
210
263
|
notify = true;
|
|
211
264
|
hasCatalog = true;
|
|
212
265
|
hasSVRRecords = true;
|
|
213
266
|
hasLinkLocalAdresses = bind_group.attributes.hasLinkLocalAdresses.default;
|
|
214
267
|
recordTTL = "1W";
|
|
215
268
|
|
|
269
|
+
set entries(value) {
|
|
270
|
+
this._entries = value;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
get entries() {
|
|
274
|
+
return this._entries ? this.expression(this._entries) : [];
|
|
275
|
+
}
|
|
276
|
+
|
|
216
277
|
/**
|
|
217
278
|
* Type of the group.
|
|
218
279
|
* @return {string} view | unknown
|
|
219
280
|
*/
|
|
220
281
|
get type() {
|
|
221
|
-
if (this.
|
|
282
|
+
if (this.sharedWith || this._entries) {
|
|
222
283
|
return "view";
|
|
223
284
|
}
|
|
224
285
|
|
|
@@ -261,179 +322,82 @@ class bind_group extends Base {
|
|
|
261
322
|
|
|
262
323
|
get domains() {
|
|
263
324
|
return this.entries.reduce(
|
|
264
|
-
(all,
|
|
325
|
+
(all, address) => all.union(address.domains),
|
|
265
326
|
new Set()
|
|
266
327
|
);
|
|
267
328
|
}
|
|
268
329
|
|
|
269
|
-
get
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
for (const source of this.entries) {
|
|
274
|
-
for (const domain of source.localDomains) {
|
|
275
|
-
const config = new bind_zone_config(this, `${domain}.zone.conf`);
|
|
276
|
-
|
|
277
|
-
this.zoneConfigs.push(config);
|
|
330
|
+
get zoneConfigs() {
|
|
331
|
+
this.zones;
|
|
332
|
+
return this._zoneConfigs || new Map();
|
|
333
|
+
}
|
|
278
334
|
|
|
279
|
-
|
|
335
|
+
intoCatalog(zone, locationName) {
|
|
336
|
+
if (this.hasCatalog) {
|
|
337
|
+
const catalogConfig = this.zoneConfigs.getOrInsertComputed(
|
|
338
|
+
`catalog.${zone.id}`,
|
|
339
|
+
domain => new bind_zone_config(this, `${domain}.zone.conf`)
|
|
340
|
+
);
|
|
280
341
|
|
|
281
|
-
|
|
342
|
+
const catalogZone = this._zones.getOrInsertComputed(
|
|
343
|
+
`catalog.${zone.id}`,
|
|
344
|
+
domain => new catalog_zone(this, domain, catalogConfig, locationName)
|
|
345
|
+
);
|
|
282
346
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
domainNames,
|
|
288
|
-
family
|
|
289
|
-
} of source.networkAddresses()) {
|
|
290
|
-
// console.log(address);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
347
|
+
const hash = createHmac("sha1", zone.id).digest("hex");
|
|
348
|
+
catalogZone.records.add(
|
|
349
|
+
DNSRecord(`${hash}.zones`, "PTR", dnsFullName(zone.id))
|
|
350
|
+
);
|
|
293
351
|
}
|
|
294
|
-
return zs;
|
|
295
|
-
}
|
|
296
352
|
|
|
297
|
-
|
|
298
|
-
outputControl.packageData.sources.push(
|
|
299
|
-
...(await Array.fromAsync(
|
|
300
|
-
this.templateContent(...outputControl.permissions)
|
|
301
|
-
))
|
|
302
|
-
);
|
|
303
|
-
|
|
304
|
-
return (
|
|
305
|
-
await Promise.all([
|
|
306
|
-
this.generateACLs(outputControl),
|
|
307
|
-
this.generateZoneDefs(outputControl, this.entries)
|
|
308
|
-
])
|
|
309
|
-
).find(r => r)
|
|
310
|
-
? true
|
|
311
|
-
: false;
|
|
353
|
+
return zone;
|
|
312
354
|
}
|
|
313
355
|
|
|
314
|
-
|
|
315
|
-
const
|
|
316
|
-
`acl ${this.name}`,
|
|
317
|
-
addresses(this.access, { aggregate: true })
|
|
318
|
-
);
|
|
356
|
+
get zones() {
|
|
357
|
+
const entries = [...this.entries];
|
|
319
358
|
|
|
320
|
-
if (
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
`0-acl-${this.name}.conf`,
|
|
324
|
-
acls
|
|
325
|
-
);
|
|
359
|
+
if (!this._zones && entries.length > 0) {
|
|
360
|
+
this._zoneConfigs = new Map();
|
|
361
|
+
this._zones = new Map();
|
|
326
362
|
|
|
327
|
-
|
|
328
|
-
|
|
363
|
+
const hosts = new Set();
|
|
364
|
+
const addresses = new Set();
|
|
329
365
|
|
|
330
|
-
|
|
331
|
-
}
|
|
366
|
+
console.log("ZONES for", this.owner.owner.name, this.name);
|
|
332
367
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
"ZONE",
|
|
337
|
-
source.toString(),
|
|
338
|
-
[...source.localDomains].join(" ")
|
|
339
|
-
);
|
|
368
|
+
for (const na of entries) {
|
|
369
|
+
const address = na.address;
|
|
370
|
+
const host = na.host;
|
|
340
371
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
const reverseZones = new Map();
|
|
344
|
-
|
|
345
|
-
const config = {
|
|
346
|
-
name: `${domain}.zone.conf`,
|
|
347
|
-
type: this.service.serverType,
|
|
348
|
-
zones: []
|
|
349
|
-
};
|
|
350
|
-
outputControl.configs.push(config);
|
|
351
|
-
|
|
352
|
-
const zone = {
|
|
353
|
-
id: domain,
|
|
354
|
-
config,
|
|
355
|
-
file: `${locationName}/${domain}.zone`,
|
|
356
|
-
records: new Set(this.defaultRecords)
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
if (this.hasLocationRecord) {
|
|
360
|
-
zone.records.add(DNSRecord("location", "TXT", locationName));
|
|
361
|
-
}
|
|
372
|
+
if (!addresses.has(address)) {
|
|
373
|
+
addresses.add(address);
|
|
362
374
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
this.assignCatalog(outputControl, zone, domain);
|
|
366
|
-
|
|
367
|
-
const hosts = new Set();
|
|
368
|
-
const addresses = new Set();
|
|
369
|
-
|
|
370
|
-
for (const {
|
|
371
|
-
address,
|
|
372
|
-
subnet,
|
|
373
|
-
networkInterface,
|
|
374
|
-
domainNames,
|
|
375
|
-
family
|
|
376
|
-
} of source.networkAddresses()) {
|
|
377
|
-
if (
|
|
378
|
-
!this.exclude.has(networkInterface.network) &&
|
|
379
|
-
!this.excludeInterfaceKinds.has(networkInterface.kind)
|
|
380
|
-
) {
|
|
381
|
-
if (
|
|
382
|
-
!addresses.has(address) &&
|
|
383
|
-
(this.hasLinkLocalAdresses || !isLinkLocal(address))
|
|
384
|
-
) {
|
|
385
|
-
addresses.add(address);
|
|
386
|
-
|
|
387
|
-
let reverseZone = reverseZones.get(subnet);
|
|
388
|
-
|
|
389
|
-
// is there already a matching subnet ?
|
|
390
|
-
if (!reverseZone) {
|
|
391
|
-
for (const [presentSubnet, zone] of reverseZones) {
|
|
392
|
-
if (presentSubnet.matchesAddress(subnet.address)) {
|
|
393
|
-
reverseZone = zone;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
375
|
+
const locationName = host.owner.name;
|
|
397
376
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
file: `${locationName}/${id}.zone`,
|
|
404
|
-
records: new Set(this.defaultRecords)
|
|
405
|
-
};
|
|
406
|
-
config.zones.push(reverseZone);
|
|
407
|
-
reverseZones.set(subnet, reverseZone);
|
|
408
|
-
|
|
409
|
-
this.assignCatalog(outputControl, reverseZone, domain);
|
|
410
|
-
}
|
|
377
|
+
for (const domain of na.domains) {
|
|
378
|
+
const config = this.zoneConfigs.getOrInsertComputed(
|
|
379
|
+
domain,
|
|
380
|
+
domain => new bind_zone_config(this, `${domain}.zone.conf`)
|
|
381
|
+
);
|
|
411
382
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
)
|
|
428
|
-
);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
383
|
+
const zone = this._zones.getOrInsertComputed(domain, domain =>
|
|
384
|
+
this.intoCatalog(
|
|
385
|
+
new bind_zone(this, domain, config, locationName),
|
|
386
|
+
locationName
|
|
387
|
+
)
|
|
388
|
+
);
|
|
389
|
+
|
|
390
|
+
const reverseZone = this._zones.getOrInsertComputed(
|
|
391
|
+
reverseArpa(na.subnet.prefix),
|
|
392
|
+
domain =>
|
|
393
|
+
this.intoCatalog(
|
|
394
|
+
new bind_zone(this, domain, config, locationName),
|
|
395
|
+
locationName
|
|
396
|
+
)
|
|
397
|
+
);
|
|
432
398
|
|
|
433
|
-
const host = networkInterface.host;
|
|
434
399
|
if (host && !hosts.has(host)) {
|
|
435
400
|
hosts.add(host);
|
|
436
|
-
|
|
437
401
|
for (const foreignDomainName of host.foreignDomainNames) {
|
|
438
402
|
zone.records.add(
|
|
439
403
|
DNSRecord("outfacing", "PTR", dnsFullName(foreignDomainName))
|
|
@@ -455,105 +419,75 @@ class bind_group extends Base {
|
|
|
455
419
|
zone.records.add(r);
|
|
456
420
|
}
|
|
457
421
|
}
|
|
422
|
+
|
|
423
|
+
for (const domainName of na.domainNames) {
|
|
424
|
+
if (domainName.endsWith(domain) && domainName[0] !== "*") {
|
|
425
|
+
zone.records.add(
|
|
426
|
+
DNSRecord(
|
|
427
|
+
dnsFullName(domainName),
|
|
428
|
+
dnsRecordTypeForAddressFamily(na.family),
|
|
429
|
+
address
|
|
430
|
+
)
|
|
431
|
+
);
|
|
432
|
+
|
|
433
|
+
reverseZone.records.add(
|
|
434
|
+
DNSRecord(
|
|
435
|
+
dnsFullName(reverseArpa(address)),
|
|
436
|
+
"PTR",
|
|
437
|
+
dnsFullName(domainName)
|
|
438
|
+
)
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
458
442
|
}
|
|
459
443
|
}
|
|
460
444
|
}
|
|
461
445
|
}
|
|
462
|
-
|
|
463
|
-
await this.writeZones(outputControl);
|
|
464
|
-
|
|
465
|
-
return outputControl.packageData;
|
|
446
|
+
return this._zones;
|
|
466
447
|
}
|
|
467
448
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
const directory = dirname(zone.file);
|
|
474
|
-
|
|
475
|
-
let catalogZone = outputControl.catalogs.get(directory);
|
|
476
|
-
|
|
477
|
-
if (!catalogZone) {
|
|
478
|
-
catalogZone = {
|
|
479
|
-
catalog: true,
|
|
480
|
-
id: `catalog.${name}`,
|
|
481
|
-
file: `${directory}/catalog.${name}.zone`,
|
|
482
|
-
records: new Set([
|
|
483
|
-
...this.defaultRecords,
|
|
484
|
-
DNSRecord("version", "TXT", '"2"')
|
|
485
|
-
])
|
|
486
|
-
};
|
|
487
|
-
outputControl.catalogs.set(directory, catalogZone);
|
|
488
|
-
|
|
489
|
-
const config = {
|
|
490
|
-
name: `catalog.${name}.zone.conf`,
|
|
491
|
-
type: this.service.serverType,
|
|
492
|
-
zones: [catalogZone]
|
|
493
|
-
};
|
|
494
|
-
catalogZone.config = config;
|
|
495
|
-
outputControl.configs.push(config);
|
|
496
|
-
}
|
|
497
|
-
zone.catalogZone = catalogZone;
|
|
498
|
-
|
|
499
|
-
const hash = createHmac("sha1", zone.id).digest("hex");
|
|
500
|
-
catalogZone.records.add(
|
|
501
|
-
DNSRecord(`${hash}.zones`, "PTR", dnsFullName(zone.id))
|
|
449
|
+
async packageContent(outputControl) {
|
|
450
|
+
outputControl.packageData.sources.push(
|
|
451
|
+
...(await Array.fromAsync(
|
|
452
|
+
this.templateContent(...outputControl.permissions)
|
|
453
|
+
))
|
|
502
454
|
);
|
|
503
455
|
|
|
504
|
-
return
|
|
456
|
+
return (
|
|
457
|
+
await Promise.all([
|
|
458
|
+
this.generateACLs(outputControl),
|
|
459
|
+
this.generateZoneDefs(outputControl)
|
|
460
|
+
])
|
|
461
|
+
).find(r => r)
|
|
462
|
+
? true
|
|
463
|
+
: false;
|
|
505
464
|
}
|
|
506
465
|
|
|
507
|
-
async
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
for (const zone of config.zones) {
|
|
514
|
-
console.log(` file: ${zone.file}`);
|
|
515
|
-
|
|
516
|
-
content.push(`zone \"${zone.id}\" {`);
|
|
466
|
+
async generateACLs(outputControl) {
|
|
467
|
+
const acls = addressesStatement(
|
|
468
|
+
`acl ${this.name}`,
|
|
469
|
+
addresses(this.access, { aggregate: true })
|
|
470
|
+
);
|
|
517
471
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
addressesStatement(
|
|
525
|
-
"allow-update",
|
|
526
|
-
this.allowedUpdates,
|
|
527
|
-
"none;",
|
|
528
|
-
" "
|
|
529
|
-
)
|
|
530
|
-
);
|
|
531
|
-
content.push(` notify ${yesno(this.notify)};`);
|
|
532
|
-
}
|
|
533
|
-
content.push(`};`, "");
|
|
472
|
+
if (acls.length) {
|
|
473
|
+
await writeLines(
|
|
474
|
+
join(outputControl.dir, "etc/named"),
|
|
475
|
+
`0-acl-${this.name}.conf`,
|
|
476
|
+
acls
|
|
477
|
+
);
|
|
534
478
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
if (r.key.length > maxKeyLength) {
|
|
538
|
-
maxKeyLength = r.key.length;
|
|
539
|
-
}
|
|
540
|
-
}
|
|
479
|
+
return true;
|
|
480
|
+
}
|
|
541
481
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
zone.file,
|
|
545
|
-
[...zone.records]
|
|
546
|
-
.sort(sortZoneRecords)
|
|
547
|
-
.map(r => r.toString(maxKeyLength, this.recordTTL))
|
|
548
|
-
);
|
|
549
|
-
}
|
|
482
|
+
return false;
|
|
483
|
+
}
|
|
550
484
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
content
|
|
555
|
-
);
|
|
485
|
+
async generateZoneDefs(outputControl) {
|
|
486
|
+
for (const config of this.zoneConfigs.values()) {
|
|
487
|
+
await config.write(outputControl, this);
|
|
556
488
|
}
|
|
489
|
+
|
|
490
|
+
return outputControl.packageData;
|
|
557
491
|
}
|
|
558
492
|
}
|
|
559
493
|
|
|
@@ -753,7 +687,7 @@ export class bind extends ExtraSourceService {
|
|
|
753
687
|
}
|
|
754
688
|
}
|
|
755
689
|
|
|
756
|
-
this.assignCatalog(outputControl, zone, `outfacting.${host.owner.name}`);
|
|
690
|
+
//this.assignCatalog(outputControl, zone, `outfacting.${host.owner.name}`);
|
|
757
691
|
});
|
|
758
692
|
}
|
|
759
693
|
}
|