pmcf 1.77.0 → 1.77.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": "1.77.0",
3
+ "version": "1.77.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/dns-utils.mjs CHANGED
@@ -14,3 +14,9 @@ export function DNSRecord(key, type, ...values) {
14
14
  )} ${values.join(" ")}`
15
15
  };
16
16
  }
17
+
18
+ export function dnsFormatParameters(parameters) {
19
+ return Object.entries(parameters)
20
+ .map(([name, value]) => (value !== undefined ? `${name}="${value}"` : name))
21
+ .join(" ");
22
+ }
package/src/dns.mjs CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  normalizeIPAddress,
8
8
  isLinkLocal
9
9
  } from "./utils.mjs";
10
- import { DNSRecord, dnsFullName } from "./dns-utils.mjs";
10
+ import { DNSRecord, dnsFullName, dnsFormatParameters } from "./dns-utils.mjs";
11
11
  import { Base } from "./base.mjs";
12
12
  import { addType } from "./types.mjs";
13
13
  import { serviceAddresses } from "./service.mjs";
@@ -213,7 +213,13 @@ async function generateZoneDefs(dns, targetDir) {
213
213
  dnsFullName(nameService.ipAddressOrDomainName)
214
214
  );
215
215
 
216
- const ALPNRecord = DNSRecord("@", "HTTPS", 1, ".", "alpn=h3");
216
+ const ALPNRecord = DNSRecord(
217
+ "@",
218
+ "HTTPS",
219
+ 1,
220
+ ".",
221
+ dnsFormatParameters({ alpn: "h3" })
222
+ );
217
223
 
218
224
  const zone = {
219
225
  id: domain,
@@ -298,7 +304,10 @@ async function generateZoneDefs(dns, targetDir) {
298
304
  if (!hosts.has(host)) {
299
305
  hosts.add(host);
300
306
  for (const service of host.findServices()) {
301
- for (const record of service.dnsRecordsForDomainName(domainName, dns.hasSVRRecords)) {
307
+ for (const record of service.dnsRecordsForDomainName(
308
+ domainName,
309
+ dns.hasSVRRecords
310
+ )) {
302
311
  zone.records.add(record);
303
312
  }
304
313
  }
package/src/service.mjs CHANGED
@@ -2,14 +2,28 @@ import { Base } from "./base.mjs";
2
2
  import { addType } from "./types.mjs";
3
3
  import { asArray } from "./utils.mjs";
4
4
  import { networkAddressProperties } from "./network-support.mjs";
5
- import { DNSRecord, dnsFullName } from "./dns-utils.mjs";
5
+ import { DNSRecord, dnsFullName, dnsFormatParameters } from "./dns-utils.mjs";
6
6
 
7
7
  const ServiceTypes = {
8
8
  dns: { protocol: "udp", port: 53, tls: false },
9
9
  ldap: { protocol: "tcp", port: 389, tls: false },
10
10
  ldaps: { protocol: "tcp", port: 636, tls: true },
11
11
  http: { protocol: "tcp", port: 80, tls: false },
12
- https: { protocol: "tcp", port: 443, tls: true },
12
+ https: {
13
+ protocol: "tcp",
14
+ port: 443,
15
+ tls: true,
16
+ dnsRecord: { type: "HTTPS", parameters: { alpn: "h2" } }
17
+ },
18
+ http3: {
19
+ protocol: "tcp",
20
+ port: 443,
21
+ tls: true,
22
+ dnsRecord: {
23
+ type: "HTTPS",
24
+ parameters: { "no-default-alpn": undefined, alpn: "h3" }
25
+ }
26
+ },
13
27
  rtsp: { protocol: "tcp", port: 554, tls: false },
14
28
  smtp: { protocol: "tcp", port: 25, tls: false },
15
29
  ssh: { protocol: "tcp", port: 22, tls: false },
@@ -197,10 +211,36 @@ export class Service extends Base {
197
211
  );
198
212
  }
199
213
 
214
+ const dnsRecord = ServiceTypes[this.type]?.dnsRecord;
215
+ if (dnsRecord) {
216
+ records.push(
217
+ DNSRecord(
218
+ dnsFullName(domainName),
219
+ dnsRecord.type,
220
+ this.priority,
221
+ ".",
222
+ dnsFormatParameters(dnsRecord.parameters)
223
+ )
224
+ );
225
+
226
+ if (this.master && this.alias) {
227
+ records.push(
228
+ DNSRecord(
229
+ this.alias,
230
+ dnsRecord.type,
231
+ this.priority,
232
+ dnsFullName(domainName),
233
+ dnsFormatParameters(dnsRecord.parameters)
234
+ )
235
+ );
236
+ }
237
+ }
238
+
200
239
  return records;
201
240
  }
202
241
  }
203
242
 
243
+
204
244
  export const sortByPriority = (a, b) => a.priority - b.priority;
205
245
 
206
246
  export function serviceAddresses(
@@ -3,3 +3,4 @@ export function DNSRecord(key: any, type: any, ...values: any[]): {
3
3
  key: any;
4
4
  toString: (maxKeyLength: any, ttl: any) => string;
5
5
  };
6
+ export function dnsFormatParameters(parameters: any): string;