pmcf 1.69.0 → 1.70.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.69.0",
3
+ "version": "1.70.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/dns.mjs CHANGED
@@ -31,7 +31,7 @@ const DNSServiceTypeDefinition = {
31
31
  expire: { type: "string", collection: false, writeable: true },
32
32
  minimum: { type: "string", collection: false, writeable: true },
33
33
  forwardsTo: { type: "network", collection: true, writeable: true },
34
- trusts: { type: "network", collection: true, writeable: true },
34
+ trusted: { type: "network", collection: true, writeable: true },
35
35
  allowedUpdates: { type: "string", collection: true, writeable: true }
36
36
  }
37
37
  };
@@ -46,7 +46,7 @@ export class DNSService extends Base {
46
46
  hasLinkLocalAdresses = true;
47
47
  notify = true;
48
48
  #forwardsTo = [];
49
- #trusts = [];
49
+ #trusted = [];
50
50
 
51
51
  refresh = 36000;
52
52
  retry = 72000;
@@ -75,12 +75,12 @@ export class DNSService extends Base {
75
75
  return [this.refresh, this.retry, this.expire, this.minimum];
76
76
  }
77
77
 
78
- set trusts(value) {
79
- this.#trusts.push(value);
78
+ set trusted(value) {
79
+ this.#trusted.push(value);
80
80
  }
81
81
 
82
- get trusts() {
83
- return this.#trusts;
82
+ get trusted() {
83
+ return this.#trusted;
84
84
  }
85
85
 
86
86
  set forwardsTo(value) {
@@ -159,7 +159,7 @@ export class DNSService extends Base {
159
159
 
160
160
  const category = [
161
161
  "acl trusted {",
162
- ...Array.from(subnets(this.trusts)).map(subnet => ` ${subnet.name};`),
162
+ ...Array.from(subnets(this.trusted)).map(subnet => ` ${subnet.name};`),
163
163
  "};"
164
164
  ];
165
165
 
package/src/host.mjs CHANGED
@@ -11,6 +11,7 @@ import {
11
11
  formatCIDR,
12
12
  hasWellKnownSubnet
13
13
  } from "./utils.mjs";
14
+ import { serviceFilter } from "./service.mjs";
14
15
  import { addType } from "./types.mjs";
15
16
  import {
16
17
  generateNetworkDefs,
@@ -263,63 +264,7 @@ export class Host extends Base {
263
264
  }
264
265
 
265
266
  *findServices(filter) {
266
- if (filter) {
267
- for (const service of this.#services) {
268
- if (
269
- (filter.type === undefined || filter.type === service.type) &&
270
- (filter.name === undefined || filter.name === service.name)
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
-
317
- yield service;
318
- }
319
- }
320
- } else {
321
- yield* this.#services;
322
- }
267
+ yield* serviceFilter(this.#services, filter);
323
268
  }
324
269
 
325
270
  typeNamed(typeName, name) {
package/src/service.mjs CHANGED
@@ -1,9 +1,6 @@
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
-
7
4
  const ServiceTypes = {
8
5
  dns: { protocol: "udp", port: 53 },
9
6
  ldap: { protocol: "tcp", port: 389 },
@@ -166,3 +163,69 @@ export class Service extends Base {
166
163
  }
167
164
  }
168
165
  }
166
+
167
+ export const sortByPriority = (a, b) => a.priority - b.priority;
168
+
169
+ export function* serviceFilter(services, filter) {
170
+ if (filter) {
171
+ for (const service of services) {
172
+ const filterString = key => {
173
+ if (filter[key] === undefined) {
174
+ return true;
175
+ }
176
+ if (filter[key] === service[key]) {
177
+ return true;
178
+ }
179
+
180
+ for(const value of filter[key].split('|')) {
181
+ if(service[key] === value) { return true; }
182
+ }
183
+
184
+ return false;
185
+ };
186
+
187
+ const filterNumber = key => {
188
+ switch (typeof filter[key]) {
189
+ case "undefined":
190
+ return true;
191
+ case "number":
192
+ return filter[key] === service[key];
193
+ case "string":
194
+ const m = filter[key].match(/^([=><!]+)(\d+)/);
195
+ if (m) {
196
+ const value = parseInt(m[2]);
197
+ switch (m[1]) {
198
+ case "=":
199
+ return service[key] === value;
200
+ case "!=":
201
+ return service[key] !== value;
202
+ case "<":
203
+ return service[key] < value;
204
+ case "<=":
205
+ return service[key] <= value;
206
+ case ">":
207
+ return service[key] > value;
208
+ case ">=":
209
+ return service[key] >= value;
210
+ }
211
+ }
212
+ }
213
+ return false;
214
+ };
215
+
216
+ if (
217
+ filterString("type") &&
218
+ filterString("name") &&
219
+ filterString("protocol") &&
220
+ filterString("alias") &&
221
+ filterNumber("priority") &&
222
+ filterNumber("weight") &&
223
+ filterNumber("port")
224
+ ) {
225
+ yield service;
226
+ }
227
+ }
228
+ } else {
229
+ yield* services;
230
+ }
231
+ }
@@ -142,7 +142,7 @@ export class Cluster extends Host {
142
142
  collection: boolean;
143
143
  writeable: boolean;
144
144
  };
145
- trusts: {
145
+ trusted: {
146
146
  type: string;
147
147
  collection: boolean;
148
148
  writeable: boolean;
@@ -331,7 +331,7 @@ export class Cluster extends Host {
331
331
  collection: boolean;
332
332
  writeable: boolean;
333
333
  };
334
- trusts: {
334
+ trusted: {
335
335
  type: string;
336
336
  collection: boolean;
337
337
  writeable: boolean;
package/types/dns.d.mts CHANGED
@@ -56,7 +56,7 @@ export class DNSService extends Base {
56
56
  collection: boolean;
57
57
  writeable: boolean;
58
58
  };
59
- trusts: {
59
+ trusted: {
60
60
  type: string;
61
61
  collection: boolean;
62
62
  writeable: boolean;
@@ -79,8 +79,8 @@ export class DNSService extends Base {
79
79
  expire: number;
80
80
  minimum: number;
81
81
  get soaUpdates(): number[];
82
- set trusts(value: any[]);
83
- get trusts(): any[];
82
+ set trusted(value: any[]);
83
+ get trusted(): any[];
84
84
  set forwardsTo(value: any[]);
85
85
  get forwardsTo(): any[];
86
86
  get forwardsToAdresses(): any[];
package/types/host.d.mts CHANGED
@@ -175,7 +175,6 @@ export class Host extends Base {
175
175
  get hostName(): string;
176
176
  get domainName(): string;
177
177
  get host(): this;
178
- findServices(filter: any): Generator<any, void, unknown>;
179
178
  named(name: any): any;
180
179
  set networkInterfaces(networkInterface: Map<any, any>);
181
180
  get networkInterfaces(): Map<any, any>;
@@ -142,7 +142,7 @@ export class Location extends Owner {
142
142
  collection: boolean;
143
143
  writeable: boolean;
144
144
  };
145
- trusts: {
145
+ trusted: {
146
146
  type: string;
147
147
  collection: boolean;
148
148
  writeable: boolean;
@@ -331,7 +331,7 @@ export class Location extends Owner {
331
331
  collection: boolean;
332
332
  writeable: boolean;
333
333
  };
334
- trusts: {
334
+ trusted: {
335
335
  type: string;
336
336
  collection: boolean;
337
337
  writeable: boolean;
@@ -144,7 +144,7 @@ export class Network extends Owner {
144
144
  collection: boolean;
145
145
  writeable: boolean;
146
146
  };
147
- trusts: {
147
+ trusted: {
148
148
  type: string;
149
149
  collection: boolean;
150
150
  writeable: boolean;
package/types/owner.d.mts CHANGED
@@ -140,7 +140,7 @@ export class Owner extends Base {
140
140
  collection: boolean;
141
141
  writeable: boolean;
142
142
  };
143
- trusts: {
143
+ trusted: {
144
144
  type: string;
145
145
  collection: boolean;
146
146
  writeable: boolean;
package/types/root.d.mts CHANGED
@@ -146,7 +146,7 @@ export class Root extends Location {
146
146
  collection: boolean;
147
147
  writeable: boolean;
148
148
  };
149
- trusts: {
149
+ trusted: {
150
150
  type: string;
151
151
  collection: boolean;
152
152
  writeable: boolean;
@@ -335,7 +335,7 @@ export class Root extends Location {
335
335
  collection: boolean;
336
336
  writeable: boolean;
337
337
  };
338
- trusts: {
338
+ trusted: {
339
339
  type: string;
340
340
  collection: boolean;
341
341
  writeable: boolean;
@@ -1,4 +1,4 @@
1
- export function sortByPriority(a: any, b: any): number;
1
+ export function serviceFilter(services: any, filter: any): Generator<any, void, any>;
2
2
  export class Service extends Base {
3
3
  static get typeDefinition(): {
4
4
  name: string;
@@ -104,4 +104,5 @@ export class Service extends Base {
104
104
  get srvPrefix(): string;
105
105
  #private;
106
106
  }
107
+ export function sortByPriority(a: any, b: any): number;
107
108
  import { Base } from "./base.mjs";