pmcf 2.35.0 → 2.35.2

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.0",
3
+ "version": "2.35.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/host.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { readFile } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
3
  import { FileContentProvider } from "npm-pkgbuild";
4
- import { ServiceOwner, Base } from "pmcf";
5
- import { networkAddressProperties, addresses } from "./network-support.mjs";
4
+ import { ServiceOwner, Base, addresses } from "pmcf";
5
+ import { networkAddressProperties } from "./network-support.mjs";
6
6
  import {
7
7
  domainFromDominName,
8
8
  domainName,
@@ -31,3 +31,17 @@ export class NetworkAddress {
31
31
  return `${this.networkInterface.fullName} ${decodeIP(this.address)}`;
32
32
  }
33
33
  }
34
+
35
+ export function addresses(networkAddresses) {
36
+ return [
37
+ ...new Set(
38
+ [...networkAddresses].map(object =>
39
+ /*object?.name ||*/ decodeIP(object.address)
40
+ )
41
+ )
42
+ ];
43
+ }
44
+
45
+ export function cidrAddresses(networkAddresses) {
46
+ return [...networkAddresses].map(na => na.cidrAddress);
47
+ }
@@ -1,13 +1,12 @@
1
1
  import { join } from "node:path";
2
2
  import { hasWellKnownSubnet, normalizeIP } from "ip-utilties";
3
- import { Base } from "pmcf";
3
+ import { Base, cidrAddresses } from "pmcf";
4
4
  import {
5
5
  networkProperties,
6
6
  networkAddressProperties
7
7
  } from "../network-support.mjs";
8
8
  import { asArray, writeLines, sectionLines } from "../utils.mjs";
9
9
  import { addType } from "../types.mjs";
10
- import { cidrAddresses } from "../network-support.mjs";
11
10
  import { SkeletonNetworkInterface } from "./skeleton.mjs";
12
11
 
