pmcf 2.51.8 → 2.52.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 +2 -2
- package/src/service.mjs +1 -0
- package/src/services/dhcp.mjs +40 -17
- package/types/service.d.mts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmcf",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.52.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"pkg-dir": "^8.0.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@types/node": "^22.15.
|
|
54
|
+
"@types/node": "^22.15.20",
|
|
55
55
|
"ava": "^6.3.0",
|
|
56
56
|
"c8": "^10.1.3",
|
|
57
57
|
"documentation": "^14.0.3",
|
package/src/service.mjs
CHANGED
package/src/services/dhcp.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { join } from "node:path";
|
|
|
2
2
|
import { FileContentProvider } from "npm-pkgbuild";
|
|
3
3
|
import {
|
|
4
4
|
Service,
|
|
5
|
+
sortInverseByPriority,
|
|
5
6
|
ServiceTypeDefinition,
|
|
6
7
|
Endpoint,
|
|
7
8
|
UnixEndpoint,
|
|
@@ -22,18 +23,33 @@ const DHCPServiceTypeDefinition = {
|
|
|
22
23
|
properties: {}
|
|
23
24
|
};
|
|
24
25
|
|
|
26
|
+
const ddnsEndpoint = {
|
|
27
|
+
type: "kea-ddns",
|
|
28
|
+
port: 53001,
|
|
29
|
+
protocol: "tcp",
|
|
30
|
+
tls: false
|
|
31
|
+
};
|
|
32
|
+
|
|
25
33
|
const controlAgentEndpoint = {
|
|
26
34
|
type: "kea-control-agent",
|
|
27
35
|
port: 53002,
|
|
28
36
|
pathname: "/",
|
|
29
|
-
method: "get",
|
|
30
37
|
protocol: "tcp",
|
|
31
38
|
tls: false
|
|
32
39
|
};
|
|
33
40
|
|
|
34
|
-
const
|
|
35
|
-
type: "kea-
|
|
36
|
-
port:
|
|
41
|
+
const ha4Endpoint = {
|
|
42
|
+
type: "kea-ha-4",
|
|
43
|
+
port: 53003,
|
|
44
|
+
pathname: "/",
|
|
45
|
+
protocol: "tcp",
|
|
46
|
+
tls: false
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const ha6Endpoint = {
|
|
50
|
+
type: "kea-ha-6",
|
|
51
|
+
port: 53004,
|
|
52
|
+
pathname: "/",
|
|
37
53
|
protocol: "tcp",
|
|
38
54
|
tls: false
|
|
39
55
|
};
|
|
@@ -79,6 +95,7 @@ export class DHCPService extends Service {
|
|
|
79
95
|
|
|
80
96
|
for (const na of this.host.networkAddresses()) {
|
|
81
97
|
endpoints.push(new HTTPEndpoint(this, na, controlAgentEndpoint));
|
|
98
|
+
endpoints.push(new HTTPEndpoint(this, na, na.family === 'IPv4' ? ha4Endpoint : ha6Endpoint));
|
|
82
99
|
|
|
83
100
|
if (na.networkInterface.kind === "loopback") {
|
|
84
101
|
endpoints.push(new Endpoint(this, na, ddnsEndpoint));
|
|
@@ -125,26 +142,25 @@ export class DHCPService extends Service {
|
|
|
125
142
|
e => e.type === "kea-control-agent"
|
|
126
143
|
);
|
|
127
144
|
|
|
128
|
-
const peers = (
|
|
145
|
+
const peers = async (family) => (
|
|
129
146
|
await Array.fromAsync(
|
|
130
|
-
network.findServices({ type: "dhcp", priority: "
|
|
147
|
+
network.findServices({ type: "dhcp", priority: "<20" })
|
|
131
148
|
)
|
|
132
149
|
)
|
|
133
|
-
.sort(
|
|
150
|
+
.sort(sortInverseByPriority)
|
|
134
151
|
.map((dhcp, i) => {
|
|
135
152
|
const ctrlAgentEndpoint = dhcp.endpoint(
|
|
136
|
-
e => e.type ===
|
|
153
|
+
e => e.type === `kea-ha-${family}`
|
|
137
154
|
);
|
|
138
155
|
|
|
139
156
|
return {
|
|
140
157
|
name: dhcp.host.name,
|
|
141
|
-
role: i === 0 ? "primary" : "standby",
|
|
142
|
-
url: ctrlAgentEndpoint
|
|
158
|
+
role: i === 0 ? "primary" : i > 1 ? "backup" : "standby",
|
|
159
|
+
url: ctrlAgentEndpoint.url,
|
|
160
|
+
"auto-failover": i <= 1
|
|
143
161
|
};
|
|
144
162
|
});
|
|
145
163
|
|
|
146
|
-
peers.length = 2;
|
|
147
|
-
|
|
148
164
|
const loggers = [
|
|
149
165
|
{
|
|
150
166
|
"output-options": [
|
|
@@ -157,7 +173,7 @@ export class DHCPService extends Service {
|
|
|
157
173
|
}
|
|
158
174
|
];
|
|
159
175
|
|
|
160
|
-
const commonConfig = family => {
|
|
176
|
+
const commonConfig = async (family) => {
|
|
161
177
|
return {
|
|
162
178
|
"interfaces-config": {
|
|
163
179
|
interfaces: listenInterfaces(`IPv${family}`)
|
|
@@ -194,7 +210,13 @@ export class DHCPService extends Service {
|
|
|
194
210
|
{
|
|
195
211
|
"this-server-name": name,
|
|
196
212
|
mode: "hot-standby",
|
|
197
|
-
|
|
213
|
+
"multi-threading": {
|
|
214
|
+
"enable-multi-threading": true,
|
|
215
|
+
"http-dedicated-listener": true,
|
|
216
|
+
"http-listener-threads": 2,
|
|
217
|
+
"http-client-threads": 2
|
|
218
|
+
},
|
|
219
|
+
peers: await peers(family)
|
|
198
220
|
}
|
|
199
221
|
]
|
|
200
222
|
}
|
|
@@ -310,7 +332,8 @@ export class DHCPService extends Service {
|
|
|
310
332
|
endpoint =>
|
|
311
333
|
endpoint.type === "dhcp" &&
|
|
312
334
|
endpoint.family === family &&
|
|
313
|
-
endpoint.networkInterface.kind !== "loopback"
|
|
335
|
+
endpoint.networkInterface.kind !== "loopback" &&
|
|
336
|
+
endpoint.networkInterface.kind !== "wlan"
|
|
314
337
|
).map(
|
|
315
338
|
endpoint => `${endpoint.networkInterface.name}/${endpoint.address}`
|
|
316
339
|
);
|
|
@@ -320,7 +343,7 @@ export class DHCPService extends Service {
|
|
|
320
343
|
);
|
|
321
344
|
const dhcp4 = {
|
|
322
345
|
Dhcp4: {
|
|
323
|
-
...commonConfig("4"),
|
|
346
|
+
...(await commonConfig("4")),
|
|
324
347
|
subnet4: subnets
|
|
325
348
|
.filter(s => s.family === "IPv4")
|
|
326
349
|
.map((subnet, index) => {
|
|
@@ -343,7 +366,7 @@ export class DHCPService extends Service {
|
|
|
343
366
|
};
|
|
344
367
|
const dhcp6 = {
|
|
345
368
|
Dhcp6: {
|
|
346
|
-
...commonConfig("6"),
|
|
369
|
+
...(await commonConfig("6")),
|
|
347
370
|
subnet6: subnets
|
|
348
371
|
.filter(s => s.family === "IPv6")
|
|
349
372
|
.map((subnet, index) => {
|
package/types/service.d.mts
CHANGED