pmcf 2.35.5 → 2.36.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": "2.35.5",
3
+ "version": "2.36.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -1,5 +1,6 @@
1
1
  import { familyIP, formatCIDR, decodeIP } from "ip-utilties";
2
2
  import { Subnet } from "./subnet.mjs";
3
+ import { Owner } from "pmcf";
3
4
 
4
5
  /**
5
6
  *
@@ -32,12 +33,21 @@ export class NetworkAddress {
32
33
  }
33
34
  }
34
35
 
35
- export function addresses(networkAddresses) {
36
+ export function addresses(sources, options) {
36
37
  return [
37
38
  ...new Set(
38
- [...networkAddresses].map(object =>
39
- /*object?.name ||*/ decodeIP(object.address)
40
- )
39
+ [...sources]
40
+ .map(s => {
41
+ if (options?.aggregate && s instanceof Owner && s.subnets) {
42
+ return [...s.subnets()];
43
+ }
44
+
45
+ return s.networkAddresses
46
+ ? [...s.networkAddresses(options?.filter)]
47
+ : s;
48
+ })
49
+ .flat()
50
+ .map(object => decodeIP(object.address))
41
51
  )
42
52
  ];
43
53
  }
@@ -224,10 +224,17 @@ export class DNSService extends ExtraSourceService {
224
224
  }
225
225
 
226
226
  const acls = [
227
- addressesStatement("acl trusted", addresses(this.trusted)),
228
- addressesStatement("acl open", addresses(this.open), true),
227
+ addressesStatement(
228
+ "acl trusted",
229
+ addresses(this.trusted, { aggregate: true })
230
+ ),
231
+ addressesStatement(
232
+ "acl open",
233
+ addresses(this.open, { aggregate: true }),
234
+ true
235
+ ),
229
236
  addressesStatement("acl protected", [
230
- ...addresses(this.protected),
237
+ ...addresses(this.protected, { aggregate: true }),
231
238
  "!open"
232
239
  ])
233
240
  ].flat();
@@ -1,4 +1,4 @@
1
- export function addresses(networkAddresses: any): any[];
1
+ export function addresses(sources: any, options: any): any[];
2
2
  export function cidrAddresses(networkAddresses: any): any[];
3
3
  /**
4
4
  *