pmcf 2.14.0 → 2.14.2

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.0",
3
+ "version": "2.14.2",
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/service.mjs CHANGED
@@ -166,28 +166,26 @@ export class Service extends Base {
166
166
  }
167
167
 
168
168
  get endpoints() {
169
- const nis = [...this.server.networkInterfaces.values()];
170
-
171
- if (!ServiceTypes[this.type]) {
172
- return nis.map(
173
- networkInterface =>
174
- new Endpoint(this, networkInterface, {
175
- rawAddress: this.rawAddress,
176
- port: this._port,
177
- tls: false
178
- })
179
- );
180
- }
169
+ const local = this._port === undefined ? {} : { port: this._port };
181
170
 
182
- return nis.map(networkInterface =>
183
- ServiceTypes[this.type].endpoints.map(
184
- e =>
185
- new Endpoint(this, networkInterface, {
186
- rawAddress: this.rawAddress,
187
- ...e
188
- })
171
+ const data = ServiceTypes[this.type]?.endpoints || [
172
+ {
173
+ tls: false
174
+ }
175
+ ];
176
+
177
+ return [...this.server.networkAddresses()]
178
+ .map(sa =>
179
+ data.map(
180
+ d =>
181
+ new Endpoint(this, sa.networkInterface, {
182
+ ...d,
183
+ rawAddress: sa.address,
184
+ ...local
185
+ })
186
+ )
189
187
  )
190
- ).flat();
188
+ .flat();
191
189
  }
192
190
 
193
191
  set alias(value) {
@@ -241,7 +239,9 @@ export class Service extends Base {
241
239
  }
242
240
 
243
241
  if (hasSVRRecords) {
244
- for (const ep of this.endpoints.filter(e => e.protocol)) {
242
+ for (const ep of this.endpoints.filter(
243
+ e => e.protocol && e.networkInterface.scope !== "host" // TODO how to identify related interfaces
244
+ )) {
245
245
  records.push(
246
246
  DNSRecord(
247
247
  dnsFullName(
@@ -300,6 +300,24 @@ export class Endpoint {
300
300
  this.networkInterface = networkInterface;
301
301
  Object.assign(this, data);
302
302
  }
303
+
304
+ toString() {
305
+ return `${this.rawAddress}[${this.port}]`;
306
+ }
307
+
308
+ get hostName() {
309
+ return this.networkInterface.hostName;
310
+ }
311
+
312
+ #rawAddress;
313
+
314
+ get rawAddress() {
315
+ return this.#rawAddress ?? this.networkInterface.rawAddress;
316
+ }
317
+
318
+ set rawAddress(value) {
319
+ this.#rawAddress = value;
320
+ }
303
321
  }
304
322
 
305
323
  export const sortByPriority = (a, b) => a.priority - b.priority;
@@ -6,7 +6,7 @@ import {
6
6
  serviceEndpoints
7
7
  } from "../service.mjs";
8
8
  import { addType } from "../types.mjs";
9
- import { writeLines } from "../utils.mjs";
9
+ import { writeLines, isIPv4Address, isIPv6Address } from "../utils.mjs";
10
10
 
11
11
  const DHCPServiceTypeDefinition = {
12
12
  name: "dhcp",
@@ -186,9 +186,16 @@ export class DHCPService extends Service {
186
186
  Dhcp4: {
187
187
  ...commonConfig,
188
188
  "interfaces-config": {
189
- interfaces: [...host.networkInterfaces.values()]
190
- .filter(ni => ni.kind !== "loopback")
191
- .map(ni => `${ni.name}/${ni.rawIPv4Address}`)
189
+ interfaces: this.endpoints
190
+ .filter(
191
+ endpoint =>
192
+ isIPv4Address(endpoint.rawAddress) &&
193
+ endpoint.networkInterface.kind !== "loopback"
194
+ )
195
+ .map(
196
+ endpoint =>
197
+ `${endpoint.networkInterface.name}/${endpoint.rawAddress}`
198
+ )
192
199
  },
193
200
  "multi-threading": {
194
201
  "enable-multi-threading": false
@@ -233,9 +240,16 @@ export class DHCPService extends Service {
233
240
  Dhcp6: {
234
241
  ...commonConfig,
235
242
  "interfaces-config": {
236
- interfaces: [...host.networkInterfaces.values()]
237
- .filter(ni => ni.kind !== "loopback")
238
- .map(ni => `${ni.name}/${ni.rawIPv6Address}`)
243
+ interfaces: this.endpoints
244
+ .filter(
245
+ endpoint =>
246
+ isIPv6Address(endpoint.rawAddress) &&
247
+ endpoint.networkInterface.kind !== "loopback"
248
+ )
249
+ .map(
250
+ endpoint =>
251
+ `${endpoint.networkInterface.name}/${endpoint.rawAddress}`
252
+ )
239
253
  },
240
254
  "control-socket": {
241
255
  "socket-type": "unix",
@@ -288,6 +288,11 @@ export class Endpoint {
288
288
  constructor(service: any, networkInterface: any, data: any);
289
289
  service: any;
290
290
  networkInterface: any;
291
+ toString(): string;
292
+ get hostName(): any;
293
+ set rawAddress(value: any);
294
+ get rawAddress(): any;
295
+ #private;
291
296
  }
292
297
  export function sortByPriority(a: any, b: any): number;
293
298
  import { Base } from "./base.mjs";