pmcf 1.21.1 → 1.22.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": "1.21.1",
3
+ "version": "1.22.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -39,6 +39,9 @@
39
39
  "lint:docs": "documentation lint ./src**/*.mjs",
40
40
  "lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target es2024 --lib esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
41
41
  },
42
+ "dependencies": {
43
+ "pacc": "^3.1.9"
44
+ },
42
45
  "devDependencies": {
43
46
  "@types/node": "^22.10.10",
44
47
  "ava": "^6.2.0",
@@ -64,8 +67,5 @@
64
67
  "arlac77/template-node-app",
65
68
  "arlac77/template-typescript"
66
69
  ]
67
- },
68
- "dependencies": {
69
- "pacc": "^3.1.9"
70
70
  }
71
71
  }
package/src/model.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { readFile, glob } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
- import { asArray, bridgeToJSON } from "./utils.mjs";
3
+ import { asArray, bridgeToJSON, isIPv4Address, isIPv6Address} from "./utils.mjs";
4
4
  import { Base } from "./base.mjs";
5
5
  import { DNSService } from "./dns.mjs";
6
6
 
@@ -639,10 +639,8 @@ export class Host extends Base {
639
639
 
640
640
  *networkAddresses() {
641
641
  for (const networkInterface of Object.values(this.networkInterfaces)) {
642
- for (const attribute of ["ipv4", "ipv6", "link-local-ipv6"]) {
643
- if (networkInterface[attribute]) {
644
- yield { address: networkInterface[attribute], networkInterface };
645
- }
642
+ for (const address of networkInterface.ipAddresses) {
643
+ yield { address, networkInterface };
646
644
  }
647
645
  }
648
646
  }
@@ -692,6 +690,7 @@ export class NetworkInterface extends Base {
692
690
  return "network_interface";
693
691
  }
694
692
 
693
+ #ipAddresses = [];
695
694
  #scope;
696
695
  #metric;
697
696
  #ssid;
@@ -703,6 +702,26 @@ export class NetworkInterface extends Base {
703
702
  constructor(owner, data) {
704
703
  super(owner, data);
705
704
 
705
+ if (data.ipv4) {
706
+ this.#ipAddresses.push(...asArray(data.ipv4));
707
+ delete data.ipv4;
708
+ }
709
+
710
+ if (data["link-local-ipv6"]) {
711
+ this.#ipAddresses.push(...asArray(data["link-local-ipv6"]));
712
+ delete data["link-local-ipv6"];
713
+ }
714
+
715
+ if (data.ipv6) {
716
+ this.#ipAddresses.push(...asArray(data.ipv6));
717
+ delete data.ipv6;
718
+ }
719
+
720
+ if (data.ipAddresses) {
721
+ this.#ipAddresses.push(...asArray(data.ipAddresses));
722
+ delete data.ipAddresses;
723
+ }
724
+
706
725
  if (data.ssid) {
707
726
  this.#ssid = data.ssid;
708
727
  delete data.ssid;
@@ -742,6 +761,20 @@ export class NetworkInterface extends Base {
742
761
  //this.arpbridge = owner.addARPBridge(this, data.arpbridge);
743
762
  }
744
763
 
764
+ get ipAddresses() {
765
+ return this.#ipAddresses;
766
+ }
767
+
768
+ get ipv4Addresses()
769
+ {
770
+ return this.#ipAddresses.filter(a => isIPv4Address(a));
771
+ }
772
+
773
+ get ipv6Addresses()
774
+ {
775
+ return this.#ipAddresses.filter(a => isIPv6Address(a));
776
+ }
777
+
745
778
  get network() {
746
779
  return this.#network;
747
780
  }
@@ -790,7 +823,8 @@ export class NetworkInterface extends Base {
790
823
  "ssid",
791
824
  "psk",
792
825
  "scope",
793
- "metric"
826
+ "metric",
827
+ "ipAddresses"
794
828
  ];
795
829
  }
796
830
  }
@@ -865,8 +899,6 @@ export class Service extends Base {
865
899
 
866
900
  Object.assign(this, data);
867
901
 
868
- this.owner = owner;
869
-
870
902
  owner.addService(this);
871
903
  }
872
904
 
@@ -914,7 +946,7 @@ export class Service extends Base {
914
946
  }
915
947
 
916
948
  get priority() {
917
- return /*this.#priority || */ this.owner.priority || 99;
949
+ return this.#priority || this.owner.priority || 99;
918
950
  }
919
951
 
920
952
  get weight() {
package/types/model.d.mts CHANGED
@@ -100,6 +100,9 @@ export class NetworkInterface extends Base {
100
100
  hwaddr: any;
101
101
  set network(networkOrName: any);
102
102
  get network(): any;
103
+ get ipAddresses(): any[];
104
+ get ipv4Addresses(): any[];
105
+ get ipv6Addresses(): any[];
103
106
  get scope(): any;
104
107
  get metric(): any;
105
108
  get ssid(): any;