pmcf 3.14.1 → 3.14.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": "3.14.1",
3
+ "version": "3.14.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -51,8 +51,8 @@
51
51
  "lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
52
52
  },
53
53
  "dependencies": {
54
- "ip-utilties": "^1.4.11",
55
- "npm-pkgbuild": "^19.0.1",
54
+ "ip-utilties": "^1.4.12",
55
+ "npm-pkgbuild": "^19.0.3",
56
56
  "pacc": "^4.41.1",
57
57
  "package-directory": "^8.1.0"
58
58
  },
package/src/endpoint.mjs CHANGED
@@ -23,6 +23,9 @@ class BaseEndpoint {
23
23
  }
24
24
  }
25
25
 
26
+ /**
27
+ * Endpoint with an ip port
28
+ */
26
29
  class PortEndpoint extends BaseEndpoint {
27
30
  _port;
28
31
  constructor(service, data) {
@@ -108,6 +111,9 @@ export class DomainNameEndpoint extends PortEndpoint {
108
111
  }
109
112
  }
110
113
 
114
+ /**
115
+ * Endpoint based on http
116
+ */
111
117
  export class HTTPEndpoint extends BaseEndpoint {
112
118
  constructor(service, address, data) {
113
119
  super(service, data);
@@ -1,6 +1,7 @@
1
1
  import { familyIP, formatCIDR, decodeIP } from "ip-utilties";
2
2
  import { Subnet } from "./subnet.mjs";
3
3
  import { Owner } from "pmcf";
4
+ import { NetworkInterface } from "./network-interfaces/network-interface.mjs";
4
5
 
5
6
  /**
6
7
  *
@@ -10,6 +11,12 @@ export class NetworkAddress {
10
11
  /** @type {NetworkInterface} */ networkInterface;
11
12
  /** @type {string|Uint8Array|Uint16Array} */ address;
12
13
 
14
+ /**
15
+ *
16
+ * @param {NetworkInterface} networkInterface
17
+ * @param {string|Uint8Array|Uint16Array} address
18
+ * @param {Subnet} subnet
19
+ */
13
20
  constructor(networkInterface, address, subnet) {
14
21
  this.networkInterface = networkInterface;
15
22
  this.address = address;
@@ -34,9 +41,9 @@ export class NetworkAddress {
34
41
  }
35
42
 
36
43
  /**
37
- *
38
- * @param {Iterable<Owner|string>} sources
39
- * @param {Object} options
44
+ *
45
+ * @param {Iterable<Owner|string>} sources
46
+ * @param {Object} options
40
47
  * @param {boolean} options.aggregate
41
48
  * @param {Object} options.filter
42
49
  * @returns {Iterable<string>} addresses
@@ -46,7 +53,7 @@ export function addresses(sources, options) {
46
53
  ...new Set(
47
54
  [...sources]
48
55
  .map(s => {
49
- if(typeof s === "string") {
56
+ if (typeof s === "string") {
50
57
  return s;
51
58
  }
52
59
  if (options?.aggregate && s instanceof Owner && s.subnets) {
@@ -58,11 +65,18 @@ export function addresses(sources, options) {
58
65
  : s;
59
66
  })
60
67
  .flat()
61
- .map(object => typeof object === "string" ? object : decodeIP(object.address))
68
+ .map(object =>
69
+ typeof object === "string" ? object : decodeIP(object.address)
70
+ )
62
71
  )
63
72
  ];
64
73
  }
65
74
 
75
+ /**
76
+ *
77
+ * @param {Array<NetworkAddress>} networkAddresses
78
+ * @returns {Array<string>}
79
+ */
66
80
  export function cidrAddresses(networkAddresses) {
67
81
  return [...networkAddresses].map(na => na.cidrAddress);
68
82
  }
@@ -134,7 +134,9 @@ export class NetworkInterface extends SkeletonNetworkInterface {
134
134
 
135
135
  get domainNames() {
136
136
  return this.hostName
137
- ? new Set([[this.hostName, this.host.domain].join(".")])
137
+ ? this.host.directDomainNames.union(
138
+ new Set([[this.hostName, this.host.domain].join(".")])
139
+ )
138
140
  : this.host.directDomainNames;
139
141
  }
140
142
 
@@ -468,21 +468,23 @@ export class BindService extends ExtraSourceService {
468
468
  }
469
469
 
470
470
  for (const domainName of domainNames) {
471
- zone.records.add(
472
- DNSRecord(
473
- dnsFullName(domainName),
474
- dnsRecordTypeForAddressFamily(family),
475
- address
476
- )
477
- );
478
-
479
- reverseZone.records.add(
480
- DNSRecord(
481
- dnsFullName(reverseArpa(address)),
482
- "PTR",
483
- dnsFullName(domainName)
484
- )
485
- );
471
+ if (domainName[0] != "*") {
472
+ zone.records.add(
473
+ DNSRecord(
474
+ dnsFullName(domainName),
475
+ dnsRecordTypeForAddressFamily(family),
476
+ address
477
+ )
478
+ );
479
+
480
+ reverseZone.records.add(
481
+ DNSRecord(
482
+ dnsFullName(reverseArpa(address)),
483
+ "PTR",
484
+ dnsFullName(domainName)
485
+ )
486
+ );
487
+ }
486
488
  }
487
489
  }
488
490
 
package/src/utils.mjs CHANGED
@@ -45,6 +45,12 @@ export async function writeLines(dir, name, lines) {
45
45
  return writeFile(join(dir, name), data, "utf8");
46
46
  }
47
47
 
48
+ /**
49
+ *
50
+ * @param {string} sectionName
51
+ * @param {Object} values
52
+ * @returns {Array<string>}
53
+ */
48
54
  export function sectionLines(sectionName, values) {
49
55
  const lines = [`[${sectionName}]`];
50
56
 
@@ -59,10 +65,18 @@ export function bridgeToJSON(bridge) {
59
65
  return [...bridge].map(n => n.fullName || `(${n})`).sort();
60
66
  }
61
67
 
68
+ /**
69
+ * @param {any} value
70
+ * @returns {Array<any>}
71
+ */
62
72
  export function asArray(value) {
63
73
  return Array.isArray(value) ? value : value === undefined ? [] : [value];
64
74
  }
65
75
 
76
+ /**
77
+ * @param {any} value
78
+ * @returns {Iterable<any>}
79
+ */
66
80
  export function asIterator(value) {
67
81
  switch (typeof value) {
68
82
  case "undefined":
@@ -15,6 +15,9 @@ export class DomainNameEndpoint extends PortEndpoint {
15
15
  get address(): any;
16
16
  get isPool(): boolean;
17
17
  }
18
+ /**
19
+ * Endpoint based on http
20
+ */
18
21
  export class HTTPEndpoint extends BaseEndpoint {
19
22
  constructor(service: any, address: any, data: any);
20
23
  url: URL;
@@ -36,6 +39,9 @@ export class UnixEndpoint extends BaseEndpoint {
36
39
  get host(): any;
37
40
  get address(): any;
38
41
  }
42
+ /**
43
+ * Endpoint with an ip port
44
+ */
39
45
  declare class PortEndpoint extends BaseEndpoint {
40
46
  _port: any;
41
47
  protocol: any;
@@ -10,20 +10,32 @@ export function addresses(sources: Iterable<Owner | string>, options: {
10
10
  aggregate: boolean;
11
11
  filter: any;
12
12
  }): Iterable<string>;
13
- export function cidrAddresses(networkAddresses: any): any[];
13
+ /**
14
+ *
15
+ * @param {Array<NetworkAddress>} networkAddresses
16
+ * @returns {Array<string>}
17
+ */
18
+ export function cidrAddresses(networkAddresses: Array<NetworkAddress>): Array<string>;
14
19
  export function sortByFamilyAndAddress(a: any, b: any): any;
15
20
  /**
16
21
  *
17
22
  */
18
23
  export class NetworkAddress {
19
- constructor(networkInterface: any, address: any, subnet: any);
24
+ /**
25
+ *
26
+ * @param {NetworkInterface} networkInterface
27
+ * @param {string|Uint8Array|Uint16Array} address
28
+ * @param {Subnet} subnet
29
+ */
30
+ constructor(networkInterface: NetworkInterface, address: string | Uint8Array | Uint16Array, subnet: Subnet);
20
31
  /** @type {Subnet} */ subnet: Subnet;
21
32
  /** @type {NetworkInterface} */ networkInterface: NetworkInterface;
22
33
  /** @type {string|Uint8Array|Uint16Array} */ address: string | Uint8Array | Uint16Array;
23
- get domainNames(): any;
34
+ get domainNames(): Set<any>;
24
35
  get family(): any;
25
36
  get cidrAddress(): any;
26
37
  toString(): string;
27
38
  }
28
39
  import { Owner } from "pmcf";
29
40
  import { Subnet } from "./subnet.mjs";
41
+ import { NetworkInterface } from "./network-interfaces/network-interface.mjs";
package/types/utils.d.mts CHANGED
@@ -1,7 +1,21 @@
1
1
  export function domainName(name: any, defaultDomain: any): any;
2
2
  export function domainFromDominName(domainName: any, defaultDomain: any): any;
3
3
  export function writeLines(dir: any, name: any, lines: any): Promise<void>;
4
- export function sectionLines(sectionName: any, values: any): string[];
4
+ /**
5
+ *
6
+ * @param {string} sectionName
7
+ * @param {Object} values
8
+ * @returns {Array<string>}
9
+ */
10
+ export function sectionLines(sectionName: string, values: any): Array<string>;
5
11
  export function bridgeToJSON(bridge: any): any[];
6
- export function asArray(value: any): any[];
7
- export function asIterator(value: any): any;
12
+ /**
13
+ * @param {any} value
14
+ * @returns {Array<any>}
15
+ */
16
+ export function asArray(value: any): Array<any>;
17
+ /**
18
+ * @param {any} value
19
+ * @returns {Iterable<any>}
20
+ */
21
+ export function asIterator(value: any): Iterable<any>;