pmcf 2.32.0 → 2.32.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "2.32.0",
3
+ "version": "2.32.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -38,7 +38,7 @@
38
38
  "lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target es2024 --lib esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
39
39
  },
40
40
  "dependencies": {
41
- "ip-utilties": "^1.3.0",
41
+ "ip-utilties": "^1.3.1",
42
42
  "npm-pkgbuild": "^18.0.1",
43
43
  "pacc": "^3.4.0",
44
44
  "pkg-dir": "^8.0.0"
@@ -1,8 +1,8 @@
1
- import { familyIP, formatCIDR,decodeIP } from "ip-utilties";
1
+ import { familyIP, formatCIDR, decodeIP } from "ip-utilties";
2
2
  import { Subnet } from "./subnet.mjs";
3
3
 
4
4
  /**
5
- *
5
+ *
6
6
  */
7
7
  export class NetworkAddress {
8
8
  /** @type {Subnet} */ subnet;
@@ -27,9 +27,7 @@ export class NetworkAddress {
27
27
  return formatCIDR(this.address, this.subnet.prefixLength);
28
28
  }
29
29
 
30
-
31
- toString()
32
- {
30
+ toString() {
33
31
  return `${this.networkInterface.fullName} ${decodeIP(this.address)}`;
34
32
  }
35
33
  }
@@ -20,9 +20,9 @@ export const NetworkInterfaceTypeDefinition = {
20
20
  const kind = value.kind;
21
21
  const t = NetworkInterfaceTypeDefinition.specializations[kind];
22
22
 
23
- if (!t) {
23
+ /*if (!t) {
24
24
  console.warn("FACTORY", owner.name, value, t?.name);
25
- }
25
+ }*/
26
26
  if (t) {
27
27
  delete value.type;
28
28
  delete value.kind;
package/src/network.mjs CHANGED
@@ -39,6 +39,12 @@ export class Network extends Owner {
39
39
  return this;
40
40
  }
41
41
 
42
+ get address() {
43
+ for(const subnet of this.subnets()) {
44
+ return subnet.address;
45
+ }
46
+ }
47
+
42
48
  networkNamed(name) {
43
49
  if (this.isNamed(name)) {
44
50
  return this;
package/src/owner.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { normalizeCIDR } from "ip-utilties";
1
+ import { normalizeCIDR, familyIP } from "ip-utilties";
2
2
  import { asIterator } from "./utils.mjs";
3
3
  import { Base } from "./base.mjs";
4
- import { Subnet } from "./subnet.mjs";
4
+ import { Subnet, SUBNET_GLOBAL_IPV4, SUBNET_GLOBAL_IPV6 } from "./subnet.mjs";
5
5
  import { addType, types } from "./types.mjs";
6
6
  const OwnerTypeDefinition = {
7
7
  name: "owner",
@@ -182,19 +182,25 @@ export class Owner extends Base {
182
182
  }
183
183
 
184
184
  addSubnet(address) {
185
- const { cidr } = normalizeCIDR(address);
185
+ const { cidr, prefixLength } = normalizeCIDR(address);
186
186
 
187
- if (cidr) {
187
+ if (cidr && prefixLength !== 0) {
188
188
  return this.subnetNamed(cidr) || new Subnet(this, cidr);
189
189
  }
190
190
 
191
- const subnet = this.subnetForAddress(address);
191
+ let subnet = this.subnetForAddress(address);
192
+
192
193
  if (!subnet) {
194
+ subnet = familyIP(address) === 'IPv4' ? SUBNET_GLOBAL_IPV4 : SUBNET_GLOBAL_IPV6;
195
+
196
+ /*
193
197
  this.error(
194
198
  `Address without subnet ${address}`,
195
199
  [...this.subnets()].map(s => s.address)
196
200
  );
201
+ */
197
202
  }
203
+
198
204
  return subnet;
199
205
  }
200
206
 
@@ -1,7 +1,7 @@
1
1
  import { join } from "node:path";
2
2
  import { createHmac } from "node:crypto";
3
3
  import { FileContentProvider } from "npm-pkgbuild";
4
- import { isLinkLocal, reverseArpa } from "ip-utilties";
4
+ import { isLinkLocal, reverseArpa, decodeIP } from "ip-utilties";
5
5
  import { writeLines } from "../utils.mjs";
6
6
  import {
7
7
  DNSRecord,
@@ -16,7 +16,7 @@ import {
16
16
  ExtraSourceService,
17
17
  ExtraSourceServiceTypeDefinition
18
18
  } from "../extra-source-service.mjs";
19
- import { subnets } from "../subnet.mjs";
19
+ import { addresses } from "../network-support.mjs";
20
20
  import { addHook } from "../hooks.mjs";
21
21
 
22
22
  const address_types = ["network", "host", "network_interface"];
@@ -93,9 +93,18 @@ const statisticsEndpoint = {
93
93
  const DNS_SERVICE_FILTER = { type: DNSServiceTypeDefinition.name };
94
94
 
95
95
  function addressList(objects) {
96
- return Array.from(objects).map(object =>
97
- typeof object === "string" ? object : object.name
98
- );
96
+ return Array.from(objects).map(object => {
97
+ switch (typeof object) {
98
+ case "string":
99
+ return object;
100
+ case "object":
101
+ if (object.name) {
102
+ return object.name;
103
+ }
104
+
105
+ return decodeIP(object);
106
+ }
107
+ });
99
108
  }
100
109
 
101
110
  function addressesStatement(prefix, objects, generateEmpty = false) {
@@ -147,7 +156,7 @@ export class DNSService extends ExtraSourceService {
147
156
  endpoints(filter) {
148
157
  const endpoints = super.endpoints(filter);
149
158
 
150
- for (const na of this.server.networkAddresses(
159
+ for (const na of this.owner.networkAddresses(
151
160
  na => na.networkInterface.kind === "localhost"
152
161
  )) {
153
162
  endpoints.push(new Endpoint(this, na, rdncEndpoint));
@@ -249,9 +258,9 @@ export class DNSService extends ExtraSourceService {
249
258
  }
250
259
 
251
260
  const acls = [
252
- addressesStatement("acl trusted", subnets(this.trusted)),
253
- addressesStatement("acl protected", subnets(this.protected)),
254
- addressesStatement("acl open", subnets(this.open), true)
261
+ addressesStatement("acl trusted", addresses(this.trusted)),
262
+ addressesStatement("acl protected", addresses(this.protected)),
263
+ addressesStatement("acl open", addresses(this.open), true)
255
264
  ].flat();
256
265
 
257
266
  if (acls.length) {
package/src/subnet.mjs CHANGED
@@ -56,9 +56,8 @@ export class Subnet extends Base {
56
56
  try {
57
57
  return matchPrefixIP(this.address, this.prefixLength, address);
58
58
  } catch (e) {
59
- console.error(e, address, this.address, this.prefixLength);
59
+ console.error(e, this.toString(), address);
60
60
  }
61
-
62
61
  return false;
63
62
  }
64
63
 
@@ -92,6 +91,7 @@ export class Subnet extends Base {
92
91
 
93
92
  const _owner = { addObject() {} };
94
93
  export const SUBNET_GLOBAL_IPV4 = new Subnet(_owner, "0.0.0.0/0");
94
+ export const SUBNET_GLOBAL_IPV6 = new Subnet(_owner, "::0/0");
95
95
  export const SUBNET_LOCALHOST_IPV4 = new Subnet(_owner, "127.0.0.1/8");
96
96
  export const SUBNET_LOCALHOST_IPV6 = new Subnet(_owner, "::1/128");
97
97
 
@@ -201,6 +201,7 @@ export class Network extends Owner {
201
201
  gateway: any;
202
202
  _bridge: any;
203
203
  get network(): this;
204
+ get address(): any;
204
205
  set bridge(network: any);
205
206
  get bridge(): any;
206
207
  }
@@ -38,6 +38,7 @@ export class Subnet extends Base {
38
38
  _traverse(...args: any[]): boolean;
39
39
  }
40
40
  export const SUBNET_GLOBAL_IPV4: Subnet;
41
+ export const SUBNET_GLOBAL_IPV6: Subnet;
41
42
  export const SUBNET_LOCALHOST_IPV4: Subnet;
42
43
  export const SUBNET_LOCALHOST_IPV6: Subnet;
43
44
  import { Base } from "./base.mjs";