pmcf 2.24.1 → 2.24.3

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.24.1",
3
+ "version": "2.24.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/dns-utils.mjs CHANGED
@@ -5,6 +5,13 @@ export function dnsFullName(name) {
5
5
  return name.endsWith(".") ? name : name + ".";
6
6
  }
7
7
 
8
+ export function dnsRecordTypeForAddressFamily(family) {
9
+ switch(family) {
10
+ case 'IPv4': return "A";
11
+ case 'IPv6': return "AAAA";
12
+ }
13
+ }
14
+
8
15
  export function DNSRecord(key, type, ...values) {
9
16
  let pad = "";
10
17
 
@@ -0,0 +1,35 @@
1
+ import { familyIP } from "ip-utilties";
2
+
3
+ export class Endpoint {
4
+ constructor(service, networkInterface, data) {
5
+ this.service = service;
6
+ this.networkInterface = networkInterface;
7
+ Object.assign(this, data);
8
+ }
9
+
10
+ toString() {
11
+ return `${this.address}[${this.port}]`;
12
+ }
13
+
14
+ get socketAddress() {
15
+ return `${this.address}:${this.port}`;
16
+ }
17
+
18
+ get hostName() {
19
+ return this.networkInterface.hostName;
20
+ }
21
+
22
+ #address;
23
+
24
+ get address() {
25
+ return this.#address ?? this.networkInterface.address;
26
+ }
27
+
28
+ set address(value) {
29
+ this.#address = value;
30
+ }
31
+
32
+ get family() {
33
+ return familyIP(this.address);
34
+ }
35
+ }
package/src/module.mjs CHANGED
@@ -1,8 +1,4 @@
1
1
  export * from "./base.mjs";
2
- export * from "./service.mjs";
3
- export * from "./services/dns.mjs";
4
- export * from "./services/ntp.mjs";
5
- export * from "./services/dhcp.mjs";
6
2
  export * from "./cluster.mjs";
7
3
  export * from "./owner.mjs";
8
4
  export * from "./location.mjs";
@@ -10,7 +6,13 @@ export * from "./root.mjs";
10
6
  export * from "./address.mjs";
11
7
  export * from "./subnet.mjs";
12
8
  export * from "./network.mjs";
9
+ export * from "./network-address.mjs";
13
10
  export * from "./network-support.mjs";
14
11
  export * from "./network-interface.mjs";
15
12
  export * from "./host.mjs";
13
+ export * from "./service.mjs";
14
+ export * from "./endpoint.mjs";
15
+ export * from "./services/dns.mjs";
16
+ export * from "./services/ntp.mjs";
17
+ export * from "./services/dhcp.mjs";
16
18
  export * from "./types.mjs";
@@ -0,0 +1,33 @@
1
+ import { familyIP, formatCIDR } from "ip-utilties";
2
+ import { Subnet } from "./subnet.mjs";
3
+
4
+ /**
5
+ * @property {NetworkInterface} networkInterface
6
+ * @property {string|Uint8Array|Uint16Array} address
7
+ * @property {string} family
8
+ * @property {Subnet} subnet
9
+ * @property {Set<string>} domainNames
10
+ */
11
+ export class NetworkAddress {
12
+ /** @type {Subnet} */ subnet;
13
+ /** @type {NetworkInterface} */ networkInterface;
14
+ /** @type {string|Uint8Array|Uint16Array} */ address;
15
+
16
+ constructor(networkInterface, address, subnet) {
17
+ this.networkInterface = networkInterface;
18
+ this.address = address;
19
+ this.subnet = subnet;
20
+ }
21
+
22
+ get domainNames() {
23
+ return this.networkInterface.domainNames;
24
+ }
25
+
26
+ get family() {
27
+ return familyIP(this.address);
28
+ }
29
+
30
+ get cidrAddress() {
31
+ return formatCIDR(this.address, this.subnet.prefixLength);
32
+ }
33
+ }
@@ -1,15 +1,10 @@
1
+ import { hasWellKnownSubnet, normalizeIP } from "ip-utilties";
1
2
  import {
2
- hasWellKnownSubnet,
3
- normalizeIP,
4
- familyIP,
5
- formatCIDR
6
- } from "ip-utilties";
7
- import { Base } from "./base.mjs";
8
- import {
9
- Subnet,
3
+ NetworkAddress,
4
+ Base,
10
5
  SUBNET_LOCALHOST_IPV4,
11
6
  SUBNET_LOCALHOST_IPV6
12
- } from "./subnet.mjs";
7
+ } from "pmcf";
13
8
  import {
14
9
  networkProperties,
15
10
  networkAddressProperties
@@ -17,37 +12,6 @@ import {
17
12
  import { asArray } from "./utils.mjs";
18
13
  import { addType } from "./types.mjs";
19
14
 
20
- /**
21
- * @property {NetworkInterface} networkInterface
22
- * @property {string|Uint8Array|Uint16Array} address
23
- * @property {string} family
24
- * @property {Subnet} subnet
25
- * @property {Set<string>} domainNames
26
- */
27
- export class NetworkAddress {
28
- /** @type {Subnet} */ subnet;
29
- /** @type {NetworkInterface} */ networkInterface;
30
- /** @type {string|Uint8Array|Uint16Array} */ address;
31
-
32
- constructor(networkInterface, address, subnet) {
33
- this.networkInterface = networkInterface;
34
- this.address = address;
35
- this.subnet = subnet;
36
- }
37
-
38
- get domainNames() {
39
- this.networkInterface.domainNames;
40
- }
41
-
42
- get family() {
43
- return familyIP(this.address);
44
- }
45
-
46
- get cidrAddress() {
47
- return formatCIDR(this.address, this.subnet.prefixLength);
48
- }
49
- }
50
-
51
15
  class SkeletonNetworkInterface extends Base {
52
16
  _extends = [];
53
17
  _network;
package/src/service.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { isLocalhost, familyIP } from "ip-utilties";
2
- import { Base } from "./base.mjs";
1
+ import { isLocalhost } from "ip-utilties";
2
+ import { Base, Endpoint } from "pmcf";
3
3
  import { addType } from "./types.mjs";
4
4
  import { asArray } from "./utils.mjs";
5
5
  import { networkAddressProperties } from "./network-support.mjs";
@@ -310,40 +310,6 @@ export class Service extends Base {
310
310
  }
311
311
  }
312
312
 
313
- export class Endpoint {
314
- constructor(service, networkInterface, data) {
315
- this.service = service;
316
- this.networkInterface = networkInterface;
317
- Object.assign(this, data);
318
- }
319
-
320
- toString() {
321
- return `${this.address}[${this.port}]`;
322
- }
323
-
324
- get socketAddress() {
325
- return `${this.address}:${this.port}`;
326
- }
327
-
328
- get hostName() {
329
- return this.networkInterface.hostName;
330
- }
331
-
332
- #address;
333
-
334
- get address() {
335
- return this.#address ?? this.networkInterface.address;
336
- }
337
-
338
- set address(value) {
339
- this.#address = value;
340
- }
341
-
342
- get family() {
343
- return familyIP(this.address);
344
- }
345
- }
346
-
347
313
  export const sortByPriority = (a, b) => a.priority - b.priority;
348
314
 
349
315
  export function serviceAddresses(
@@ -5,7 +5,7 @@ import {
5
5
  ServiceTypeDefinition,
6
6
  Endpoint,
7
7
  serviceEndpoints
8
- } from "../service.mjs";
8
+ } from "pmcf";
9
9
  import { addType } from "../types.mjs";
10
10
  import { writeLines } from "../utils.mjs";
11
11
 
@@ -1,9 +1,13 @@
1
1
  import { join } from "node:path";
2
2
  import { createHmac } from "node:crypto";
3
3
  import { FileContentProvider } from "npm-pkgbuild";
4
- import { isIPv6, isLinkLocal, reverseArpa } from "ip-utilties";
4
+ import { isLinkLocal, reverseArpa } from "ip-utilties";
5
5
  import { writeLines } from "../utils.mjs";
6
- import { DNSRecord, dnsFullName } from "../dns-utils.mjs";
6
+ import {
7
+ DNSRecord,
8
+ dnsFullName,
9
+ dnsRecordTypeForAddressFamily
10
+ } from "../dns-utils.mjs";
7
11
  import { addType } from "../types.mjs";
8
12
  import { ServiceTypeDefinition, serviceAddresses } from "../service.mjs";
9
13
  import {
@@ -299,7 +303,7 @@ async function generateZoneDefs(dns, location, packageData) {
299
303
  na => na.networkInterface.kind != "loopback"
300
304
  )) {
301
305
  zone.records.add(
302
- DNSRecord("@", na.family === "IPv6" ? "AAAA" : "A", na.address)
306
+ DNSRecord("@", dnsRecordTypeForAddressFamily(na.family), na.address)
303
307
  );
304
308
  }
305
309
  }
@@ -364,7 +368,8 @@ async function generateZoneDefs(dns, location, packageData) {
364
368
  address,
365
369
  subnet,
366
370
  networkInterface,
367
- domainNames
371
+ domainNames,
372
+ family
368
373
  } of location.networkAddresses()) {
369
374
  if (
370
375
  !dns.exclude.has(networkInterface.network) &&
@@ -381,7 +386,7 @@ async function generateZoneDefs(dns, location, packageData) {
381
386
  zone.records.add(
382
387
  DNSRecord(
383
388
  dnsFullName(domainName),
384
- isIPv6(address) ? "AAAA" : "A",
389
+ dnsRecordTypeForAddressFamily(family),
385
390
  address
386
391
  )
387
392
  );
@@ -1,4 +1,5 @@
1
1
  export function dnsFullName(name: any): any;
2
+ export function dnsRecordTypeForAddressFamily(family: any): "A" | "AAAA";
2
3
  export function DNSRecord(key: any, type: any, ...values: any[]): {
3
4
  key: any;
4
5
  toString: (maxKeyLength?: number, ttl?: string) => string;
@@ -0,0 +1,12 @@
1
+ export class Endpoint {
2
+ constructor(service: any, networkInterface: any, data: any);
3
+ service: any;
4
+ networkInterface: any;
5
+ toString(): string;
6
+ get socketAddress(): string;
7
+ get hostName(): any;
8
+ set address(value: any);
9
+ get address(): any;
10
+ get family(): any;
11
+ #private;
12
+ }
@@ -1,8 +1,4 @@
1
1
  export * from "./base.mjs";
2
- export * from "./service.mjs";
3
- export * from "./services/dns.mjs";
4
- export * from "./services/ntp.mjs";
5
- export * from "./services/dhcp.mjs";
6
2
  export * from "./cluster.mjs";
7
3
  export * from "./owner.mjs";
8
4
  export * from "./location.mjs";
@@ -10,7 +6,13 @@ export * from "./root.mjs";
10
6
  export * from "./address.mjs";
11
7
  export * from "./subnet.mjs";
12
8
  export * from "./network.mjs";
9
+ export * from "./network-address.mjs";
13
10
  export * from "./network-support.mjs";
14
11
  export * from "./network-interface.mjs";
15
12
  export * from "./host.mjs";
13
+ export * from "./service.mjs";
14
+ export * from "./endpoint.mjs";
15
+ export * from "./services/dns.mjs";
16
+ export * from "./services/ntp.mjs";
17
+ export * from "./services/dhcp.mjs";
16
18
  export * from "./types.mjs";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @property {NetworkInterface} networkInterface
3
+ * @property {string|Uint8Array|Uint16Array} address
4
+ * @property {string} family
5
+ * @property {Subnet} subnet
6
+ * @property {Set<string>} domainNames
7
+ */
8
+ export class NetworkAddress {
9
+ constructor(networkInterface: any, address: any, subnet: any);
10
+ /** @type {Subnet} */ subnet: Subnet;
11
+ /** @type {NetworkInterface} */ networkInterface: NetworkInterface;
12
+ /** @type {string|Uint8Array|Uint16Array} */ address: string | Uint8Array | Uint16Array;
13
+ get domainNames(): any;
14
+ get family(): any;
15
+ get cidrAddress(): any;
16
+ }
17
+ import { Subnet } from "./subnet.mjs";
@@ -1,19 +1,3 @@
1
- /**
2
- * @property {NetworkInterface} networkInterface
3
- * @property {string|Uint8Array|Uint16Array} address
4
- * @property {string} family
5
- * @property {Subnet} subnet
6
- * @property {Set<string>} domainNames
7
- */
8
- export class NetworkAddress {
9
- constructor(networkInterface: any, address: any, subnet: any);
10
- /** @type {Subnet} */ subnet: Subnet;
11
- /** @type {NetworkInterface} */ networkInterface: NetworkInterface;
12
- /** @type {string|Uint8Array|Uint16Array} */ address: string | Uint8Array | Uint16Array;
13
- get domainNames(): void;
14
- get family(): any;
15
- get cidrAddress(): any;
16
- }
17
1
  export namespace NetworkInterfaceTypeDefinition {
18
2
  export let name: string;
19
3
  export let priority: number;
@@ -695,7 +679,7 @@ export class LoopbackNetworkInterface extends SkeletonNetworkInterface {
695
679
  get kind(): string;
696
680
  get scope(): string;
697
681
  get hostName(): string;
698
- get ipAddresses(): Map<string, Subnet>;
682
+ get ipAddresses(): Map<string, import("pmcf").Subnet>;
699
683
  }
700
684
  export class WireguardNetworkInterface extends SkeletonNetworkInterface {
701
685
  static get typeDefinition(): {
@@ -1022,7 +1006,6 @@ export class WireguardNetworkInterface extends SkeletonNetworkInterface {
1022
1006
  };
1023
1007
  get kind(): string;
1024
1008
  }
1025
- import { Subnet } from "./subnet.mjs";
1026
1009
  declare class SkeletonNetworkInterface extends Base {
1027
1010
  _extends: any[];
1028
1011
  _network: any;
@@ -1044,5 +1027,6 @@ declare class SkeletonNetworkInterface extends Base {
1044
1027
  get address(): any;
1045
1028
  get addresses(): any[];
1046
1029
  }
1047
- import { Base } from "./base.mjs";
1030
+ import { Base } from "pmcf";
1031
+ import { NetworkAddress } from "pmcf";
1048
1032
  export {};
@@ -329,17 +329,5 @@ export class Service extends Base {
329
329
  toString: (maxKeyLength?: number, ttl?: string) => string;
330
330
  }[];
331
331
  }
332
- export class Endpoint {
333
- constructor(service: any, networkInterface: any, data: any);
334
- service: any;
335
- networkInterface: any;
336
- toString(): string;
337
- get socketAddress(): string;
338
- get hostName(): any;
339
- set address(value: any);
340
- get address(): any;
341
- get family(): any;
342
- #private;
343
- }
344
332
  export function sortByPriority(a: any, b: any): number;
345
- import { Base } from "./base.mjs";
333
+ import { Base } from "pmcf";
@@ -266,5 +266,5 @@ export class DHCPService extends Service {
266
266
  };
267
267
  }, void, unknown>;
268
268
  }
269
- import { Service } from "../service.mjs";
269
+ import { Service } from "pmcf";
270
270
  import { FileContentProvider } from "npm-pkgbuild";