pmcf 2.26.1 → 2.28.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/bin/pmcf-diagram CHANGED
@@ -9,38 +9,27 @@ const location = await root.load(args[0]);
9
9
  function q(str) {
10
10
  return str.match(/^\w+$/) ? str : `"${str}"`;
11
11
  }
12
- function id(str) {
13
- return q(str.replaceAll(/-/g, ""));
14
- }
15
12
 
16
13
  console.log("graph G {");
17
14
  console.log(" node [shape=record];");
18
15
  for await (const host of location.hosts()) {
19
16
  console.log(
20
- ` ${id(host.name)} [label="${host.name}|{${[
17
+ ` ${q(host.name)} [label="${host.name}|{${[
21
18
  ...host.networkInterfaces.values()
22
19
  ]
23
20
  .filter(ni => !ni.isTemplate && ni.kind !== "loopback")
24
- .map(ni => `<${id(ni.name)}> ${ni.name}`)
21
+ .map(ni => `<${q(ni.name)}> ${ni.name}`)
25
22
  .join("|")}}"];`
26
23
  );
27
24
  }
28
25
 
29
26
  for await (const network of location.networks()) {
30
27
  console.log(
31
- ` ${id(network.name)} [label="${network.name}\\n${[...network.subnets()]
28
+ ` ${q(network.name)} [label="${network.name}\\n${[...network.subnets()]
32
29
  .map(s => s.address)
33
30
  .join(" ")}" shape=circle];`
34
31
  );
35
32
 
36
- if (network.bridge) {
37
- for (const n of network.bridge) {
38
- if (n !== network) {
39
- console.log(` ${id(network.name)} -- ${id(n.name)};`);
40
- }
41
- }
42
- }
43
-
44
33
  for await (const na of network.networkAddresses(
45
34
  na =>
46
35
  na.networkInterface.network === network &&
@@ -48,11 +37,19 @@ for await (const network of location.networks()) {
48
37
  na.networkInterface.kind !== "loopback"
49
38
  )) {
50
39
  console.log(
51
- ` ${id(network.name)} -- ${id(na.networkInterface.host.name)}:${id(
40
+ ` ${q(network.name)} -- ${q(na.networkInterface.host.name)}:${q(
52
41
  na.networkInterface.name
53
42
  )}[label="${na.address}"];`
54
43
  );
55
44
  }
56
45
  }
57
46
 
47
+ for await (const cluster of location.clusters()) {
48
+ console.log(` ${[...cluster.members].map(b => `${q(b.host.name)}:${b.name}`).join(" -- ")};`);
49
+ }
50
+
51
+ for (const bridge of location.bridges) {
52
+ console.log(` ${[...bridge].map(b => q(b.name)).join(" -- ")};`);
53
+ }
54
+
58
55
  console.log("}");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "2.26.1",
3
+ "version": "2.28.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/cluster.mjs CHANGED
@@ -4,7 +4,6 @@ import { Owner } from "./owner.mjs";
4
4
  import { Host } from "./host.mjs";
5
5
  import { addType } from "./types.mjs";
6
6
  import { writeLines } from "./utils.mjs";
7
- import { cidrAddresses } from "./network-support.mjs";
8
7
 
9
8
  const ClusterTypeDefinition = {
10
9
  name: "cluster",
package/src/owner.mjs CHANGED
@@ -214,6 +214,11 @@ export class Owner extends Base {
214
214
  return this.typeList("cluster");
215
215
  }
216
216
 
217
+ get bridges()
218
+ {
219
+ return this._bridges;
220
+ }
221
+
217
222
  addBridge(network, destinationNetworks) {
218
223
  if (destinationNetworks) {
219
224
  let bridge;
@@ -9,6 +9,7 @@ import {
9
9
  dnsRecordTypeForAddressFamily,
10
10
  sortZoneRecords
11
11
  } from "../dns-utils.mjs";
12
+ import { Endpoint, serviceEndpoints } from "pmcf";
12
13
  import { addType } from "../types.mjs";
13
14
  import { ServiceTypeDefinition, serviceAddresses } from "../service.mjs";
14
15
  import {
@@ -69,6 +70,20 @@ const DNSServiceTypeDefinition = {
69
70
  }
70
71
  };
71
72
 
73
+ const rdncEndpoint = {
74
+ type: "rdnc",
75
+ port: 953,
76
+ protocol: "tcp",
77
+ tls: false
78
+ };
79
+
80
+ const statisticsEndpoint = {
81
+ type: "bind-statistics",
82
+ port: 19521,
83
+ protocol: "tcp",
84
+ tls: false
85
+ };
86
+
72
87
  const DNS_SERVICE_FILTER = { type: DNSServiceTypeDefinition.name };
73
88
 
74
89
  function addressList(objects) {
@@ -123,6 +138,19 @@ export class DNSService extends ExtraSourceService {
123
138
  return DNSServiceTypeDefinition.name;
124
139
  }
125
140
 
141
+ endpoints(filter) {
142
+ const endpoints = super.endpoints(filter);
143
+
144
+ for (const na of this.server.networkAddresses(
145
+ na => na.networkInterface.kind === "localhost"
146
+ )) {
147
+ endpoints.push(new Endpoint(this, na, rdncEndpoint));
148
+ endpoints.push(new Endpoint(this, na, statisticsEndpoint));
149
+ }
150
+
151
+ return endpoints;
152
+ }
153
+
126
154
  get soaUpdates() {
127
155
  return [this.serial, this.refresh, this.retry, this.expire, this.minimum];
128
156
  }
@@ -202,15 +230,15 @@ export class DNSService extends ExtraSourceService {
202
230
  }
203
231
  };
204
232
 
205
- const options = addressesStatement(
206
- "forwarders",
207
- serviceAddresses(this.source, DNS_SERVICE_FILTER)
233
+ const forwarders = new Set(
234
+ serviceEndpoints(this.source, DNS_SERVICE_FILTER).map(e => e.address)
208
235
  );
209
- if (options.length > 2) {
236
+
237
+ if (forwarders.size) {
210
238
  await writeLines(
211
239
  join(p1, "etc/named/options"),
212
240
  `forwarders.conf`,
213
- options
241
+ addressesStatement("forwarders", forwarders)
214
242
  );
215
243
  }
216
244
 
@@ -223,7 +251,7 @@ export class DNSService extends ExtraSourceService {
223
251
  if (acls.length) {
224
252
  await writeLines(join(p1, "etc/named"), `0-acl-${name}.conf`, acls);
225
253
  }
226
- if (options.length || acls.length) {
254
+ if (forwarders.size || acls.length) {
227
255
  yield packageData;
228
256
  }
229
257
 
package/types/owner.d.mts CHANGED
@@ -152,6 +152,7 @@ export class Owner extends Base {
152
152
  subnetForAddress(address: any): any;
153
153
  clusterNamed(name: any): any;
154
154
  clusters(): any;
155
+ get bridges(): Set<any>;
155
156
  addBridge(network: any, destinationNetworks: any): any;
156
157
  _resolveBridges(): void;
157
158
  get derivedPackaging(): Set<any>;