pmcf 2.51.4 → 2.51.6

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.51.4",
3
+ "version": "2.51.6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/endpoint.mjs CHANGED
@@ -93,20 +93,32 @@ export class HTTPEndpoint extends PortEndpoint {
93
93
  constructor(service, address, data) {
94
94
  super(service, data);
95
95
 
96
- for (const name of ["path"]) {
97
- if (data[name] !== undefined) {
98
- this[name] = data[name];
99
- }
100
- }
101
-
102
96
  if (typeof address === "string") {
97
+ this.url = new URL(address);
98
+ } else if (address instanceof URL) {
103
99
  this.url = address;
104
100
  } else {
105
- this.url = "http://" + address.address + ":" + data.port + data.path;
106
- this.host = address.address;
101
+ this.url = new URL(
102
+ "http://" +
103
+ (address.family === "IPv6"
104
+ ? "[" + address.address + "]"
105
+ : address.address) +
106
+ ":" +
107
+ data.port +
108
+ data.path
109
+ );
110
+ this.hostname = address.address;
107
111
  }
108
112
  }
109
113
 
114
+ get port() {
115
+ return this.url.port || 80;
116
+ }
117
+
118
+ get pathname() {
119
+ return this.url.pathname;
120
+ }
121
+
110
122
  get address() {
111
123
  return this.url;
112
124
  }
package/src/service.mjs CHANGED
@@ -38,7 +38,7 @@ const ServiceTypes = {
38
38
  ssh: { endpoints: [{ protocol: "tcp", port: 22, tls: false }] },
39
39
  imap: { endpoints: [{ protocol: "tcp", port: 143, tls: false }] },
40
40
  imaps: { endpoints: [{ protocol: "tcp", port: 993, tls: true }] },
41
- dhcp: { endpoints: [{ port: 547, protocol: "udp", tls: false }] },
41
+ dhcp: { endpoints: [{ protocol: "udp", port: 547, tls: false }] },
42
42
  "dhcpv6-client": {
43
43
  endpoints: [
44
44
  { protocol: "tcp", port: 546, tls: false },
@@ -208,7 +208,7 @@ export class Service extends Base {
208
208
 
209
209
  return filter ? result.filter(filter) : result;
210
210
  }
211
-
211
+
212
212
  endpoint(filter) {
213
213
  return this.endpoints(filter)[0];
214
214
  }
@@ -216,7 +216,7 @@ export class Service extends Base {
216
216
  address(
217
217
  options = {
218
218
  endpoints: e => e.networkInterface?.kind !== "loopbak",
219
- select: e => e.domainName||e.address,
219
+ select: e => e.domainName || e.address,
220
220
  limit: 1,
221
221
  join: ""
222
222
  }
@@ -275,7 +275,10 @@ export class Service extends Base {
275
275
 
276
276
  if (hasSVRRecords) {
277
277
  for (const ep of this.endpoints(
278
- e => e.protocol && e.networkInterface && e.networkInterface.kind !== "loopback"
278
+ e =>
279
+ e.protocol &&
280
+ e.networkInterface &&
281
+ e.networkInterface.kind !== "loopback"
279
282
  )) {
280
283
  records.push(
281
284
  DNSRecord(
@@ -24,7 +24,7 @@ const DHCPServiceTypeDefinition = {
24
24
 
25
25
  const controlAgentEndpoint = {
26
26
  type: "kea-control-agent",
27
- port: 8000,
27
+ port: 53002,
28
28
  path: "/",
29
29
  method: "get",
30
30
  protocol: "tcp",
@@ -183,6 +183,21 @@ export class DHCPService extends Service {
183
183
  "renew-timer": 900,
184
184
  "rebind-timer": 1800,
185
185
  "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
+ ],
186
201
  "hooks-libraries": [
187
202
  {
188
203
  library: "/usr/lib/kea/hooks/libdhcp_lease_cmds.so"
@@ -308,26 +323,15 @@ export class DHCPService extends Service {
308
323
  const dhcp4 = {
309
324
  Dhcp4: {
310
325
  ...commonConfig("4"),
311
- "option-data": [
312
- {
313
- name: "domain-name-servers",
314
- data: dnsServerEndpoints
315
- .filter(endpoint => endpoint.family === "IPv4")
316
- .map(endpoint => endpoint.address)
317
- .join(",")
318
- },
319
- {
320
- name: "domain-search",
321
- data: [...this.domains].join(",")
322
- }
323
- ],
324
326
  subnet4: subnets
325
327
  .filter(s => s.family === "IPv4")
326
328
  .map((subnet, index) => {
327
329
  return {
328
330
  id: index + 1,
329
331
  subnet: subnet.longAddress,
330
- pools: [{ pool: subnet.dhcpUsableAddressRange.join(" - ") }],
332
+ pools: subnet.dhcpPools.map(range => {
333
+ return { pool: range.join(" - ") };
334
+ }),
331
335
  "option-data": [
332
336
  {
333
337
  name: "routers",
@@ -342,23 +346,15 @@ export class DHCPService extends Service {
342
346
  const dhcp6 = {
343
347
  Dhcp6: {
344
348
  ...commonConfig("6"),
345
- "preferred-lifetime": 3000,
346
- "option-data": [
347
- {
348
- name: "dns-servers",
349
- data: dnsServerEndpoints
350
- .filter(endpoint => endpoint.family === "IPv6")
351
- .map(endpoint => endpoint.address)
352
- .join(",")
353
- }
354
- ],
355
349
  subnet6: subnets
356
350
  .filter(s => s.family === "IPv6")
357
351
  .map((subnet, index) => {
358
352
  return {
359
353
  id: index + 1,
360
354
  subnet: subnet.longAddress,
361
- pools: [{ pool: subnet.addressRange.join(" - ") }],
355
+ pools: subnet.dhcpPools.map(range => {
356
+ return { pool: range.join(" - ") };
357
+ }),
362
358
 
363
359
  /*"pd-pools": [
364
360
  {
package/src/subnet.mjs CHANGED
@@ -64,10 +64,11 @@ 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
- {
67
+ get dhcpPools() {
69
68
  /* TODO where to take values from ? */
70
- return rangeIP(this.prefix, this.prefixLength, 51, 6).map(a => decodeIP(a));
69
+ return [
70
+ rangeIP(this.prefix, this.prefixLength, 51, 6).map(a => decodeIP(a))
71
+ ];
71
72
  }
72
73
 
73
74
  get address() {
@@ -16,9 +16,11 @@ export class DomainNameEndpoint extends PortEndpoint {
16
16
  }
17
17
  export class HTTPEndpoint extends PortEndpoint {
18
18
  constructor(service: any, address: any, data: any);
19
- url: string;
20
- host: any;
21
- get address(): string;
19
+ url: URL;
20
+ hostname: any;
21
+ get port(): string | 80;
22
+ get pathname(): string;
23
+ get address(): URL;
22
24
  }
23
25
  export class UnixEndpoint extends BaseEndpoint {
24
26
  constructor(service: any, path: any, data: any);
@@ -33,7 +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
+ get dhcpPools(): any[];
37
37
  get address(): string;
38
38
  get longAddress(): string;
39
39
  _traverse(...args: any[]): boolean;