pmcf 6.26.5 → 6.27.1

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": "6.26.5",
3
+ "version": "6.27.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -54,7 +54,7 @@
54
54
  "content-entry-transform": "^1.7.0",
55
55
  "ip-utilties": "^3.12.0",
56
56
  "npm-pkgbuild": "^20.8.13",
57
- "pacc": "^11.1.3",
57
+ "pacc": "^11.2.0",
58
58
  "package-directory": "^8.2.0",
59
59
  "yaml": "^2.9.0"
60
60
  },
package/src/endpoint.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getAttribute, string_attribute } from "pacc";
1
+ import { getAttribute, string_attribute, url_attribute } from "pacc";
2
2
  import { FAMILY_IPV6 } from "ip-utilties";
3
3
  import { addType } from "pmcf";
4
4
  import { endpointAttributes, CoreService } from "./core-service.mjs";
@@ -134,6 +134,15 @@ export class Endpoint extends PortEndpoint {
134
134
  }
135
135
 
136
136
  export class DomainNameEndpoint extends PortEndpoint {
137
+ static name = "domain_endpoint";
138
+ static attributes = {
139
+ domainName: { ...string_attribute, name: "domainName" }
140
+ };
141
+
142
+ static {
143
+ addType(this);
144
+ }
145
+
137
146
  constructor(service, domainName, data) {
138
147
  super(service, data);
139
148
  this.domainName = domainName;
@@ -160,6 +169,15 @@ export class DomainNameEndpoint extends PortEndpoint {
160
169
  * Endpoint based on http
161
170
  */
162
171
  export class HTTPEndpoint extends BaseEndpoint {
172
+ static name = "url_endpoint";
173
+ static attributes = {
174
+ url: url_attribute
175
+ };
176
+
177
+ static {
178
+ addType(this);
179
+ }
180
+
163
181
  /**
164
182
  *
165
183
  * @param {Service} service
@@ -223,6 +241,15 @@ export class HTTPEndpoint extends BaseEndpoint {
223
241
  }
224
242
 
225
243
  export class UnixEndpoint extends BaseEndpoint {
244
+ static name = "unix_endpoint";
245
+ static attributes = {
246
+ url: url_attribute
247
+ };
248
+
249
+ static {
250
+ addType(this);
251
+ }
252
+
226
253
  constructor(service, path, data) {
227
254
  super(service, data);
228
255
  this.path = path;
@@ -20,12 +20,11 @@ import {
20
20
  } from "pacc";
21
21
  import {
22
22
  Base,
23
- ExtraSourceService,
24
- serviceEndpoints,
23
+ CoreService,
24
+ Endpoint,
25
25
  addresses,
26
26
  networkAddressType,
27
- addType,
28
- FAMILY_DNS
27
+ addType
29
28
  } from "pmcf";
30
29
  import { yesno, writeLines, asArray } from "../utils.mjs";
31
30
  import {
@@ -572,11 +571,13 @@ function addressesStatement(prefix, objects, empty = false, indent = "") {
572
571
  return [];
573
572
  }
574
573
 
575
- export class bind extends ExtraSourceService {
574
+ export class bind extends CoreService {
576
575
  static attributes = {
577
576
  forwarders: {
578
- ...default_collection_attribute,
579
- name: "forwarders"
577
+ ...default_collection_attribute_writable,
578
+ type: Endpoint,
579
+ name: "forwarders",
580
+ deferredExpression: true
580
581
  },
581
582
  groups: {
582
583
  ...default_collection_attribute_writable,
@@ -640,21 +641,18 @@ export class bind extends ExtraSourceService {
640
641
  return this.primaries ? "secondary" : "primary";
641
642
  }
642
643
 
643
- get forwarders() {
644
- const forwarders = serviceEndpoints(this.source, {
645
- services: "services[types[dns] && priority>=100 && priority<200]",
646
- endpoints: endpoint => endpoint.family !== FAMILY_DNS,
647
- select: e => e.address,
648
- limit: 5
649
- });
650
-
651
- return forwarders;
652
- }
653
-
654
644
  async writeForwarders(outputControl) {
655
- const forwarders = this.forwarders;
645
+ // TODO formulate everything as pacc expression
646
+ const forwarders = [...this.forwarders]
647
+ .map(e => e.endpoints())
648
+ .flat()
649
+ .filter(e => e.networkAddress)
650
+ .map(e => e.networkAddress?.address);
656
651
 
657
652
  if (forwarders.length) {
653
+ if (forwarders.length > 5) {
654
+ forwarders.length = 5;
655
+ }
658
656
  await writeLines(
659
657
  join(outputControl.dir, "etc/named/options"),
660
658
  `forwarders.conf`,
package/src/type.mjs CHANGED
@@ -39,9 +39,13 @@ export function assign(attribute, object, value) {
39
39
  }
40
40
 
41
41
  if (attribute.deferredExpression) {
42
- Object.defineProperty(object, attribute.name, {
43
- get: () => object.expression(value)
44
- });
42
+ if (object.hasOwnProperty(attribute.name)) {
43
+ error(`attribute ${attribute.name} of ${object.fullName} already defined`, attribute );
44
+ } else {
45
+ Object.defineProperty(object, attribute.name, {
46
+ get: () => object.expression(value)
47
+ });
48
+ }
45
49
  return value;
46
50
  }
47
51