pmcf 2.51.7 → 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 +54 -33
- 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}`)
|
|
@@ -183,21 +199,6 @@ export class DHCPService extends Service {
|
|
|
183
199
|
"renew-timer": 900,
|
|
184
200
|
"rebind-timer": 1800,
|
|
185
201
|
"valid-lifetime": 3600,
|
|
186
|
-
"preferred-lifetime": 3000,
|
|
187
|
-
|
|
188
|
-
"option-data": [
|
|
189
|
-
{
|
|
190
|
-
name: "dns-servers",
|
|
191
|
-
data: dnsServerEndpoints
|
|
192
|
-
.filter(endpoint => endpoint.family === `IPv${family}`)
|
|
193
|
-
.map(endpoint => endpoint.address)
|
|
194
|
-
.join(",")
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
name: "domain-search",
|
|
198
|
-
data: [...this.domains].join(",")
|
|
199
|
-
}
|
|
200
|
-
],
|
|
201
202
|
"hooks-libraries": [
|
|
202
203
|
{
|
|
203
204
|
library: "/usr/lib/kea/hooks/libdhcp_lease_cmds.so"
|
|
@@ -209,14 +210,33 @@ export class DHCPService extends Service {
|
|
|
209
210
|
{
|
|
210
211
|
"this-server-name": name,
|
|
211
212
|
mode: "hot-standby",
|
|
212
|
-
|
|
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)
|
|
213
220
|
}
|
|
214
221
|
]
|
|
215
222
|
}
|
|
216
223
|
}
|
|
217
224
|
],
|
|
218
225
|
"dhcp-ddns": dhcpServerDdns,
|
|
219
|
-
loggers
|
|
226
|
+
loggers,
|
|
227
|
+
"option-data": [
|
|
228
|
+
{
|
|
229
|
+
name: "domain-name-servers",
|
|
230
|
+
data: dnsServerEndpoints
|
|
231
|
+
.filter(endpoint => endpoint.family === `IPv${family}`)
|
|
232
|
+
.map(endpoint => endpoint.address)
|
|
233
|
+
.join(",")
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
name: "domain-search",
|
|
237
|
+
data: [...this.domains].join(",")
|
|
238
|
+
}
|
|
239
|
+
]
|
|
220
240
|
};
|
|
221
241
|
};
|
|
222
242
|
|
|
@@ -312,7 +332,8 @@ export class DHCPService extends Service {
|
|
|
312
332
|
endpoint =>
|
|
313
333
|
endpoint.type === "dhcp" &&
|
|
314
334
|
endpoint.family === family &&
|
|
315
|
-
endpoint.networkInterface.kind !== "loopback"
|
|
335
|
+
endpoint.networkInterface.kind !== "loopback" &&
|
|
336
|
+
endpoint.networkInterface.kind !== "wlan"
|
|
316
337
|
).map(
|
|
317
338
|
endpoint => `${endpoint.networkInterface.name}/${endpoint.address}`
|
|
318
339
|
);
|
|
@@ -322,7 +343,7 @@ export class DHCPService extends Service {
|
|
|
322
343
|
);
|
|
323
344
|
const dhcp4 = {
|
|
324
345
|
Dhcp4: {
|
|
325
|
-
...commonConfig("4"),
|
|
346
|
+
...(await commonConfig("4")),
|
|
326
347
|
subnet4: subnets
|
|
327
348
|
.filter(s => s.family === "IPv4")
|
|
328
349
|
.map((subnet, index) => {
|
|
@@ -345,7 +366,7 @@ export class DHCPService extends Service {
|
|
|
345
366
|
};
|
|
346
367
|
const dhcp6 = {
|
|
347
368
|
Dhcp6: {
|
|
348
|
-
...commonConfig("6"),
|
|
369
|
+
...(await commonConfig("6")),
|
|
349
370
|
subnet6: subnets
|
|
350
371
|
.filter(s => s.family === "IPv6")
|
|
351
372
|
.map((subnet, index) => {
|
package/types/service.d.mts
CHANGED