pmcf 1.67.1 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "1.67.1",
3
+ "version": "1.68.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
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
- (a, b) => a.priority - b.priority
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 = ["forwarders {"];
133
- for (const s of this.forwardsTo) {
134
- for (const dns of s.findServices(DNS_SERVICE_FILTER)) {
135
- options.push(...(dns.rawAddresses.map(a=>` ${a};`)));
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
 
@@ -167,7 +175,7 @@ export class DNSService extends Base {
167
175
  name: `named-zones-${name}`,
168
176
  description: `zone definitions for ${this.fullName}`,
169
177
  dependencies: ["mf-named"],
170
- replaces: ["mf-named-zones", `named-${name}`],
178
+ replaces: ["mf-named-zones"],
171
179
  access: "private"
172
180
  };
173
181
 
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.type === service.type ||
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
@@ -1,6 +1,9 @@
1
1
  import { Base } from "./base.mjs";
2
2
  import { addType } from "./types.mjs";
3
3
 
4
+
5
+ export const sortByPriority = (a, b) => a.priority - b.priority;
6
+
4
7
  const ServiceTypes = {
5
8
  dns: { protocol: "udp", port: 53 },
6
9
  ldap: { protocol: "tcp", port: 389 },
package/types/dns.d.mts CHANGED
@@ -76,6 +76,7 @@ export class DNSService extends Base {
76
76
  get soaUpdates(): number[];
77
77
  set forwardsTo(value: any[]);
78
78
  get forwardsTo(): any[];
79
+ get forwardsToAdresses(): any[];
79
80
  get domains(): any[];
80
81
  resolvedConfig(): Promise<{
81
82
  DNS: string;
@@ -1,3 +1,4 @@
1
+ export function sortByPriority(a: any, b: any): number;
1
2
  export class Service extends Base {
2
3
  static get typeDefinition(): {
3
4
  name: string;