pmcf 2.52.1 → 2.53.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": "2.52.1",
3
+ "version": "2.53.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -51,7 +51,7 @@
51
51
  "pkg-dir": "^8.0.0"
52
52
  },
53
53
  "devDependencies": {
54
- "@types/node": "^22.15.20",
54
+ "@types/node": "^22.15.21",
55
55
  "ava": "^6.3.0",
56
56
  "c8": "^10.1.3",
57
57
  "documentation": "^14.0.3",
package/src/endpoint.mjs CHANGED
@@ -113,9 +113,12 @@ export class HTTPEndpoint extends BaseEndpoint {
113
113
  }
114
114
 
115
115
  get port() {
116
- return (
117
- this.url.port || (this.url.toString().startsWith("https:") ? 443 : 80)
118
- );
116
+
117
+ const port = this.url.port;
118
+ if(port.length) {
119
+ return parseInt(port);
120
+ }
121
+ return this.url.toString().startsWith("https:") ? 443 : 80;
119
122
  }
120
123
 
121
124
  get pathname() {
@@ -72,6 +72,9 @@ const controlDDNSEndpoint = {
72
72
  path: "/run/kea/ddns-ctrl-socket"
73
73
  };
74
74
 
75
+ const keaVersion = 2.6;
76
+ export const fetureHasHTTPEndpoints = keaVersion > 2.7;
77
+
75
78
  export class DHCPService extends Service {
76
79
  static {
77
80
  addType(this);
@@ -95,7 +98,16 @@ export class DHCPService extends Service {
95
98
 
96
99
  for (const na of this.host.networkAddresses()) {
97
100
  endpoints.push(new HTTPEndpoint(this, na, controlAgentEndpoint));
98
- endpoints.push(new HTTPEndpoint(this, na, na.family === 'IPv4' ? ha4Endpoint : ha6Endpoint));
101
+
102
+ if (fetureHasHTTPEndpoints) {
103
+ endpoints.push(
104
+ new HTTPEndpoint(
105
+ this,
106
+ na,
107
+ na.family === "IPv4" ? ha4Endpoint : ha6Endpoint
108
+ )
109
+ );
110
+ }
99
111
 
100
112
  if (na.networkInterface.kind === "loopback") {
101
113
  endpoints.push(new Endpoint(this, na, ddnsEndpoint));
@@ -134,7 +146,7 @@ export class DHCPService extends Service {
134
146
  name: `kea-${this.location.name}-${name}`,
135
147
  description: `kea definitions for ${this.fullName}@${name}`,
136
148
  access: "private",
137
- dependencies: ["kea>=2.6.2"]
149
+ dependencies: [`kea>=${keaVersion}`]
138
150
  }
139
151
  };
140
152
 
@@ -142,24 +154,29 @@ export class DHCPService extends Service {
142
154
  e => e.type === "kea-control-agent"
143
155
  );
144
156
 
145
- const peers = async (family) => (
146
- await Array.fromAsync(
147
- network.findServices({ type: "dhcp", priority: "<20" })
157
+ const peers = async family =>
158
+ (
159
+ await Array.fromAsync(
160
+ network.findServices({ type: "dhcp", priority: "<20" })
161
+ )
148
162
  )
149
- )
150
- .sort(sortInverseByPriority)
151
- .map((dhcp, i) => {
152
- const ctrlAgentEndpoint = dhcp.endpoint(
153
- e => e.type === `kea-ha-${family}`
154
- );
155
-
156
- return {
157
- name: dhcp.host.name,
158
- role: i === 0 ? "primary" : i > 1 ? "backup" : "standby",
159
- url: ctrlAgentEndpoint.url,
160
- "auto-failover": i <= 1
161
- };
162
- });
163
+ .sort(sortInverseByPriority)
164
+ .map((dhcp, i) => {
165
+ const ctrlAgentEndpoint = dhcp.endpoint(
166
+ e =>
167
+ e.type ===
168
+ (fetureHasHTTPEndpoints
169
+ ? `kea-ha-${family}`
170
+ : "kea-control-agent")
171
+ );
172
+
173
+ return {
174
+ name: dhcp.host.name,
175
+ role: i === 0 ? "primary" : i > 1 ? "backup" : "standby",
176
+ url: ctrlAgentEndpoint.url,
177
+ "auto-failover": i <= 1
178
+ };
179
+ });
163
180
 
164
181
  const loggers = [
165
182
  {
@@ -173,7 +190,7 @@ export class DHCPService extends Service {
173
190
  }
174
191
  ];
175
192
 
176
- const commonConfig = async (family) => {
193
+ const commonConfig = async family => {
177
194
  return {
178
195
  "interfaces-config": {
179
196
  interfaces: listenInterfaces(`IPv${family}`)
@@ -210,12 +227,14 @@ export class DHCPService extends Service {
210
227
  {
211
228
  "this-server-name": name,
212
229
  mode: "hot-standby",
230
+
231
+ /*
213
232
  "multi-threading": {
214
233
  "enable-multi-threading": true,
215
234
  "http-dedicated-listener": true,
216
235
  "http-listener-threads": 2,
217
236
  "http-client-threads": 2
218
- },
237
+ },*/
219
238
  peers: await peers(family)
220
239
  }
221
240
  ]
@@ -249,8 +268,8 @@ export class DHCPService extends Service {
249
268
 
250
269
  const ctrlAgent = {
251
270
  "Control-agent": {
252
- "http-host": ctrlAgentEndpoint?.host,
253
- "http-port": ctrlAgentEndpoint?.port,
271
+ "http-host": ctrlAgentEndpoint.hostname,
272
+ "http-port": ctrlAgentEndpoint.port,
254
273
  "control-sockets": {
255
274
  dhcp4: toUnix(this.endpoint(e => e.type === "kea-control-dhcp4")),
256
275
  dhcp6: toUnix(this.endpoint(e => e.type === "kea-control-dhcp6")),
@@ -395,14 +414,12 @@ export class DHCPService extends Service {
395
414
  }
396
415
  };
397
416
 
398
- const files = {
417
+ for (const [name, data] of Object.entries({
399
418
  "kea-ctrl-agent": ctrlAgent,
400
419
  "kea-dhcp-ddns": ddns,
401
420
  "kea-dhcp4": dhcp4,
402
421
  "kea-dhcp6": dhcp6
403
- };
404
-
405
- for (const [name, data] of Object.entries(files)) {
422
+ })) {
406
423
  loggers[0].name = name;
407
424
  await writeLines(
408
425
  join(packageData.dir, "etc/kea"),
@@ -19,7 +19,7 @@ export class HTTPEndpoint extends BaseEndpoint {
19
19
  url: URL;
20
20
  family: any;
21
21
  hostname: any;
22
- get port(): string | 80 | 443;
22
+ get port(): number;
23
23
  get pathname(): string;
24
24
  get address(): URL;
25
25
  get protocol(): string;
@@ -1,3 +1,4 @@
1
+ export const fetureHasHTTPEndpoints: boolean;
1
2
  export class DHCPService extends Service {
2
3
  static get typeDefinition(): {
3
4
  name: string;