pmcf 2.14.1 → 2.15.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": "2.14.1",
3
+ "version": "2.15.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -48,7 +48,7 @@
48
48
  "c8": "^10.1.3",
49
49
  "documentation": "^14.0.3",
50
50
  "semantic-release": "^24.2.3",
51
- "typescript": "^5.8.2"
51
+ "typescript": "^5.8.3"
52
52
  },
53
53
  "engines": {
54
54
  "node": ">=22.14.0"
package/src/host.mjs CHANGED
@@ -115,7 +115,6 @@ export class Host extends Base {
115
115
 
116
116
  _applyExtends(host) {
117
117
  for (const service of host.services) {
118
-
119
118
  //present.extends.push(service);
120
119
 
121
120
  this.services = service.forOwner(this);
@@ -402,6 +401,24 @@ export class Host extends Base {
402
401
  );
403
402
  }
404
403
 
404
+ *findNetworkInterfaces(filter) {
405
+ yield* objectFilter(
406
+ types.network_interface,
407
+ this._networkInterfaces.values(),
408
+ filter
409
+ );
410
+ }
411
+
412
+ findNetworkInterface(filter) {
413
+ for (const ni of objectFilter(
414
+ types.network_interface,
415
+ this._networkInterfaces.values(),
416
+ filter
417
+ )) {
418
+ return ni;
419
+ }
420
+ }
421
+
405
422
  get networkInterfaces() {
406
423
  return this._networkInterfaces;
407
424
  }
@@ -671,7 +688,11 @@ export class NetworkInterface extends Base {
671
688
  }
672
689
 
673
690
  get scope() {
674
- return this.extendedProperty("_scope") ?? this.network?.scope ?? networkProperties.scope.default;
691
+ return (
692
+ this.extendedProperty("_scope") ??
693
+ this.network?.scope ??
694
+ networkProperties.scope.default
695
+ );
675
696
  }
676
697
 
677
698
  set hwaddr(value) {
@@ -687,7 +708,11 @@ export class NetworkInterface extends Base {
687
708
  }
688
709
 
689
710
  get metric() {
690
- return this.extendedProperty("_metric") ?? this.network?.metric ?? networkProperties.metric.default;
711
+ return (
712
+ this.extendedProperty("_metric") ??
713
+ this.network?.metric ??
714
+ networkProperties.metric.default
715
+ );
691
716
  }
692
717
 
693
718
  set MTU(value) {
package/src/service.mjs CHANGED
@@ -35,7 +35,7 @@ const ServiceTypes = {
35
35
  ssh: { endpoints: [{ protocol: "tcp", port: 22, tls: false }] },
36
36
  imap: { endpoints: [{ protocol: "tcp", port: 143, tls: false }] },
37
37
  imaps: { endpoints: [{ protocol: "tcp", port: 993, tls: true }] },
38
- dhcp: { endpoints: [{ port: 547, tls: false }] },
38
+ dhcp: { endpoints: [{ port: 547, protocol: "udp", tls: false }] },
39
39
  "dhcpv6-client": {
40
40
  endpoints: [
41
41
  { protocol: "tcp", port: 546, tls: false },
@@ -166,7 +166,10 @@ export class Service extends Base {
166
166
  }
167
167
 
168
168
  get endpoints() {
169
- const local = this._port === undefined ? {} : { port: this._port };
169
+ const local =
170
+ this._port === undefined
171
+ ? { type: this.type }
172
+ : { type: this.type, port: this._port };
170
173
 
171
174
  const data = ServiceTypes[this.type]?.endpoints || [
172
175
  {
@@ -3,10 +3,11 @@ import { FileContentProvider } from "npm-pkgbuild";
3
3
  import {
4
4
  Service,
5
5
  ServiceTypeDefinition,
6
+ Endpoint,
6
7
  serviceEndpoints
7
8
  } from "../service.mjs";
8
9
  import { addType } from "../types.mjs";
9
- import { writeLines } from "../utils.mjs";
10
+ import { writeLines, isIPv4Address, isIPv6Address } from "../utils.mjs";
10
11
 
11
12
  const DHCPServiceTypeDefinition = {
12
13
  name: "dhcp",
@@ -17,6 +18,20 @@ const DHCPServiceTypeDefinition = {
17
18
  properties: {}
18
19
  };
19
20
 
21
+ const controlAgentEndpoint = {
22
+ type: "kea-control-agent",
23
+ port: 8000,
24
+ protocol: "tcp",
25
+ tls: false
26
+ };
27
+
28
+ const ddnsEndpoint = {
29
+ type: "kea-ddns",
30
+ port: 53001,
31
+ protocol: "tcp",
32
+ tls: false
33
+ };
34
+
20
35
  export class DHCPService extends Service {
21
36
  static {
22
37
  addType(this);
@@ -35,6 +50,20 @@ export class DHCPService extends Service {
35
50
  return DHCPServiceTypeDefinition.name;
36
51
  }
37
52
 
53
+ get endpoints() {
54
+ const l0 = this.server.findNetworkInterface({ scope: "host" });
55
+
56
+ if (l0) {
57
+ return [
58
+ ...super.endpoints,
59
+ new Endpoint(this, l0, controlAgentEndpoint),
60
+ new Endpoint(this, l0, ddnsEndpoint)
61
+ ];
62
+ }
63
+
64
+ return super.endpoints;
65
+ }
66
+
38
67
  async *preparePackages(dir) {
39
68
  const network = this.network;
40
69
  const host = this.server;
@@ -182,13 +211,23 @@ export class DHCPService extends Service {
182
211
  })
183
212
  .sort((a, b) => a.hostname.localeCompare(b.hostname));
184
213
 
214
+ const listenInterfaces = filter =>
215
+ this.endpoints
216
+ .filter(
217
+ endpoint =>
218
+ endpoint.type === "dhcp" &&
219
+ filter(endpoint.rawAddress) &&
220
+ endpoint.networkInterface.kind !== "loopback"
221
+ )
222
+ .map(
223
+ endpoint => `${endpoint.networkInterface.name}/${endpoint.rawAddress}`
224
+ );
225
+
185
226
  const dhcp4 = {
186
227
  Dhcp4: {
187
228
  ...commonConfig,
188
229
  "interfaces-config": {
189
- interfaces: [...host.networkInterfaces.values()]
190
- .filter(ni => ni.kind !== "loopback")
191
- .map(ni => `${ni.name}/${ni.rawIPv4Address}`)
230
+ interfaces: listenInterfaces(isIPv4Address)
192
231
  },
193
232
  "multi-threading": {
194
233
  "enable-multi-threading": false
@@ -233,9 +272,7 @@ export class DHCPService extends Service {
233
272
  Dhcp6: {
234
273
  ...commonConfig,
235
274
  "interfaces-config": {
236
- interfaces: [...host.networkInterfaces.values()]
237
- .filter(ni => ni.kind !== "loopback")
238
- .map(ni => `${ni.name}/${ni.rawIPv6Address}`)
275
+ interfaces: listenInterfaces(isIPv6Address)
239
276
  },
240
277
  "control-socket": {
241
278
  "socket-type": "unix",
package/types/host.d.mts CHANGED
@@ -228,6 +228,8 @@ export class Host extends Base {
228
228
  get host(): this;
229
229
  named(name: any): any;
230
230
  get networks(): Set<any>;
231
+ findNetworkInterfaces(filter: any): Generator<any, void, any>;
232
+ findNetworkInterface(filter: any): any;
231
233
  set networkInterfaces(networkInterface: Map<any, any>);
232
234
  get networkInterfaces(): Map<any, any>;
233
235
  networkAddresses(): Generator<{