pmcf 2.46.4 → 2.47.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.46.4",
3
+ "version": "2.47.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/host.mjs CHANGED
@@ -452,10 +452,16 @@ export class Host extends ServiceOwner {
452
452
  return addresses(this.networkAddresses());
453
453
  }
454
454
 
455
- *subnets() {
455
+ get subnets() {
456
+ const sn = new Set();
457
+
456
458
  for (const networkInterface of this.networkInterfaces.values()) {
457
- yield* networkInterface.subnets();
459
+ for (const s of networkInterface.subnets()) {
460
+ sn.add(s);
461
+ }
458
462
  }
463
+
464
+ return sn;
459
465
  }
460
466
 
461
467
  async publicKey(type = "ed25519") {
package/src/service.mjs CHANGED
@@ -188,6 +188,10 @@ export class Service extends Base {
188
188
  return this.host.networks;
189
189
  }
190
190
 
191
+ get subnets() {
192
+ return this.host.subnets;
193
+ }
194
+
191
195
  endpoints(filter) {
192
196
  const data = serviceTypeEndpoints(this.type);
193
197
 
@@ -4,7 +4,9 @@ import {
4
4
  Service,
5
5
  ServiceTypeDefinition,
6
6
  Endpoint,
7
- serviceEndpoints
7
+ serviceEndpoints,
8
+ SUBNET_LOCALHOST_IPV4,
9
+ SUBNET_LOCALHOST_IPV6
8
10
  } from "pmcf";
9
11
  import { addType } from "../types.mjs";
10
12
  import { writeLines } from "../utils.mjs";
@@ -187,14 +189,6 @@ export class DHCPService extends Service {
187
189
  "ncr-format": "JSON"
188
190
  };
189
191
 
190
- const subnets = new Set();
191
-
192
- for (const network of this.networks) {
193
- for (const subnet of network.subnets()) {
194
- subnets.add(subnet);
195
- }
196
- }
197
-
198
192
  const hwmap = new Map();
199
193
  const hostNames = new Set();
200
194
 
@@ -229,6 +223,7 @@ export class DHCPService extends Service {
229
223
  endpoint => `${endpoint.networkInterface.name}/${endpoint.address}`
230
224
  );
231
225
 
226
+ const subnets = [...this.subnets].filter(s => s !== SUBNET_LOCALHOST_IPV4 && s !== SUBNET_LOCALHOST_IPV6/* s.address !== "127/8"*/); // TODO no localhost
232
227
  const dhcp4 = {
233
228
  Dhcp4: {
234
229
  ...commonConfig,
@@ -252,7 +247,7 @@ export class DHCPService extends Service {
252
247
  data: [...this.domains].join(",")
253
248
  }
254
249
  ],
255
- subnet4: [...subnets]
250
+ subnet4: subnets
256
251
  .filter(s => s.family === "IPv4")
257
252
  .map((subnet, index) => {
258
253
  return {
@@ -292,7 +287,7 @@ export class DHCPService extends Service {
292
287
  .join(",")
293
288
  }
294
289
  ],
295
- subnet6: [...subnets]
290
+ subnet6: subnets
296
291
  .filter(s => s.family === "IPv6")
297
292
  .map((subnet, index) => {
298
293
  return {
@@ -68,7 +68,9 @@ export class NTPService extends ExtraSourceService {
68
68
  priority: "<10"
69
69
  },
70
70
  endpoints: e =>
71
- e.family === "IPv4" && e.networkInterface.kind !== "loopback",
71
+ e.service.host !== host &&
72
+ e.family === "IPv4" &&
73
+ e.networkInterface.kind !== "loopback",
72
74
 
73
75
  select: endpoint =>
74
76
  `${endpoint.service.isPool ? "pool" : "server"} ${
package/src/subnet.mjs CHANGED
@@ -53,12 +53,7 @@ export class Subnet extends Base {
53
53
  }
54
54
 
55
55
  matchesAddress(address) {
56
- try {
57
- return matchPrefixIP(this.address, this.prefixLength, address);
58
- } catch (e) {
59
- console.error(e, this.toString(), address);
60
- }
61
- return false;
56
+ return matchPrefixIP(this.address, this.prefixLength, address);
62
57
  }
63
58
 
64
59
  get isLinkLocal() {
package/types/host.d.mts CHANGED
@@ -242,7 +242,7 @@ export class Host extends ServiceOwner {
242
242
  networkAddresses(filter: any): Generator<any, void, any>;
243
243
  get address(): any;
244
244
  get addresses(): any[];
245
- subnets(): Generator<any, void, any>;
245
+ get subnets(): Set<any>;
246
246
  publicKey(type?: string): Promise<string>;
247
247
  preparePackages(dir: any): AsyncGenerator<{
248
248
  dir: any;
@@ -314,6 +314,7 @@ export class Service extends Base {
314
314
  hosts(): Generator<any, void, any>;
315
315
  get domainName(): any;
316
316
  get networks(): Set<any>;
317
+ get subnets(): Set<any>;
317
318
  endpoints(filter: any): any[];
318
319
  address(options?: {
319
320
  endpoints: (e: any) => boolean;