pmcf 6.42.0 → 6.43.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/services/kea.mjs +29 -33
- package/src/subnet.mjs +6 -11
package/package.json
CHANGED
package/src/services/kea.mjs
CHANGED
|
@@ -2,14 +2,15 @@ import { join } from "node:path";
|
|
|
2
2
|
import { FileContentProvider } from "npm-pkgbuild";
|
|
3
3
|
import {
|
|
4
4
|
reverseArpa,
|
|
5
|
-
isLinkLocal,
|
|
6
5
|
addressType,
|
|
7
6
|
FAMILY_IPV4,
|
|
8
7
|
FAMILY_IPV6,
|
|
9
8
|
ADDRESS_TYPE_LOOPBACK
|
|
10
9
|
} from "ip-utilties";
|
|
11
10
|
import {
|
|
11
|
+
name_attribute,
|
|
12
12
|
string_attribute_writable,
|
|
13
|
+
string_collection_attribute_writable,
|
|
13
14
|
number_attribute_writable,
|
|
14
15
|
boolean_attribute_writable_true,
|
|
15
16
|
default_collection_attribute_writable,
|
|
@@ -17,17 +18,36 @@ import {
|
|
|
17
18
|
} from "pacc";
|
|
18
19
|
import {
|
|
19
20
|
addType,
|
|
21
|
+
Subnet,
|
|
20
22
|
CoreService,
|
|
21
23
|
Endpoint,
|
|
22
24
|
sortDescendingByPriority,
|
|
23
|
-
SUBNET_LOCALHOST_IPV4,
|
|
24
|
-
SUBNET_LOCALHOST_IPV6,
|
|
25
25
|
FAMILY_UNIX
|
|
26
26
|
} from "pmcf";
|
|
27
27
|
import { writeLines } from "../utils.mjs";
|
|
28
28
|
|
|
29
|
+
class kea_subnet extends Subnet {
|
|
30
|
+
static attributes = {
|
|
31
|
+
pool: {
|
|
32
|
+
...string_collection_attribute_writable,
|
|
33
|
+
name: "pool"
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
static {
|
|
38
|
+
addType(this);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
pool = [];
|
|
42
|
+
}
|
|
43
|
+
|
|
29
44
|
export class kea extends CoreService {
|
|
30
45
|
static attributes = {
|
|
46
|
+
subnets: {
|
|
47
|
+
...default_collection_attribute_writable,
|
|
48
|
+
type: kea_subnet,
|
|
49
|
+
name: "subnets"
|
|
50
|
+
},
|
|
31
51
|
dnsServerEndpoints: {
|
|
32
52
|
...default_collection_attribute_writable,
|
|
33
53
|
type: Endpoint,
|
|
@@ -135,6 +155,8 @@ export class kea extends CoreService {
|
|
|
135
155
|
addType(this);
|
|
136
156
|
}
|
|
137
157
|
|
|
158
|
+
subnets = new Map();
|
|
159
|
+
|
|
138
160
|
async *preparePackages(dir) {
|
|
139
161
|
const ctrlAgentEndpoint = this.endpoint("kea-ha-4");
|
|
140
162
|
|
|
@@ -144,18 +166,9 @@ export class kea extends CoreService {
|
|
|
144
166
|
|
|
145
167
|
const network = this.network;
|
|
146
168
|
const host = this.host;
|
|
147
|
-
|
|
148
169
|
const source = host.owner;
|
|
149
170
|
const name = host.name;
|
|
150
|
-
|
|
151
|
-
const subnets = [...new Map(this.subnets).values()].filter(
|
|
152
|
-
s => s !== SUBNET_LOCALHOST_IPV4 && s !== SUBNET_LOCALHOST_IPV6
|
|
153
|
-
); // TODO should be normal
|
|
154
|
-
/*console.log(
|
|
155
|
-
"SUBNETS",
|
|
156
|
-
subnets.map(s => s.fullName)
|
|
157
|
-
);*/
|
|
158
|
-
|
|
171
|
+
const subnets = [...this.subnets.values()];
|
|
159
172
|
const dnsServerEndpoints = this.dnsServerEndpoints;
|
|
160
173
|
const packageData = await this.packageData;
|
|
161
174
|
|
|
@@ -399,29 +412,18 @@ export class kea extends CoreService {
|
|
|
399
412
|
endpoint.type === "dhcp" &&
|
|
400
413
|
endpoint.family === family &&
|
|
401
414
|
endpoint.networkInterface.kind !== "loopback" &&
|
|
402
|
-
endpoint.networkInterface.kind !== "wlan" &&
|
|
403
415
|
endpoint.networkInterface.kind !== "tun"
|
|
404
416
|
).map(
|
|
405
417
|
endpoint => `${endpoint.networkInterface.name}/${endpoint.address}`
|
|
406
418
|
);
|
|
407
419
|
|
|
408
|
-
const pools = subnet => {
|
|
409
|
-
return subnet.dhcpPools.map(pool => {
|
|
410
|
-
return { pool: Array.isArray(pool) ? pool.join(" - ") : pool };
|
|
411
|
-
});
|
|
412
|
-
};
|
|
420
|
+
const pools = subnet => [{ pool: subnet.pool.join(" - ") }];
|
|
413
421
|
|
|
414
422
|
const dhcp4 = {
|
|
415
423
|
Dhcp4: {
|
|
416
424
|
...(await commonConfig("4")),
|
|
417
425
|
subnet4: subnets
|
|
418
|
-
.filter(
|
|
419
|
-
s =>
|
|
420
|
-
s.family === FAMILY_IPV4 &&
|
|
421
|
-
// TODO keep out tailscale
|
|
422
|
-
s.cidr !== "100.64.0.2/32" &&
|
|
423
|
-
s.cidr !== "100.64.0.3/32"
|
|
424
|
-
)
|
|
426
|
+
.filter(s => s.family === FAMILY_IPV4)
|
|
425
427
|
.map((subnet, index) => {
|
|
426
428
|
return {
|
|
427
429
|
id: index + 1,
|
|
@@ -442,13 +444,7 @@ export class kea extends CoreService {
|
|
|
442
444
|
Dhcp6: {
|
|
443
445
|
...(await commonConfig("6")),
|
|
444
446
|
subnet6: subnets
|
|
445
|
-
.filter(
|
|
446
|
-
s =>
|
|
447
|
-
s.family === FAMILY_IPV6 &&
|
|
448
|
-
!isLinkLocal(s.address) &&
|
|
449
|
-
// TODO keep out tailscale
|
|
450
|
-
s.cidr !== "fd7a:115c:a1e0::/64"
|
|
451
|
-
)
|
|
447
|
+
.filter(s => s.family === FAMILY_IPV6)
|
|
452
448
|
.map((subnet, index) => {
|
|
453
449
|
return {
|
|
454
450
|
id: index + 1,
|
package/src/subnet.mjs
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
rangeIP,
|
|
4
4
|
decodeIP,
|
|
5
5
|
matchPrefixIP,
|
|
6
|
-
FAMILY_IPV6
|
|
7
6
|
} from "ip-utilties";
|
|
8
7
|
import { string_attribute, name_attribute, integer_attribute } from "pacc";
|
|
9
8
|
import { networks_attribute } from "./common-attributes.mjs";
|
|
@@ -30,6 +29,12 @@ export class Subnet extends core {
|
|
|
30
29
|
|
|
31
30
|
constructor(owner, address) {
|
|
32
31
|
super();
|
|
32
|
+
|
|
33
|
+
switch(typeof address) {
|
|
34
|
+
case "object":
|
|
35
|
+
address = address.address;
|
|
36
|
+
}
|
|
37
|
+
|
|
33
38
|
const { longPrefix, prefix, prefixLength, cidr, family } =
|
|
34
39
|
normalizeCIDR(address);
|
|
35
40
|
|
|
@@ -71,16 +76,6 @@ export class Subnet extends core {
|
|
|
71
76
|
return rangeIP(this.prefix, this.prefixLength, 1, 1).map(a => decodeIP(a));
|
|
72
77
|
}
|
|
73
78
|
|
|
74
|
-
get dhcpPools() {
|
|
75
|
-
/* TODO where to take values from ? */
|
|
76
|
-
|
|
77
|
-
return [
|
|
78
|
-
this.family === FAMILY_IPV6
|
|
79
|
-
? this.cidr
|
|
80
|
-
: rangeIP(this.prefix, this.prefixLength, 51, 20).map(a => decodeIP(a))
|
|
81
|
-
];
|
|
82
|
-
}
|
|
83
|
-
|
|
84
79
|
get longAddress() {
|
|
85
80
|
return `${this.longPrefix}/${this.prefixLength}`;
|
|
86
81
|
}
|