pmcf 2.19.5 → 2.20.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.19.5",
3
+ "version": "2.20.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -40,7 +40,7 @@
40
40
  "dependencies": {
41
41
  "ip-utilties": "^1.1.0",
42
42
  "npm-pkgbuild": "^18.0.1",
43
- "pacc": "^3.3.0",
43
+ "pacc": "^3.4.0",
44
44
  "pkg-dir": "^8.0.0"
45
45
  },
46
46
  "devDependencies": {
package/src/host.mjs CHANGED
@@ -421,16 +421,9 @@ export class Host extends Base {
421
421
  }
422
422
  }
423
423
 
424
- *networkAddresses() {
424
+ *networkAddresses(filter) {
425
425
  for (const networkInterface of this.networkInterfaces.values()) {
426
- for (const [address, subnet] of networkInterface.ipAddresses) {
427
- yield {
428
- networkInterface,
429
- domainNames: networkInterface.domainNames,
430
- address,
431
- subnet
432
- };
433
- }
426
+ yield* networkInterface.networkAddresses(filter);
434
427
  }
435
428
  }
436
429
 
@@ -6,6 +6,7 @@ import {
6
6
  normalizeIP
7
7
  } from "ip-utilties";
8
8
  import { Base } from "./base.mjs";
9
+ import { Subnet } from "./subnet.mjs";
9
10
  import {
10
11
  networkProperties,
11
12
  networkAddressProperties
@@ -13,6 +14,14 @@ import {
13
14
  import { asArray } from "./utils.mjs";
14
15
  import { addType } from "./types.mjs";
15
16
 
17
+ /**
18
+ * @typedef {object} NetworkAddress
19
+ * @property {NetworkInterface} networkInterface
20
+ * @property {string|Uint8Array|Uint16Array} address
21
+ * @property {Subnet} subnet
22
+ * @property {Set<string>} domainNames
23
+ */
24
+
16
25
  class SkeletonNetworkInterface extends Base {
17
26
  _extends = [];
18
27
  _network;
@@ -43,7 +52,7 @@ class SkeletonNetworkInterface extends Base {
43
52
 
44
53
  matches(other) {
45
54
  if (this.isTemplate) {
46
- const name = this.name.replace("*", "");
55
+ const name = this.name.replaceAll("*", "");
47
56
  return name.length === 0 || other.name.indexOf(name) >= 0;
48
57
  }
49
58
 
@@ -58,6 +67,30 @@ class SkeletonNetworkInterface extends Base {
58
67
  this._network = network;
59
68
  }
60
69
 
70
+ get ipAddresses() {
71
+ return new Map();
72
+ }
73
+
74
+ /**
75
+ *
76
+ * @param {object} filter
77
+ * @return {Iterable<NetworkAddress>}
78
+ */
79
+ *networkAddresses(filter=(n)=>true) {
80
+ for (const [address, subnet] of this.ipAddresses) {
81
+ const networkAddress = {
82
+ networkInterface: this,
83
+ domainNames: this.domainNames,
84
+ address,
85
+ subnet
86
+ };
87
+
88
+ if(filter(networkAddress)) {
89
+ yield networkAddress;
90
+ }
91
+ }
92
+ }
93
+
61
94
  get rawAddress() {
62
95
  return this.rawAddresses[0];
63
96
  }
@@ -74,10 +107,6 @@ class SkeletonNetworkInterface extends Base {
74
107
  return this.cidrAddresses[0];
75
108
  }
76
109
 
77
- get ipAddresses() {
78
- return new Map();
79
- }
80
-
81
110
  get rawAddresses() {
82
111
  return [...this.ipAddresses].map(([address]) => address);
83
112
  }
package/src/owner.mjs CHANGED
@@ -298,9 +298,9 @@ export class Owner extends Base {
298
298
  return all;
299
299
  }
300
300
 
301
- *networkAddresses() {
301
+ *networkAddresses(filter) {
302
302
  for (const host of this.hosts()) {
303
- yield* host.networkAddresses();
303
+ yield* host.networkAddresses(filter);
304
304
  }
305
305
  }
306
306
 
package/types/host.d.mts CHANGED
@@ -232,12 +232,7 @@ export class Host extends Base {
232
232
  findNetworkInterface(filter: any): any;
233
233
  set networkInterfaces(networkInterface: Map<any, any>);
234
234
  get networkInterfaces(): Map<any, any>;
235
- networkAddresses(): Generator<{
236
- networkInterface: any;
237
- domainNames: any;
238
- address: any;
239
- subnet: any;
240
- }, void, unknown>;
235
+ networkAddresses(filter: any): Generator<any, void, any>;
241
236
  get rawAddress(): any;
242
237
  get rawAddresses(): any[];
243
238
  get cidrAddress(): any;
@@ -685,6 +685,19 @@ export class LoopbackNetworkInterface extends SkeletonNetworkInterface {
685
685
  prefixLength: number;
686
686
  }>;
687
687
  }
688
+ export type NetworkAddress = {
689
+ networkInterface: NetworkInterface;
690
+ address: string | Uint8Array | Uint16Array;
691
+ subnet: Subnet;
692
+ domainNames: Set<string>;
693
+ };
694
+ /**
695
+ * @typedef {object} NetworkAddress
696
+ * @property {NetworkInterface} networkInterface
697
+ * @property {string|Uint8Array|Uint16Array} address
698
+ * @property {Subnet} subnet
699
+ * @property {Set<string>} domainNames
700
+ */
688
701
  declare class SkeletonNetworkInterface extends Base {
689
702
  _extends: any[];
690
703
  _network: any;
@@ -695,15 +708,22 @@ declare class SkeletonNetworkInterface extends Base {
695
708
  matches(other: any): boolean;
696
709
  set network(network: any);
697
710
  get network(): any;
711
+ get ipAddresses(): Map<any, any>;
712
+ /**
713
+ *
714
+ * @param {object} filter
715
+ * @return {Iterable<NetworkAddress>}
716
+ */
717
+ networkAddresses(filter?: object): Iterable<NetworkAddress>;
698
718
  get rawAddress(): any;
699
719
  get rawIPv4Address(): any;
700
720
  get rawIPv6Address(): any;
701
721
  get cidrAddress(): any;
702
- get ipAddresses(): Map<any, any>;
703
722
  get rawAddresses(): any[];
704
723
  get rawIPv4Addresses(): any[];
705
724
  get rawIPv6Addresses(): any[];
706
725
  get cidrAddresses(): any[];
707
726
  }
727
+ import { Subnet } from "./subnet.mjs";
708
728
  import { Base } from "./base.mjs";
709
729
  export {};
package/types/owner.d.mts CHANGED
@@ -155,7 +155,7 @@ export class Owner extends Base {
155
155
  addBridge(network: any, destinationNetworks: any): any;
156
156
  _resolveBridges(): void;
157
157
  get derivedPackaging(): Set<any>;
158
- networkAddresses(): Generator<any, void, any>;
158
+ networkAddresses(filter: any): Generator<any, void, any>;
159
159
  _country: any;
160
160
  set country(value: any);
161
161
  get country(): any;