pmcf 2.14.2 → 2.15.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 +1 -1
- package/src/host.mjs +28 -3
- package/src/service.mjs +5 -2
- package/src/services/dhcp.mjs +43 -20
- package/types/host.d.mts +2 -0
package/package.json
CHANGED
package/src/host.mjs
CHANGED
|
@@ -115,7 +115,6 @@ export class Host extends Base {
|
|
|
115
115
|
|
|
116
116
|
_applyExtends(host) {
|
|
117
117
|
for (const service of host.services) {
|
|
118
|
-
|
|
119
118
|
//present.extends.push(service);
|
|
120
119
|
|
|
121
120
|
this.services = service.forOwner(this);
|
|
@@ -402,6 +401,24 @@ export class Host extends Base {
|
|
|
402
401
|
);
|
|
403
402
|
}
|
|
404
403
|
|
|
404
|
+
*findNetworkInterfaces(filter) {
|
|
405
|
+
yield* objectFilter(
|
|
406
|
+
types.network_interface,
|
|
407
|
+
this._networkInterfaces.values(),
|
|
408
|
+
filter
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
findNetworkInterface(filter) {
|
|
413
|
+
for (const ni of objectFilter(
|
|
414
|
+
types.network_interface,
|
|
415
|
+
this._networkInterfaces.values(),
|
|
416
|
+
filter
|
|
417
|
+
)) {
|
|
418
|
+
return ni;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
405
422
|
get networkInterfaces() {
|
|
406
423
|
return this._networkInterfaces;
|
|
407
424
|
}
|
|
@@ -671,7 +688,11 @@ export class NetworkInterface extends Base {
|
|
|
671
688
|
}
|
|
672
689
|
|
|
673
690
|
get scope() {
|
|
674
|
-
return
|
|
691
|
+
return (
|
|
692
|
+
this.extendedProperty("_scope") ??
|
|
693
|
+
this.network?.scope ??
|
|
694
|
+
networkProperties.scope.default
|
|
695
|
+
);
|
|
675
696
|
}
|
|
676
697
|
|
|
677
698
|
set hwaddr(value) {
|
|
@@ -687,7 +708,11 @@ export class NetworkInterface extends Base {
|
|
|
687
708
|
}
|
|
688
709
|
|
|
689
710
|
get metric() {
|
|
690
|
-
return
|
|
711
|
+
return (
|
|
712
|
+
this.extendedProperty("_metric") ??
|
|
713
|
+
this.network?.metric ??
|
|
714
|
+
networkProperties.metric.default
|
|
715
|
+
);
|
|
691
716
|
}
|
|
692
717
|
|
|
693
718
|
set MTU(value) {
|
package/src/service.mjs
CHANGED
|
@@ -35,7 +35,7 @@ const ServiceTypes = {
|
|
|
35
35
|
ssh: { endpoints: [{ protocol: "tcp", port: 22, tls: false }] },
|
|
36
36
|
imap: { endpoints: [{ protocol: "tcp", port: 143, tls: false }] },
|
|
37
37
|
imaps: { endpoints: [{ protocol: "tcp", port: 993, tls: true }] },
|
|
38
|
-
dhcp: { endpoints: [{ port: 547, tls: false }] },
|
|
38
|
+
dhcp: { endpoints: [{ port: 547, protocol: "udp", tls: false }] },
|
|
39
39
|
"dhcpv6-client": {
|
|
40
40
|
endpoints: [
|
|
41
41
|
{ protocol: "tcp", port: 546, tls: false },
|
|
@@ -166,7 +166,10 @@ export class Service extends Base {
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
get endpoints() {
|
|
169
|
-
const local =
|
|
169
|
+
const local =
|
|
170
|
+
this._port === undefined
|
|
171
|
+
? { type: this.type }
|
|
172
|
+
: { type: this.type, port: this._port };
|
|
170
173
|
|
|
171
174
|
const data = ServiceTypes[this.type]?.endpoints || [
|
|
172
175
|
{
|
package/src/services/dhcp.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { FileContentProvider } from "npm-pkgbuild";
|
|
|
3
3
|
import {
|
|
4
4
|
Service,
|
|
5
5
|
ServiceTypeDefinition,
|
|
6
|
+
Endpoint,
|
|
6
7
|
serviceEndpoints
|
|
7
8
|
} from "../service.mjs";
|
|
8
9
|
import { addType } from "../types.mjs";
|
|
@@ -17,6 +18,20 @@ const DHCPServiceTypeDefinition = {
|
|
|
17
18
|
properties: {}
|
|
18
19
|
};
|
|
19
20
|
|
|
21
|
+
const controlAgentEndpoint = {
|
|
22
|
+
type: "kea-control-agent",
|
|
23
|
+
port: 8000,
|
|
24
|
+
protocol: "tcp",
|
|
25
|
+
tls: false
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const ddnsEndpoint = {
|
|
29
|
+
type: "kea-ddns",
|
|
30
|
+
port: 53001,
|
|
31
|
+
protocol: "tcp",
|
|
32
|
+
tls: false
|
|
33
|
+
};
|
|
34
|
+
|
|
20
35
|
export class DHCPService extends Service {
|
|
21
36
|
static {
|
|
22
37
|
addType(this);
|
|
@@ -35,6 +50,20 @@ export class DHCPService extends Service {
|
|
|
35
50
|
return DHCPServiceTypeDefinition.name;
|
|
36
51
|
}
|
|
37
52
|
|
|
53
|
+
get endpoints() {
|
|
54
|
+
const l0 = this.server.findNetworkInterface({ scope: "host" });
|
|
55
|
+
|
|
56
|
+
if (l0) {
|
|
57
|
+
return [
|
|
58
|
+
...super.endpoints,
|
|
59
|
+
new Endpoint(this, l0, controlAgentEndpoint),
|
|
60
|
+
new Endpoint(this, l0, ddnsEndpoint)
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return super.endpoints;
|
|
65
|
+
}
|
|
66
|
+
|
|
38
67
|
async *preparePackages(dir) {
|
|
39
68
|
const network = this.network;
|
|
40
69
|
const host = this.server;
|
|
@@ -182,20 +211,23 @@ export class DHCPService extends Service {
|
|
|
182
211
|
})
|
|
183
212
|
.sort((a, b) => a.hostname.localeCompare(b.hostname));
|
|
184
213
|
|
|
214
|
+
const listenInterfaces = filter =>
|
|
215
|
+
this.endpoints
|
|
216
|
+
.filter(
|
|
217
|
+
endpoint =>
|
|
218
|
+
endpoint.type === "dhcp" &&
|
|
219
|
+
filter(endpoint.rawAddress) &&
|
|
220
|
+
endpoint.networkInterface.kind !== "loopback"
|
|
221
|
+
)
|
|
222
|
+
.map(
|
|
223
|
+
endpoint => `${endpoint.networkInterface.name}/${endpoint.rawAddress}`
|
|
224
|
+
);
|
|
225
|
+
|
|
185
226
|
const dhcp4 = {
|
|
186
227
|
Dhcp4: {
|
|
187
228
|
...commonConfig,
|
|
188
229
|
"interfaces-config": {
|
|
189
|
-
interfaces:
|
|
190
|
-
.filter(
|
|
191
|
-
endpoint =>
|
|
192
|
-
isIPv4Address(endpoint.rawAddress) &&
|
|
193
|
-
endpoint.networkInterface.kind !== "loopback"
|
|
194
|
-
)
|
|
195
|
-
.map(
|
|
196
|
-
endpoint =>
|
|
197
|
-
`${endpoint.networkInterface.name}/${endpoint.rawAddress}`
|
|
198
|
-
)
|
|
230
|
+
interfaces: listenInterfaces(isIPv4Address)
|
|
199
231
|
},
|
|
200
232
|
"multi-threading": {
|
|
201
233
|
"enable-multi-threading": false
|
|
@@ -240,16 +272,7 @@ export class DHCPService extends Service {
|
|
|
240
272
|
Dhcp6: {
|
|
241
273
|
...commonConfig,
|
|
242
274
|
"interfaces-config": {
|
|
243
|
-
interfaces:
|
|
244
|
-
.filter(
|
|
245
|
-
endpoint =>
|
|
246
|
-
isIPv6Address(endpoint.rawAddress) &&
|
|
247
|
-
endpoint.networkInterface.kind !== "loopback"
|
|
248
|
-
)
|
|
249
|
-
.map(
|
|
250
|
-
endpoint =>
|
|
251
|
-
`${endpoint.networkInterface.name}/${endpoint.rawAddress}`
|
|
252
|
-
)
|
|
275
|
+
interfaces: listenInterfaces(isIPv6Address)
|
|
253
276
|
},
|
|
254
277
|
"control-socket": {
|
|
255
278
|
"socket-type": "unix",
|
package/types/host.d.mts
CHANGED
|
@@ -228,6 +228,8 @@ export class Host extends Base {
|
|
|
228
228
|
get host(): this;
|
|
229
229
|
named(name: any): any;
|
|
230
230
|
get networks(): Set<any>;
|
|
231
|
+
findNetworkInterfaces(filter: any): Generator<any, void, any>;
|
|
232
|
+
findNetworkInterface(filter: any): any;
|
|
231
233
|
set networkInterfaces(networkInterface: Map<any, any>);
|
|
232
234
|
get networkInterfaces(): Map<any, any>;
|
|
233
235
|
networkAddresses(): Generator<{
|