pmcf 2.49.0 → 2.50.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "2.49.0",
3
+ "version": "2.50.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.17",
54
+ "@types/node": "^22.15.18",
55
55
  "ava": "^6.3.0",
56
56
  "c8": "^10.1.3",
57
57
  "documentation": "^14.0.3",
@@ -59,7 +59,7 @@
59
59
  "typescript": "^5.8.3"
60
60
  },
61
61
  "engines": {
62
- "node": ">=22.15.0"
62
+ "node": ">=22.15.1"
63
63
  },
64
64
  "repository": {
65
65
  "type": "git",
package/src/endpoint.mjs CHANGED
@@ -1,17 +1,16 @@
1
1
  class BaseEndpoint {
2
- #type;
2
+ _type;
3
3
 
4
4
  constructor(service, data) {
5
5
  this.service = service;
6
6
 
7
7
  if (data.type !== undefined) {
8
- this.#type = data.type;
9
- delete data.type;
8
+ this._type = data.type;
10
9
  }
11
10
  }
12
11
 
13
12
  get type() {
14
- return this.#type ?? this.service.type;
13
+ return this._type ?? this.service.type;
15
14
  }
16
15
 
17
16
  toString() {
@@ -20,24 +19,27 @@ class BaseEndpoint {
20
19
  }
21
20
 
22
21
  class PortEndpoint extends BaseEndpoint {
23
- #port;
22
+ _port;
24
23
  constructor(service, data) {
25
24
  super(service, data);
26
25
 
27
26
  if (data.port !== undefined) {
28
- this.#port = data.port;
29
- delete data.port;
27
+ this._port = data.port;
28
+ }
29
+ if (data.protocol !== undefined) {
30
+ this.protocol = data.protocol;
31
+ }
32
+ if (data.tls !== undefined) {
33
+ this.tls = data.tls;
30
34
  }
31
-
32
- Object.assign(this, data);
33
35
  }
34
36
 
35
37
  get port() {
36
- return this.#port ?? this.service.port;
38
+ return this._port ?? this.service.port;
37
39
  }
38
40
 
39
41
  toString() {
40
- return `${this.type}/${this.address}[${this.port}]`;
42
+ return `${this.type}:${this.family}/${this.address}[${this.port}]`;
41
43
  }
42
44
  }
43
45
 
@@ -96,6 +98,10 @@ export class HTTPEndpoint extends PortEndpoint {
96
98
  get address() {
97
99
  return this.url;
98
100
  }
101
+
102
+ toString() {
103
+ return `${this.type}:${this.url}`;
104
+ }
99
105
  }
100
106
 
101
107
  export class UnixEndpoint extends BaseEndpoint {
@@ -108,7 +114,15 @@ export class UnixEndpoint extends BaseEndpoint {
108
114
  return "unix";
109
115
  }
110
116
 
117
+ get host() {
118
+ return this.service.host;
119
+ }
120
+
111
121
  get address() {
112
122
  return this.path;
113
123
  }
124
+
125
+ toString() {
126
+ return `${this.type}:${this.family}:${this.path}`;
127
+ }
114
128
  }
@@ -4,6 +4,7 @@ import {
4
4
  Service,
5
5
  ServiceTypeDefinition,
6
6
  Endpoint,
7
+ UnixEndpoint,
7
8
  serviceEndpoints,
8
9
  SUBNET_LOCALHOST_IPV4,
9
10
  SUBNET_LOCALHOST_IPV6
@@ -34,6 +35,24 @@ const ddnsEndpoint = {
34
35
  tls: false
35
36
  };
36
37
 
38
+ const control4Endpoint = {
39
+ type: "kea-control-dhcp4",
40
+ family: "unix",
41
+ path: "/run/kea/4-ctrl-socket"
42
+ };
43
+
44
+ const control6Endpoint = {
45
+ type: "kea-control-dhcp6",
46
+ family: "unix",
47
+ path: "/run/kea/6-ctrl-socket"
48
+ };
49
+
50
+ const controlDDNSEndpoint = {
51
+ type: "kea-control-ddns",
52
+ family: "unix",
53
+ path: "/run/kea/ddns-ctrl-socket"
54
+ };
55
+
37
56
  export class DHCPService extends Service {
38
57
  static {
39
58
  addType(this);
@@ -62,6 +81,12 @@ export class DHCPService extends Service {
62
81
  endpoints.push(new Endpoint(this, na, ddnsEndpoint));
63
82
  }
64
83
 
84
+ endpoints.push(
85
+ new UnixEndpoint(this, control4Endpoint.path, control4Endpoint),
86
+ new UnixEndpoint(this, control6Endpoint.path, control6Endpoint),
87
+ new UnixEndpoint(this, controlDDNSEndpoint.path, controlDDNSEndpoint)
88
+ );
89
+
65
90
  return filter ? endpoints.filter(filter) : endpoints;
66
91
  }
67
92
 
@@ -70,7 +95,7 @@ export class DHCPService extends Service {
70
95
  const host = this.host;
71
96
  const name = host.name;
72
97
 
73
- console.log("kea", host.name, network.name);
98
+ console.log("kea", name, network.name);
74
99
 
75
100
  const dnsServerEndpoints = serviceEndpoints(network, {
76
101
  services: {
@@ -85,7 +110,7 @@ export class DHCPService extends Service {
85
110
  sources: [new FileContentProvider(dir + "/")],
86
111
  outputs: this.outputs,
87
112
  properties: {
88
- name: `kea-${this.location.name}-${host.name}`,
113
+ name: `kea-${this.location.name}-${name}`,
89
114
  description: `kea definitions for ${this.fullName}@${name}`,
90
115
  access: "private",
91
116
  dependencies: ["kea>=2.6.2"]
@@ -125,23 +150,21 @@ export class DHCPService extends Service {
125
150
  }
126
151
  ];
127
152
 
153
+ const toUnix = endpoint => {
154
+ return {
155
+ "socket-type": "unix",
156
+ "socket-name": endpoint?.path
157
+ };
158
+ };
159
+
128
160
  const ctrlAgent = {
129
161
  "Control-agent": {
130
162
  "http-host": "127.0.0.1",
131
163
  "http-port": 8000,
132
164
  "control-sockets": {
133
- dhcp4: {
134
- "socket-type": "unix",
135
- "socket-name": "/run/kea/4-ctrl-socket"
136
- },
137
- dhcp6: {
138
- "socket-type": "unix",
139
- "socket-name": "/run/kea/6-ctrl-socket"
140
- },
141
- d2: {
142
- "socket-type": "unix",
143
- "socket-name": "/run/kea/ddns-ctrl-socket"
144
- }
165
+ dhcp4: toUnix(this.endpoint(e => e.type === "kea-control-dhcp4")),
166
+ dhcp6: toUnix(this.endpoint(e => e.type === "kea-control-dhcp6")),
167
+ d2: toUnix(this.endpoint(e => e.type === "kea-control-ddns"))
145
168
  },
146
169
  loggers
147
170
  }
@@ -163,10 +186,9 @@ export class DHCPService extends Service {
163
186
  DhcpDdns: {
164
187
  "ip-address": "127.0.0.1",
165
188
  port: 53001,
166
- "control-socket": {
167
- "socket-type": "unix",
168
- "socket-name": "/run/kea/ddns-ctrl-socket"
169
- },
189
+ "control-socket": toUnix(
190
+ this.endpoint(e => e.type === "kea-control-ddns")
191
+ ),
170
192
  "tsig-keys": [],
171
193
  "forward-ddns": {
172
194
  "ddns-domains": dnsServersSlot([...this.domains])
@@ -223,7 +245,9 @@ export class DHCPService extends Service {
223
245
  endpoint => `${endpoint.networkInterface.name}/${endpoint.address}`
224
246
  );
225
247
 
226
- const subnets = [...this.subnets].filter(s => s !== SUBNET_LOCALHOST_IPV4 && s !== SUBNET_LOCALHOST_IPV6/* s.address !== "127/8"*/); // TODO no localhost
248
+ const subnets = [...this.subnets].filter(
249
+ s => s !== SUBNET_LOCALHOST_IPV4 && s !== SUBNET_LOCALHOST_IPV6
250
+ ); // TODO no localhost
227
251
  const dhcp4 = {
228
252
  Dhcp4: {
229
253
  ...commonConfig,
@@ -253,7 +277,7 @@ export class DHCPService extends Service {
253
277
  return {
254
278
  id: index + 1,
255
279
  subnet: subnet.longAddress,
256
- pools: [{ pool: subnet.addressRange.join(" - ") }],
280
+ pools: [{ pool: subnet.dhcpUsableAddressRange.join(" - ") }],
257
281
  "option-data": [
258
282
  {
259
283
  name: "routers",
package/src/subnet.mjs CHANGED
@@ -64,6 +64,12 @@ export class Subnet extends Base {
64
64
  return rangeIP(this.prefix, this.prefixLength, 1, 1).map(a => decodeIP(a));
65
65
  }
66
66
 
67
+ get dhcpUsableAddressRange()
68
+ {
69
+ /* TODO where to take values from ? */
70
+ return rangeIP(this.prefix, this.prefixLength, 51, 6).map(a => decodeIP(a));
71
+ }
72
+
67
73
  get address() {
68
74
  return this.name;
69
75
  }
@@ -23,17 +23,20 @@ export class UnixEndpoint extends BaseEndpoint {
23
23
  constructor(service: any, path: any, data: any);
24
24
  path: any;
25
25
  get family(): string;
26
+ get host(): any;
26
27
  get address(): any;
27
28
  }
28
29
  declare class PortEndpoint extends BaseEndpoint {
30
+ _port: any;
31
+ protocol: any;
32
+ tls: any;
29
33
  get port(): any;
30
- #private;
31
34
  }
32
35
  declare class BaseEndpoint {
33
36
  constructor(service: any, data: any);
37
+ _type: any;
34
38
  service: any;
35
39
  get type(): any;
36
40
  toString(): string;
37
- #private;
38
41
  }
39
42
  export {};
@@ -33,6 +33,7 @@ export class Subnet extends Base {
33
33
  matchesAddress(address: any): any;
34
34
  get isLinkLocal(): any;
35
35
  get addressRange(): any;
36
+ get dhcpUsableAddressRange(): any;
36
37
  get address(): string;
37
38
  get longAddress(): string;
38
39
  _traverse(...args: any[]): boolean;