pmcf 1.25.0 → 1.25.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.
@@ -2,7 +2,11 @@
2
2
 
3
3
  import { join } from "node:path";
4
4
  import { createHmac } from "node:crypto";
5
- import { writeLines, isIPv4Address } from "../src/utils.mjs";
5
+ import {
6
+ writeLines,
7
+ isIPv4Address,
8
+ normalizeIPAddress
9
+ } from "../src/utils.mjs";
6
10
  import { prepare } from "../src/cmd.mjs";
7
11
 
8
12
  const { world, args, options } = prepare();
@@ -41,7 +45,10 @@ async function generateNamedDefs(owner, targetDir) {
41
45
  type,
42
46
  value,
43
47
  toString: () =>
44
- `${key.padEnd(maxKeyLength, " ")} ${ttl} IN ${type.padEnd(5, " ")} ${value}`
48
+ `${key.padEnd(maxKeyLength, " ")} ${ttl} IN ${type.padEnd(
49
+ 5,
50
+ " "
51
+ )} ${value}`
45
52
  };
46
53
  };
47
54
 
@@ -201,16 +208,3 @@ export function reverseArpaAddress(address) {
201
208
  (isIPv4Address(address) ? ".in-addr.arpa" : ".ip6.arpa")
202
209
  );
203
210
  }
204
-
205
- export function normalizeIPAddress(address) {
206
- if (isIPv4Address(address)) {
207
- return address;
208
- }
209
- address = address.replace(/\/\d+$/, "");
210
- const parts = address.split(":");
211
- const i = parts.indexOf("");
212
- if (i >= 0) {
213
- parts.splice(i, 1, ..."0".repeat(9 - parts.length));
214
- }
215
- return parts.map(s => s.padStart(4, "0")).join(":");
216
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "1.25.0",
3
+ "version": "1.25.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/model.mjs CHANGED
@@ -4,7 +4,8 @@ import {
4
4
  asArray,
5
5
  bridgeToJSON,
6
6
  isIPv4Address,
7
- isIPv6Address
7
+ isIPv6Address,
8
+ normalizeIPAddress
8
9
  } from "./utils.mjs";
9
10
  import { Base } from "./base.mjs";
10
11
  import { Service } from "./service.mjs";
@@ -659,13 +660,11 @@ export class Host extends Base {
659
660
  }
660
661
 
661
662
  get ipAddresses() {
662
- return [...this.networkAddresses()].map(na => na.address);
663
+ return [...this.networkAddresses()].map(na => normalizeIPAddress(na.address));
663
664
  }
664
665
 
665
666
  get ipAddress() {
666
- for (const a of this.networkAddresses()) {
667
- return a.address;
668
- }
667
+ return this.ipAddresses[0];
669
668
  }
670
669
 
671
670
  async publicKey(type = "ed25519") {
package/src/utils.mjs CHANGED
@@ -39,3 +39,16 @@ export function isIPv4Address(address) {
39
39
  export function isIPv6Address(address) {
40
40
  return address.indexOf(":") >= 0;
41
41
  }
42
+
43
+ export function normalizeIPAddress(address) {
44
+ address = address.replace(/\/\d+$/, "");
45
+ if (isIPv4Address(address)) {
46
+ return address;
47
+ }
48
+ const parts = address.split(":");
49
+ const i = parts.indexOf("");
50
+ if (i >= 0) {
51
+ parts.splice(i, 1, ..."0".repeat(9 - parts.length));
52
+ }
53
+ return parts.map(s => s.padStart(4, "0")).join(":");
54
+ }
package/types/utils.d.mts CHANGED
@@ -4,3 +4,4 @@ export function bridgeToJSON(bridge: any): any[];
4
4
  export function asArray(value: any): any[];
5
5
  export function isIPv4Address(address: any): boolean;
6
6
  export function isIPv6Address(address: any): boolean;
7
+ export function normalizeIPAddress(address: any): any;