pmcf 1.71.0 → 1.72.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": "1.71.0",
3
+ "version": "1.72.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/dns.mjs CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  } from "./utils.mjs";
10
10
  import { Base } from "./base.mjs";
11
11
  import { addType } from "./types.mjs";
12
- import { sortByPriority } from "./service.mjs";
12
+ import { serviceAddresses } from "./service.mjs";
13
13
  import { subnets } from "./subnet.mjs";
14
14
 
15
15
  const DNSServiceTypeDefinition = {
@@ -91,15 +91,6 @@ export class DNSService extends Base {
91
91
  return this.#forwardsTo;
92
92
  }
93
93
 
94
- get forwardsToAdresses() {
95
- return this.forwardsTo
96
- .map(ft => Array.from(ft.findServices(DNS_SERVICE_FILTER)))
97
- .flat()
98
- .sort(sortByPriority)
99
- .map(s => s.rawAddresses)
100
- .flat();
101
- }
102
-
103
94
  *findServices(filter) {
104
95
  yield* this.owner.findServices(filter);
105
96
 
@@ -113,22 +104,15 @@ export class DNSService extends Base {
113
104
  }
114
105
 
115
106
  async resolvedConfig() {
116
- const dnsServices = Array.from(this.findServices(DNS_SERVICE_FILTER)).sort(
117
- sortByPriority
118
- );
119
-
120
- const master = dnsServices
121
- .filter(s => s.priority < 10)
122
- .map(s => s.rawAddresses)
123
- .flat();
124
- const fallback = dnsServices
125
- .filter(s => s.priority >= 10)
126
- .map(s => s.rawAddresses)
127
- .flat();
128
-
129
107
  return {
130
- DNS: master.join(" "),
131
- FallbackDNS: fallback.join(" "),
108
+ DNS: serviceAddresses(this, {
109
+ ...DNS_SERVICE_FILTER,
110
+ priority: "<10"
111
+ }).join(" "),
112
+ FallbackDNS: serviceAddresses(this, {
113
+ ...DNS_SERVICE_FILTER,
114
+ priority: ">=10"
115
+ }).join(" "),
132
116
  Domains: this.domains.join(" "),
133
117
  DNSSEC: "no",
134
118
  MulticastDNS: "yes",
@@ -152,7 +136,9 @@ export class DNSService extends Base {
152
136
 
153
137
  const options = [
154
138
  "forwarders {",
155
- ...this.forwardsToAdresses.map(a => ` ${a};`),
139
+ ...serviceAddresses(this.forwardsTo, DNS_SERVICE_FILTER).map(
140
+ a => ` ${a};`
141
+ ),
156
142
  "};"
157
143
  ];
158
144
  await writeLines(join(p1, "etc/named.d/options"), `${name}.conf`, options);
package/src/service.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Base } from "./base.mjs";
2
2
  import { addType } from "./types.mjs";
3
+ import { asArray } from "./utils.mjs";
3
4
 
4
5
  const ServiceTypes = {
5
6
  dns: { protocol: "udp", port: 53 },
@@ -166,3 +167,16 @@ export class Service extends Base {
166
167
  }
167
168
 
168
169
  export const sortByPriority = (a, b) => a.priority - b.priority;
170
+
171
+ export function serviceAddresses(
172
+ sources,
173
+ filter,
174
+ addressType = "rawAddresses"
175
+ ) {
176
+ return asArray(sources)
177
+ .map(ft => Array.from(ft.findServices(filter)))
178
+ .flat()
179
+ .sort(sortByPriority)
180
+ .map(s => s[addressType])
181
+ .flat();
182
+ }
package/types/dns.d.mts CHANGED
@@ -83,7 +83,6 @@ export class DNSService extends Base {
83
83
  get trusted(): any[];
84
84
  set forwardsTo(value: any[]);
85
85
  get forwardsTo(): any[];
86
- get forwardsToAdresses(): any[];
87
86
  get domains(): any[];
88
87
  resolvedConfig(): Promise<{
89
88
  DNS: string;
@@ -1,3 +1,4 @@
1
+ export function serviceAddresses(sources: any, filter: any, addressType?: string): any[];
1
2
  export class Service extends Base {
2
3
  static get typeDefinition(): {
3
4
  name: string;