pmcf 1.66.1 → 1.67.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.66.1",
3
+ "version": "1.67.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/dns.mjs CHANGED
@@ -1,7 +1,12 @@
1
1
  import { join } from "node:path";
2
2
  import { createHmac } from "node:crypto";
3
3
  import { FileContentProvider } from "npm-pkgbuild";
4
- import { writeLines, isIPv6Address, normalizeIPAddress, isLinkLocal } from "./utils.mjs";
4
+ import {
5
+ writeLines,
6
+ isIPv6Address,
7
+ normalizeIPAddress,
8
+ isLinkLocal
9
+ } from "./utils.mjs";
5
10
  import { Base } from "./base.mjs";
6
11
  import { addType } from "./types.mjs";
7
12
 
@@ -12,7 +17,11 @@ const DNSServiceTypeDefinition = {
12
17
  properties: {
13
18
  hasSVRRecords: { type: "boolean", collection: false, writeable: true },
14
19
  hasCatalog: { type: "boolean", collection: false, writeable: true },
15
- hasLinkLocalAdresses: { type: "boolean", collection: false, writeable: true },
20
+ hasLinkLocalAdresses: {
21
+ type: "boolean",
22
+ collection: false,
23
+ writeable: true
24
+ },
16
25
  notify: { type: "boolean", collection: false, writeable: true },
17
26
  recordTTL: { type: "string", collection: false, writeable: true },
18
27
  refresh: { type: "string", collection: false, writeable: true },
@@ -107,19 +116,68 @@ export class DNSService extends Base {
107
116
  }
108
117
 
109
118
  async *preparePackages(stagingDir) {
110
- for await (const result of super.preparePackages(stagingDir)) {
111
- await generateNamedDefs(this, stagingDir);
119
+ const name = this.owner.name;
120
+ const p1 = join(stagingDir, "p1");
121
+
122
+ const result = {
123
+ sources: [new FileContentProvider(p1 + "/")[Symbol.asyncIterator]()],
124
+ outputs: this.outputs,
125
+ properties: {
126
+ name: `named-${name}`,
127
+ description: `named definitions for ${this.fullName}`,
128
+ access: "private"
129
+ }
130
+ };
131
+
132
+ const options = ["forwarders {"];
133
+ for (const s of this.forwardsTo) {
134
+ for (const dns of s.findServices(DNS_SERVICE_FILTER)) {
135
+ options.push(...(dns.rawAddresses.map(a=>a+";")));
136
+ }
137
+ }
138
+ options.push("}");
139
+ await writeLines(join(p1, "etc/named.d/options"), `${name}.conf`, options);
112
140
 
113
- result.properties.name = `named-${this.owner.name}`;
114
- result.properties.dependencies = ["mf-named"];
115
- result.properties.replaces = ["mf-named-zones"];
141
+ const category = [];
116
142
 
117
- result.sources.push(
118
- new FileContentProvider(stagingDir + "/")[Symbol.asyncIterator]()
119
- );
143
+ /*
144
+ const category = ["acl trusted {"];
145
+
146
+ const network = this.owner.named("LOCAL");
147
+ for (const subnet of network.subnets()) {
148
+ category.push(`${subnet.name};`);
149
+ }
150
+
151
+ category.push("}");
152
+ */
120
153
 
154
+ await writeLines(
155
+ join(p1, "etc/named.d/categories"),
156
+ `${name}.conf`,
157
+ category
158
+ );
159
+
160
+ if(options.length > 2 || category.length > 2) {
121
161
  yield result;
122
162
  }
163
+
164
+ const p2 = join(stagingDir, "p2");
165
+
166
+ result.properties = {
167
+ name: `named-zones-${name}`,
168
+ description: `zone definitions for ${this.fullName}`,
169
+ dependencies: ["mf-named"],
170
+ replaces: ["mf-named-zones", `named-${name}`],
171
+ access: "private"
172
+ };
173
+
174
+ result.sources = [
175
+ new FileContentProvider(p2 + "/")[Symbol.asyncIterator]()
176
+ ];
177
+
178
+ await generateZoneDefs(this, p2);
179
+
180
+ yield result;
123
181
  }
124
182
  }
125
183
 
@@ -127,7 +185,7 @@ function fullName(name) {
127
185
  return name.endsWith(".") ? name : name + ".";
128
186
  }
129
187
 
130
- async function generateNamedDefs(dns, targetDir) {
188
+ async function generateZoneDefs(dns, targetDir) {
131
189
  const ttl = dns.recordTTL;
132
190
  const updates = [Math.ceil(Date.now() / 1000), ...dns.soaUpdates].join(" ");
133
191
 
@@ -212,7 +270,10 @@ async function generateNamedDefs(dns, targetDir) {
212
270
  } of dns.owner.networkAddresses()) {
213
271
  const host = networkInterface.host;
214
272
 
215
- if (!addresses.has(address) && (dns.hasLinkLocalAdresses || !isLinkLocal(address))) {
273
+ if (
274
+ !addresses.has(address) &&
275
+ (dns.hasLinkLocalAdresses || !isLinkLocal(address))
276
+ ) {
216
277
  addresses.add(address);
217
278
 
218
279
  zone.records.add(
@@ -278,7 +339,11 @@ async function generateNamedDefs(dns, targetDir) {
278
339
  if (zone.type !== "catalog") {
279
340
  const hash = createHmac("md5", zone.id).digest("hex");
280
341
  catalogZone.records.add(
281
- createRecord(`${hash}.zones.catalog.${domain}.`, "PTR", fullName(zone.id))
342
+ createRecord(
343
+ `${hash}.zones.catalog.${domain}.`,
344
+ "PTR",
345
+ fullName(zone.id)
346
+ )
282
347
  );
283
348
  }
284
349
 
package/src/service.mjs CHANGED
@@ -16,7 +16,7 @@ const ServiceTypes = {
16
16
 
17
17
  const ServiceTypeDefinition = {
18
18
  name: "service",
19
- owners: ["host"],
19
+ owners: ["host", "cluster"],
20
20
  priority: 0.4,
21
21
  extends: Base.typeDefinition,
22
22
  properties: {
package/types/dns.d.mts CHANGED
@@ -85,6 +85,15 @@ export class DNSService extends Base {
85
85
  MulticastDNS: string;
86
86
  LLMNR: string;
87
87
  }>;
88
+ preparePackages(stagingDir: any): AsyncGenerator<{
89
+ sources: AsyncGenerator<any, void, unknown>[];
90
+ outputs: Set<typeof import("npm-pkgbuild").ARCH | typeof import("npm-pkgbuild").DOCKER>;
91
+ properties: {
92
+ name: string;
93
+ description: string;
94
+ access: string;
95
+ };
96
+ }, void, unknown>;
88
97
  #private;
89
98
  }
90
99
  import { Base } from "./base.mjs";