pmcf 2.48.8 → 2.49.1
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/endpoint.mjs +58 -16
- package/src/service.mjs +4 -0
- package/src/services/dhcp.mjs +48 -19
- package/types/endpoint.d.mts +18 -6
- 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.49.1",
|
|
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.18",
|
|
55
55
|
"ava": "^6.3.0",
|
|
56
56
|
"c8": "^10.1.3",
|
|
57
57
|
"documentation": "^14.0.3",
|
package/src/endpoint.mjs
CHANGED
|
@@ -1,34 +1,49 @@
|
|
|
1
|
-
class
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
class BaseEndpoint {
|
|
2
|
+
_type;
|
|
3
|
+
|
|
4
4
|
constructor(service, data) {
|
|
5
5
|
this.service = service;
|
|
6
|
-
if (data.port !== undefined) {
|
|
7
|
-
this.#port = data.port;
|
|
8
|
-
delete data.port;
|
|
9
|
-
}
|
|
10
6
|
|
|
11
7
|
if (data.type !== undefined) {
|
|
12
|
-
this
|
|
13
|
-
delete data.type;
|
|
8
|
+
this._type = data.type;
|
|
14
9
|
}
|
|
15
|
-
Object.assign(this, data);
|
|
16
10
|
}
|
|
17
11
|
|
|
18
12
|
get type() {
|
|
19
|
-
return this
|
|
13
|
+
return this._type ?? this.service.type;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
toString() {
|
|
17
|
+
return `${this.type}`;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
class PortEndpoint extends BaseEndpoint {
|
|
22
|
+
_port;
|
|
23
|
+
constructor(service, data) {
|
|
24
|
+
super(service, data);
|
|
25
|
+
|
|
26
|
+
if (data.port !== undefined) {
|
|
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;
|
|
34
|
+
}
|
|
20
35
|
}
|
|
21
36
|
|
|
22
37
|
get port() {
|
|
23
|
-
return this
|
|
38
|
+
return this._port ?? this.service.port;
|
|
24
39
|
}
|
|
25
40
|
|
|
26
41
|
toString() {
|
|
27
|
-
return `${this.type}/${this.address}[${this.port}]`;
|
|
42
|
+
return `${this.type}:${this.family}/${this.address}[${this.port}]`;
|
|
28
43
|
}
|
|
29
44
|
}
|
|
30
45
|
|
|
31
|
-
export class Endpoint extends
|
|
46
|
+
export class Endpoint extends PortEndpoint {
|
|
32
47
|
constructor(service, networkAddress, data) {
|
|
33
48
|
super(service, data);
|
|
34
49
|
this.networkAddress = networkAddress;
|
|
@@ -59,7 +74,7 @@ export class Endpoint extends _Endpoint {
|
|
|
59
74
|
}
|
|
60
75
|
}
|
|
61
76
|
|
|
62
|
-
export class DomainNameEndpoint extends
|
|
77
|
+
export class DomainNameEndpoint extends PortEndpoint {
|
|
63
78
|
constructor(service, domainName, data) {
|
|
64
79
|
super(service, data);
|
|
65
80
|
this.domainName = domainName;
|
|
@@ -74,7 +89,7 @@ export class DomainNameEndpoint extends _Endpoint {
|
|
|
74
89
|
}
|
|
75
90
|
}
|
|
76
91
|
|
|
77
|
-
export class HTTPEndpoint extends
|
|
92
|
+
export class HTTPEndpoint extends PortEndpoint {
|
|
78
93
|
constructor(service, url, data) {
|
|
79
94
|
super(service, data);
|
|
80
95
|
this.url = url;
|
|
@@ -83,4 +98,31 @@ export class HTTPEndpoint extends _Endpoint {
|
|
|
83
98
|
get address() {
|
|
84
99
|
return this.url;
|
|
85
100
|
}
|
|
101
|
+
|
|
102
|
+
toString() {
|
|
103
|
+
return `${this.type}:${this.url}`;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export class UnixEndpoint extends BaseEndpoint {
|
|
108
|
+
constructor(service, path, data) {
|
|
109
|
+
super(service, data);
|
|
110
|
+
this.path = path;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
get family() {
|
|
114
|
+
return "unix";
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
get host() {
|
|
118
|
+
return this.service.host;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
get address() {
|
|
122
|
+
return this.path;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
toString() {
|
|
126
|
+
return `${this.type}:${this.family}:${this.path}`;
|
|
127
|
+
}
|
|
86
128
|
}
|
package/src/service.mjs
CHANGED
package/src/services/dhcp.mjs
CHANGED
|
@@ -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",
|
|
98
|
+
console.log("kea", name, network.name);
|
|
74
99
|
|
|
75
100
|
const dnsServerEndpoints = serviceEndpoints(network, {
|
|
76
101
|
services: {
|
|
@@ -85,10 +110,10 @@ 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}-${
|
|
113
|
+
name: `kea-${this.location.name}-${name}`,
|
|
89
114
|
description: `kea definitions for ${this.fullName}@${name}`,
|
|
90
115
|
access: "private",
|
|
91
|
-
dependencies: ["kea>=2.6.
|
|
116
|
+
dependencies: ["kea>=2.6.2"]
|
|
92
117
|
}
|
|
93
118
|
};
|
|
94
119
|
|
|
@@ -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
|
-
|
|
135
|
-
|
|
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,11 +186,13 @@ export class DHCPService extends Service {
|
|
|
163
186
|
DhcpDdns: {
|
|
164
187
|
"ip-address": "127.0.0.1",
|
|
165
188
|
port: 53001,
|
|
166
|
-
"control-socket":
|
|
189
|
+
"control-socket": toUnix(
|
|
190
|
+
this.endpoint(e => e.type === "kea-control-ddns")
|
|
191
|
+
),
|
|
192
|
+
/* {
|
|
167
193
|
"socket-type": "unix",
|
|
168
194
|
"socket-name": "/run/kea/ddns-ctrl-socket"
|
|
169
|
-
},
|
|
170
|
-
"tsig-keys": [],
|
|
195
|
+
} */ "tsig-keys": [],
|
|
171
196
|
"forward-ddns": {
|
|
172
197
|
"ddns-domains": dnsServersSlot([...this.domains])
|
|
173
198
|
},
|
|
@@ -223,7 +248,11 @@ export class DHCPService extends Service {
|
|
|
223
248
|
endpoint => `${endpoint.networkInterface.name}/${endpoint.address}`
|
|
224
249
|
);
|
|
225
250
|
|
|
226
|
-
const subnets = [...this.subnets].filter(
|
|
251
|
+
const subnets = [...this.subnets].filter(
|
|
252
|
+
s =>
|
|
253
|
+
s !== SUBNET_LOCALHOST_IPV4 &&
|
|
254
|
+
s !== SUBNET_LOCALHOST_IPV6 /* s.address !== "127/8"*/
|
|
255
|
+
); // TODO no localhost
|
|
227
256
|
const dhcp4 = {
|
|
228
257
|
Dhcp4: {
|
|
229
258
|
...commonConfig,
|
package/types/endpoint.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export class Endpoint extends
|
|
1
|
+
export class Endpoint extends PortEndpoint {
|
|
2
2
|
constructor(service: any, networkAddress: any, data: any);
|
|
3
3
|
networkAddress: any;
|
|
4
4
|
get socketAddress(): string;
|
|
@@ -8,23 +8,35 @@ export class Endpoint extends _Endpoint {
|
|
|
8
8
|
get family(): any;
|
|
9
9
|
get networkInterface(): any;
|
|
10
10
|
}
|
|
11
|
-
export class DomainNameEndpoint extends
|
|
11
|
+
export class DomainNameEndpoint extends PortEndpoint {
|
|
12
12
|
constructor(service: any, domainName: any, data: any);
|
|
13
13
|
domainName: any;
|
|
14
14
|
get networkInterface(): {};
|
|
15
15
|
get address(): any;
|
|
16
16
|
}
|
|
17
|
-
export class HTTPEndpoint extends
|
|
17
|
+
export class HTTPEndpoint extends PortEndpoint {
|
|
18
18
|
constructor(service: any, url: any, data: any);
|
|
19
19
|
url: any;
|
|
20
20
|
get address(): any;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
export class UnixEndpoint extends BaseEndpoint {
|
|
23
|
+
constructor(service: any, path: any, data: any);
|
|
24
|
+
path: any;
|
|
25
|
+
get family(): string;
|
|
26
|
+
get host(): any;
|
|
27
|
+
get address(): any;
|
|
28
|
+
}
|
|
29
|
+
declare class PortEndpoint extends BaseEndpoint {
|
|
30
|
+
_port: any;
|
|
31
|
+
protocol: any;
|
|
32
|
+
tls: any;
|
|
33
|
+
get port(): any;
|
|
34
|
+
}
|
|
35
|
+
declare class BaseEndpoint {
|
|
23
36
|
constructor(service: any, data: any);
|
|
37
|
+
_type: any;
|
|
24
38
|
service: any;
|
|
25
39
|
get type(): any;
|
|
26
|
-
get port(): any;
|
|
27
40
|
toString(): string;
|
|
28
|
-
#private;
|
|
29
41
|
}
|
|
30
42
|
export {};
|
package/types/service.d.mts
CHANGED