pmcf 2.12.1 → 2.13.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 +1 -1
- package/src/service.mjs +21 -6
- package/src/services/dhcp.mjs +7 -5
- package/src/services/ntp.mjs +12 -3
- package/types/service.d.mts +5 -0
package/package.json
CHANGED
package/src/service.mjs
CHANGED
|
@@ -168,17 +168,16 @@ export class Service extends Base {
|
|
|
168
168
|
get endpoints() {
|
|
169
169
|
if (!ServiceTypes[this.type]) {
|
|
170
170
|
return [
|
|
171
|
-
{
|
|
172
|
-
|
|
173
|
-
address: this.rawAddress,
|
|
171
|
+
new Endpoint(this, {
|
|
172
|
+
rawAddress: this.rawAddress,
|
|
174
173
|
port: this._port,
|
|
175
174
|
tls: false
|
|
176
|
-
}
|
|
175
|
+
})
|
|
177
176
|
];
|
|
178
177
|
}
|
|
179
178
|
|
|
180
|
-
return ServiceTypes[this.type].endpoints.map(
|
|
181
|
-
|
|
179
|
+
return ServiceTypes[this.type].endpoints.map(
|
|
180
|
+
e => new Endpoint(this, { rawAddress: this.rawAddress, ...e })
|
|
182
181
|
);
|
|
183
182
|
}
|
|
184
183
|
|
|
@@ -286,6 +285,13 @@ export class Service extends Base {
|
|
|
286
285
|
}
|
|
287
286
|
}
|
|
288
287
|
|
|
288
|
+
export class Endpoint {
|
|
289
|
+
constructor(service, data) {
|
|
290
|
+
this.service = service;
|
|
291
|
+
Object.assign(this, data);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
289
295
|
export const sortByPriority = (a, b) => a.priority - b.priority;
|
|
290
296
|
|
|
291
297
|
export function serviceAddresses(
|
|
@@ -302,3 +308,12 @@ export function serviceAddresses(
|
|
|
302
308
|
.flat()
|
|
303
309
|
.filter(addressFilter);
|
|
304
310
|
}
|
|
311
|
+
|
|
312
|
+
export function serviceEndpoints(sources, filter) {
|
|
313
|
+
return asArray(sources)
|
|
314
|
+
.map(ft => Array.from(ft.findServices(filter)))
|
|
315
|
+
.flat()
|
|
316
|
+
.sort(sortByPriority)
|
|
317
|
+
.map(service => service.endpoints)
|
|
318
|
+
.flat();
|
|
319
|
+
}
|
package/src/services/dhcp.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { FileContentProvider } from "npm-pkgbuild";
|
|
|
3
3
|
import {
|
|
4
4
|
Service,
|
|
5
5
|
ServiceTypeDefinition,
|
|
6
|
-
|
|
6
|
+
serviceEndpoints
|
|
7
7
|
} from "../service.mjs";
|
|
8
8
|
import { addType } from "../types.mjs";
|
|
9
9
|
import { writeLines } from "../utils.mjs";
|
|
@@ -42,7 +42,7 @@ export class DHCPService extends Service {
|
|
|
42
42
|
|
|
43
43
|
console.log("kea", host.name, network.name);
|
|
44
44
|
|
|
45
|
-
const
|
|
45
|
+
const dnsServerEndpoints = serviceEndpoints(network, {
|
|
46
46
|
type: "dns",
|
|
47
47
|
priority: "<10"
|
|
48
48
|
});
|
|
@@ -115,8 +115,8 @@ export class DHCPService extends Service {
|
|
|
115
115
|
domains.map(domain => {
|
|
116
116
|
return {
|
|
117
117
|
name: domain,
|
|
118
|
-
"dns-servers":
|
|
119
|
-
return { "ip-address":
|
|
118
|
+
"dns-servers": dnsServerEndpoints.map(endpoint => {
|
|
119
|
+
return { "ip-address": endpoint.rawAddress };
|
|
120
120
|
})
|
|
121
121
|
};
|
|
122
122
|
});
|
|
@@ -200,7 +200,9 @@ export class DHCPService extends Service {
|
|
|
200
200
|
"option-data": [
|
|
201
201
|
{
|
|
202
202
|
name: "domain-name-servers",
|
|
203
|
-
data:
|
|
203
|
+
data: dnsServerEndpoints
|
|
204
|
+
.map(endpoint => endpoint.rawAddress)
|
|
205
|
+
.join(",")
|
|
204
206
|
},
|
|
205
207
|
{
|
|
206
208
|
name: "domain-search",
|
package/src/services/ntp.mjs
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { FileContentProvider } from "npm-pkgbuild";
|
|
3
3
|
import { addType } from "../types.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
ServiceTypeDefinition,
|
|
6
|
+
serviceAddresses,
|
|
7
|
+
serviceEndpoints
|
|
8
|
+
} from "../service.mjs";
|
|
5
9
|
import {
|
|
6
10
|
ExtraSourceService,
|
|
7
11
|
ExtraSourceServiceTypeDefinition
|
|
@@ -81,10 +85,15 @@ export class NTPService extends ExtraSourceService {
|
|
|
81
85
|
};
|
|
82
86
|
|
|
83
87
|
const lines = [
|
|
84
|
-
...
|
|
88
|
+
...serviceEndpoints(this, {
|
|
85
89
|
...NTP_SERVICE_FILTER,
|
|
86
90
|
priority: ">=10"
|
|
87
|
-
}).map(
|
|
91
|
+
}).map(
|
|
92
|
+
endpoint =>
|
|
93
|
+
`${endpoint.service.isPool ? "pool" : "server"} ${
|
|
94
|
+
endpoint.rawAddress
|
|
95
|
+
} iburst`
|
|
96
|
+
),
|
|
88
97
|
`mailonchange ${this.administratorEmail} 0.5`,
|
|
89
98
|
"local stratum 10",
|
|
90
99
|
"leapsectz right/UTC",
|
package/types/service.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export function serviceAddresses(sources: any, filter: any, addressType?: string, addressFilter?: (a: any) => boolean): any[];
|
|
2
|
+
export function serviceEndpoints(sources: any, filter: any): any[];
|
|
2
3
|
export namespace ServiceTypeDefinition {
|
|
3
4
|
export let name: string;
|
|
4
5
|
export let owners: string[];
|
|
@@ -283,5 +284,9 @@ export class Service extends Base {
|
|
|
283
284
|
toString: (maxKeyLength?: number, ttl?: string) => string;
|
|
284
285
|
}[];
|
|
285
286
|
}
|
|
287
|
+
export class Endpoint {
|
|
288
|
+
constructor(service: any, data: any);
|
|
289
|
+
service: any;
|
|
290
|
+
}
|
|
286
291
|
export function sortByPriority(a: any, b: any): number;
|
|
287
292
|
import { Base } from "./base.mjs";
|