pmcf 1.87.3 → 1.87.4
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/dns.mjs +26 -18
package/package.json
CHANGED
package/src/dns.mjs
CHANGED
|
@@ -41,6 +41,22 @@ const DNSServiceTypeDefinition = {
|
|
|
41
41
|
|
|
42
42
|
const DNS_SERVICE_FILTER = { type: DNSServiceTypeDefinition.name };
|
|
43
43
|
|
|
44
|
+
function addressList(objects) {
|
|
45
|
+
return Array.from(objects).map(object =>
|
|
46
|
+
typeof object === "string" ? object : object.name
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function addressesStatement(prefix, objects, generateEmpty = false) {
|
|
51
|
+
const body = addressList(objects).map(name => ` ${name};`);
|
|
52
|
+
|
|
53
|
+
if (body.length || generateEmpty) {
|
|
54
|
+
return [`${prefix} {`, body, "};"];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
|
|
44
60
|
export class DNSService extends Base {
|
|
45
61
|
allowedUpdates = [];
|
|
46
62
|
recordTTL = "1W";
|
|
@@ -146,11 +162,10 @@ export class DNSService extends Base {
|
|
|
146
162
|
}
|
|
147
163
|
};
|
|
148
164
|
|
|
149
|
-
const options =
|
|
150
|
-
"forwarders
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
];
|
|
165
|
+
const options = addressesStatement(
|
|
166
|
+
"forwarders",
|
|
167
|
+
serviceAddresses(this.source, DNS_SERVICE_FILTER)
|
|
168
|
+
);
|
|
154
169
|
if (options.length > 2) {
|
|
155
170
|
await writeLines(
|
|
156
171
|
join(p1, "etc/named/options"),
|
|
@@ -160,22 +175,15 @@ export class DNSService extends Base {
|
|
|
160
175
|
}
|
|
161
176
|
|
|
162
177
|
const acls = [
|
|
163
|
-
"acl trusted
|
|
164
|
-
|
|
165
|
-
"
|
|
166
|
-
|
|
167
|
-
"acl protected {",
|
|
168
|
-
...Array.from(subnets(this.protected)).map(subnet => ` ${subnet.name};`),
|
|
169
|
-
"};",
|
|
170
|
-
"",
|
|
171
|
-
"acl open {",
|
|
172
|
-
"};"
|
|
173
|
-
];
|
|
178
|
+
addressesStatement("acl trusted", subnets(this.trusted)),
|
|
179
|
+
addressesStatement("acl protected", subnets(this.protected)),
|
|
180
|
+
addressesStatement("acl open", [], true)
|
|
181
|
+
].flat();
|
|
174
182
|
|
|
175
|
-
if (
|
|
183
|
+
if (acls.length) {
|
|
176
184
|
await writeLines(join(p1, "etc/named"), `0-acl-${name}.conf`, acls);
|
|
177
185
|
}
|
|
178
|
-
if (options.length
|
|
186
|
+
if (options.length || acls.length) {
|
|
179
187
|
yield packageData;
|
|
180
188
|
}
|
|
181
189
|
|