13
12
  export const NetworkInterfaceTypeDefinition = {
@@ -1,8 +1,7 @@
1
1
  import { join } from "node:path";
2
2
  import { writeLines, sectionLines } from "../utils.mjs";
3
- import { NetworkAddress, Host } from "pmcf";
3
+ import { NetworkAddress, Host, cidrAddresses } from "pmcf";
4
4
  import { ServiceOwner } from "../service-owner.mjs";
5
- import { cidrAddresses } from "../network-support.mjs";
6
5
 
7
6
  export class SkeletonNetworkInterface extends ServiceOwner {
8
7
  _extends = [];
@@ -38,11 +38,3 @@ export const networkAddressProperties = {
38
38
  addresses: { type: "string", collection: true, writeable: false },
39
39
  address: { type: "string", collection: false, writeable: false }
40
40
  };
41
-
42
- export function addresses(networkAddresses) {
43
- return [...networkAddresses].map(na => na.address);
44
- }
45
-
46
- export function cidrAddresses(networkAddresses) {
47
- return [...networkAddresses].map(na => na.cidrAddress);
48
- }
package/src/service.mjs CHANGED
@@ -10,11 +10,6 @@ import {
10
10
  } from "./dns-utils.mjs";
11
11
 
12
12
  const ServiceTypes = {
13
- "systemd-resolved": { endpoints: [] },
14
- "systemd-timesyncd": { endpoints: [] },
15
- "systemd-journal": { endpoints: [] },
16
- "systemd-journal-remote": { endpoints: [] },
17
- "systemd-journal-upload": { endpoints: [] },
18
13
  ntp: { endpoints: [{ protocol: "udp", port: 123, tls: false }] },
19
14
  dns: { endpoints: [{ protocol: "udp", port: 53, tls: false }] },
20
15
  ldap: { endpoints: [{ protocol: "tcp", port: 389, tls: false }] },
@@ -1,19 +1,23 @@
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, decodeIP } from "ip-utilties";
5
- import { writeLines } from "../utils.mjs";
4
+ import { isLinkLocal, reverseArpa } from "ip-utilties";
5
+ import { writeLines, asArray } from "../utils.mjs";
6
6
  import {
7
7
  DNSRecord,
8
8
  dnsFullName,
9
9
  dnsRecordTypeForAddressFamily,
10
10
  sortZoneRecords
11
11
  } from "../dns-utils.mjs";
12
- import { ExtraSourceService, Endpoint, serviceEndpoints } from "pmcf";
12
+ import {
13
+ ExtraSourceService,
14
+ Endpoint,
15
+ serviceEndpoints,
16
+ addresses
17
+ } from "pmcf";
13
18
  import { addType } from "../types.mjs";
14
19
  import { ServiceTypeDefinition } from "../service.mjs";
15
20
  import { ExtraSourceServiceTypeDefinition } from "../extra-source-service.mjs";
16
- import { addresses } from "../network-support.mjs";
17
21
  import { addHook } from "../hooks.mjs";
18
22
 
19
23
  const address_types = ["network", "host", "network_interface"];
@@ -87,23 +91,8 @@ const statisticsEndpoint = {
87
91
  tls: false
88
92
  };
89
93
 
90
- function addressList(objects) {
91
- return Array.from(objects).map(object => {
92
- switch (typeof object) {
93
- case "string":
94
- return object;
95
- case "object":
96
- if (object.name) {
97
- return object.name;
98
- }
99
-
100
- return decodeIP(object);
101
- }
102
- });
103
- }
104
-
105
94
  function addressesStatement(prefix, objects, generateEmpty = false) {
106
- const body = addressList(objects).map(name => ` ${name};`);
95
+ const body = asArray(objects).map(name => ` ${name};`);
107
96
 
108
97
  if (body.length || generateEmpty) {
109
98
  return [`${prefix} {`, body, "};"];
@@ -221,7 +210,7 @@ export class DNSService extends ExtraSourceService {
221
210
  };
222
211
 
223
212
  const forwarders = serviceEndpoints(this.source, {
224
- services: { type: "dns", priority: ">=10" },
213
+ services: { type: "dns", priority: ">=20" },
225
214
  select: e => e.address
226
215
  });
227
216
 
@@ -235,8 +224,11 @@ export class DNSService extends ExtraSourceService {
235
224
 
236
225
  const acls = [
237
226
  addressesStatement("acl trusted", addresses(this.trusted)),
238
- addressesStatement("acl protected", addresses(this.protected)),
239
- addressesStatement("acl open", addresses(this.open), true)
227
+ addressesStatement("acl open", addresses(this.open), true),
228
+ addressesStatement("acl protected", [
229
+ ...addresses(this.protected),
230
+ "!open"
231
+ ])
240
232
  ].flat();
241
233
 
242
234
  if (acls.length) {
@@ -65,7 +65,7 @@ export class NTPService extends ExtraSourceService {
65
65
  ...serviceEndpoints(this, {
66
66
  services: {
67
67
  type: "ntp",
68
- priority: ">=10"
68
+ priority: ">=20"
69
69
  },
70
70
  endpoints: e =>
71
71
  e.family === "IPv4" && e.networkInterface.kind !== "loopback",
@@ -52,7 +52,7 @@ export class SystemdResolvedService extends ExtraSourceService {
52
52
  "Resolve",
53
53
  {
54
54
  DNS: serviceEndpoints(this, options("<10")),
55
- FallbackDNS: serviceEndpoints(this, options(">=10")),
55
+ FallbackDNS: serviceEndpoints(this, options(">=20")),
56
56
  Domains: [...this.localDomains].join(" "),
57
57
  DNSSEC: "no",
58
58
  MulticastDNS: this.network.multicastDNS ? "yes" : "no",
@@ -45,7 +45,7 @@ export class SystemdTimesyncdService extends ExtraSourceService {
45
45
  NTP: serviceEndpoints(this, {
46
46
  services: {
47
47
  type: "ntp",
48
- priority: "<20"
48
+ priority: "<10"
49
49
  },
50
50
  endpoints: endpoint =>
51
51
  endpoint.networkInterface.kind !== "loopback",
@@ -1,3 +1,5 @@
1
+ export function addresses(networkAddresses: any): any[];
2
+ export function cidrAddresses(networkAddresses: any): any[];
1
3
  /**
2
4
  *
3
5
  */
@@ -1,5 +1,3 @@
1
- export function addresses(networkAddresses: any): any[];
2
- export function cidrAddresses(networkAddresses: any): any[];
3
1
  export namespace networkProperties {
4
2
  export namespace scope {
5
3
  export let type: string;