pmcf 1.67.2 → 1.68.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/package.json +1 -1
- package/src/dns.mjs +17 -9
- package/src/host.mjs +47 -3
- package/src/service.mjs +3 -0
- package/types/dns.d.mts +1 -0
- package/types/service.d.mts +1 -0
package/package.json
CHANGED
package/src/dns.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from "./utils.mjs";
|
|
10
10
|
import { Base } from "./base.mjs";
|
|
11
11
|
import { addType } from "./types.mjs";
|
|
12
|
+
import { sortByPriority } from "./service.mjs";
|
|
12
13
|
|
|
13
14
|
const DNSServiceTypeDefinition = {
|
|
14
15
|
name: "dns",
|
|
@@ -79,6 +80,15 @@ export class DNSService extends Base {
|
|
|
79
80
|
return this.#forwardsTo;
|
|
80
81
|
}
|
|
81
82
|
|
|
83
|
+
get forwardsToAdresses() {
|
|
84
|
+
return this.forwardsTo
|
|
85
|
+
.map(ft => Array.from(ft.findServices(DNS_SERVICE_FILTER)))
|
|
86
|
+
.flat()
|
|
87
|
+
.sort(sortByPriority)
|
|
88
|
+
.map(s => s.rawAddresses)
|
|
89
|
+
.flat();
|
|
90
|
+
}
|
|
91
|
+
|
|
82
92
|
*findServices(filter) {
|
|
83
93
|
yield* this.owner.findServices(filter);
|
|
84
94
|
|
|
@@ -93,7 +103,7 @@ export class DNSService extends Base {
|
|
|
93
103
|
|
|
94
104
|
async resolvedConfig() {
|
|
95
105
|
const dnsServices = Array.from(this.findServices(DNS_SERVICE_FILTER)).sort(
|
|
96
|
-
|
|
106
|
+
sortByPriority
|
|
97
107
|
);
|
|
98
108
|
|
|
99
109
|
const master = dnsServices
|
|
@@ -129,13 +139,11 @@ export class DNSService extends Base {
|
|
|
129
139
|
}
|
|
130
140
|
};
|
|
131
141
|
|
|
132
|
-
const options = [
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
options.push("};");
|
|
142
|
+
const options = [
|
|
143
|
+
"forwarders {",
|
|
144
|
+
...this.forwardsToAdresses.map(a => ` ${a};`),
|
|
145
|
+
"};"
|
|
146
|
+
];
|
|
139
147
|
await writeLines(join(p1, "etc/named.d/options"), `${name}.conf`, options);
|
|
140
148
|
|
|
141
149
|
const category = [];
|
|
@@ -157,7 +165,7 @@ export class DNSService extends Base {
|
|
|
157
165
|
category
|
|
158
166
|
);
|
|
159
167
|
|
|
160
|
-
if(options.length > 2 || category.length > 2) {
|
|
168
|
+
if (options.length > 2 || category.length > 2) {
|
|
161
169
|
yield result;
|
|
162
170
|
}
|
|
163
171
|
|
package/src/host.mjs
CHANGED
|
@@ -266,10 +266,54 @@ export class Host extends Base {
|
|
|
266
266
|
if (filter) {
|
|
267
267
|
for (const service of this.#services) {
|
|
268
268
|
if (
|
|
269
|
-
filter.type ===
|
|
270
|
-
filter.
|
|
271
|
-
filter.name === service.name
|
|
269
|
+
(filter.type === undefined || filter.type === service.type) &&
|
|
270
|
+
(filter.name === undefined || filter.name === service.name)
|
|
272
271
|
) {
|
|
272
|
+
switch (typeof filter.priority) {
|
|
273
|
+
case "number":
|
|
274
|
+
if (filter.priority !== service.priority) {
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
break;
|
|
278
|
+
case "string":
|
|
279
|
+
const m = filter.priority.match(/^([=><!]+)(\d+)/);
|
|
280
|
+
if (m) {
|
|
281
|
+
const priority = parseInt(m[2]);
|
|
282
|
+
switch (m[1]) {
|
|
283
|
+
case "=":
|
|
284
|
+
if (service.priority != priority) {
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
break;
|
|
288
|
+
case "!=":
|
|
289
|
+
if (service.priority == priority) {
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
break;
|
|
293
|
+
case "<":
|
|
294
|
+
if (service.priority >= priority) {
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
break;
|
|
298
|
+
case "<=":
|
|
299
|
+
if (service.priority > priority) {
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
break;
|
|
303
|
+
case ">":
|
|
304
|
+
if (service.priority <= priority) {
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
break;
|
|
308
|
+
case ">=":
|
|
309
|
+
if (service.priority < priority) {
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
273
317
|
yield service;
|
|
274
318
|
}
|
|
275
319
|
}
|
package/src/service.mjs
CHANGED
package/types/dns.d.mts
CHANGED
package/types/service.d.mts
CHANGED