pmcf 2.35.4 → 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
package/src/network-address.mjs
CHANGED
|
@@ -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(
|
|
36
|
+
export function addresses(sources, options) {
|
|
36
37
|
return [
|
|
37
38
|
...new Set(
|
|
38
|
-
[...
|
|
39
|
-
|
|
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
|
}
|
package/src/service.mjs
CHANGED
|
@@ -318,5 +318,9 @@ export function serviceEndpoints(sources, options = {}) {
|
|
|
318
318
|
|
|
319
319
|
const res = [...new Set(options.select ? all.map(options.select) : all)];
|
|
320
320
|
|
|
321
|
+
if(options.limit < res.length) {
|
|
322
|
+
res.length = options.limit;
|
|
323
|
+
}
|
|
324
|
+
|
|
321
325
|
return options.join ? res.join(options.join) : res;
|
|
322
326
|
}
|
package/src/services/dns.mjs
CHANGED
|
@@ -211,7 +211,8 @@ export class DNSService extends ExtraSourceService {
|
|
|
211
211
|
|
|
212
212
|
const forwarders = serviceEndpoints(this.source, {
|
|
213
213
|
services: { type: "dns", priority: ">=20" },
|
|
214
|
-
select: e => e.address
|
|
214
|
+
select: e => e.address,
|
|
215
|
+
limit: 5
|
|
215
216
|
});
|
|
216
217
|
|
|
217
218
|
if (forwarders.length) {
|
|
@@ -223,10 +224,17 @@ export class DNSService extends ExtraSourceService {
|
|
|
223
224
|
}
|
|
224
225
|
|
|
225
226
|
const acls = [
|
|
226
|
-
addressesStatement(
|
|
227
|
-
|
|
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
|
+
),
|
|
228
236
|
addressesStatement("acl protected", [
|
|
229
|
-
...addresses(this.protected),
|
|
237
|
+
...addresses(this.protected, { aggregate: true }),
|
|
230
238
|
"!open"
|
|
231
239
|
])
|
|
232
240
|
].flat();
|
|
@@ -42,7 +42,8 @@ export class SystemdResolvedService extends ExtraSourceService {
|
|
|
42
42
|
services: { type: "dns", priority },
|
|
43
43
|
endpoints: e => e.networkInterface.kind !== "loopback",
|
|
44
44
|
select: endpoint => endpoint.address,
|
|
45
|
-
join: " "
|
|
45
|
+
join: " ",
|
|
46
|
+
limit: 5
|
|
46
47
|
};
|
|
47
48
|
};
|
|
48
49
|
|