pmcf 1.71.0 → 1.73.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": "1.71.0",
3
+ "version": "1.73.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/cluster.mjs CHANGED
@@ -56,24 +56,27 @@ export class Cluster extends Host {
56
56
  }
57
57
 
58
58
  async *preparePackages(stagingDir) {
59
- const result = {
60
- sources: [],
61
- properties: {
62
- description: `${this.typeName} definitions for ${this.fullName}`,
63
- access: "private"
64
- }
65
- };
66
-
67
- let interfaces = new Set();
68
-
69
- for (const cluster of this.owner.clusters()) {
70
- interfaces = interfaces.union(cluster.masters.union(cluster.backups));
71
- }
72
-
73
- for (const ni of interfaces) {
59
+ for (const ni of [...this.owner.clusters()].reduce(
60
+ (all, cluster) => all.union(cluster.members),
61
+ new Set()
62
+ )) {
74
63
  const host = ni.host;
75
64
  const name = `keepalived-${host.name}`;
76
65
  const packageStagingDir = join(stagingDir, name);
66
+ const result = {
67
+ sources: [
68
+ new FileContentProvider(packageStagingDir + "/")[
69
+ Symbol.asyncIterator
70
+ ]()
71
+ ],
72
+ outputs: host.outputs,
73
+ properties: {
74
+ name,
75
+ description: `${this.typeName} definitions for ${this.fullName}`,
76
+ access: "private",
77
+ dependencies: ["keepalived"]
78
+ }
79
+ };
77
80
 
78
81
  const cfg = [
79
82
  "global_defs {",
@@ -146,13 +149,6 @@ export class Cluster extends Host {
146
149
  cfg
147
150
  );
148
151
 
149
- (result.outputs = host.outputs), (result.properties.name = name);
150
- result.properties.dependencies = ["keepalived"];
151
-
152
- result.sources.push(
153
- new FileContentProvider(packageStagingDir + "/")[Symbol.asyncIterator]()
154
- );
155
-
156
152
  yield result;
157
153
  }
158
154
  }
package/src/dns.mjs CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  } from "./utils.mjs";
10
10
  import { Base } from "./base.mjs";
11
11
  import { addType } from "./types.mjs";
12
- import { sortByPriority } from "./service.mjs";
12
+ import { serviceAddresses } from "./service.mjs";
13
13
  import { subnets } from "./subnet.mjs";
14
14
 
15
15
  const DNSServiceTypeDefinition = {
@@ -91,15 +91,6 @@ export class DNSService extends Base {
91
91
  return this.#forwardsTo;
92
92
  }
93
93
 
94
- get forwardsToAdresses() {
95
- return this.forwardsTo
96
- .map(ft => Array.from(ft.findServices(DNS_SERVICE_FILTER)))
97
- .flat()
98
- .sort(sortByPriority)
99
- .map(s => s.rawAddresses)
100
- .flat();
101
- }
102
-
103
94
  *findServices(filter) {
104
95
  yield* this.owner.findServices(filter);
105
96
 
@@ -113,22 +104,15 @@ export class DNSService extends Base {
113
104
  }
114
105
 
115
106
  async resolvedConfig() {
116
- const dnsServices = Array.from(this.findServices(DNS_SERVICE_FILTER)).sort(
117
- sortByPriority
118
- );
119
-
120
- const master = dnsServices
121
- .filter(s => s.priority < 10)
122
- .map(s => s.rawAddresses)
123
- .flat();
124
- const fallback = dnsServices
125
- .filter(s => s.priority >= 10)
126
- .map(s => s.rawAddresses)
127
- .flat();
128
-
129
107
  return {
130
- DNS: master.join(" "),
131
- FallbackDNS: fallback.join(" "),
108
+ DNS: serviceAddresses(this, {
109
+ ...DNS_SERVICE_FILTER,
110
+ priority: "<10"
111
+ }).join(" "),
112
+ FallbackDNS: serviceAddresses(this, {
113
+ ...DNS_SERVICE_FILTER,
114
+ priority: ">=10"
115
+ }).join(" "),
132
116
  Domains: this.domains.join(" "),
133
117
  DNSSEC: "no",
134
118
  MulticastDNS: "yes",
@@ -152,7 +136,9 @@ export class DNSService extends Base {
152
136
 
153
137
  const options = [
154
138
  "forwarders {",
155
- ...this.forwardsToAdresses.map(a => ` ${a};`),
139
+ ...serviceAddresses(this.forwardsTo, DNS_SERVICE_FILTER).map(
140
+ a => ` ${a};`
141
+ ),
156
142
  "};"
157
143
  ];
158
144
  await writeLines(join(p1, "etc/named.d/options"), `${name}.conf`, options);
package/src/service.mjs CHANGED
@@ -1,17 +1,19 @@
1
1
  import { Base } from "./base.mjs";
2
2
  import { addType } from "./types.mjs";
3
+ import { asArray } from "./utils.mjs";
3
4
 
4
5
  const ServiceTypes = {
5
- dns: { protocol: "udp", port: 53 },
6
- ldap: { protocol: "tcp", port: 389 },
7
- http: { protocol: "tcp", port: 80 },
8
- https: { protocol: "tcp", port: 443 },
9
- rtsp: { protocol: "tcp", port: 554 },
10
- smtp: { protocol: "tcp", port: 25 },
11
- ssh: { protocol: "tcp", port: 22 },
12
- imap: { protocol: "tcp", port: 143 },
13
- imaps: { protocol: "tcp", port: 993 },
14
- dhcp: {}
6
+ dns: { protocol: "udp", port: 53, tls: false },
7
+ ldap: { protocol: "tcp", port: 389, tls: false },
8
+ ldaps: { protocol: "tcp", port: 636, tls: true },
9
+ http: { protocol: "tcp", port: 80, tls: false },
10
+ https: { protocol: "tcp", port: 443, tls: true },
11
+ rtsp: { protocol: "tcp", port: 554, tls: false },
12
+ smtp: { protocol: "tcp", port: 25, tls: false },
13
+ ssh: { protocol: "tcp", port: 22, tls: false },
14
+ imap: { protocol: "tcp", port: 143, tls: false },
15
+ imaps: { protocol: "tcp", port: 993, tls: true },
16
+ dhcp: { tls: false }
15
17
  };
16
18
 
17
19
  const ServiceTypeDefinition = {
@@ -28,7 +30,8 @@ const ServiceTypeDefinition = {
28
30
  master: { type: "boolean", collection: false, writeable: true },
29
31
  priority: { type: "number", collection: false, writeable: true },
30
32
  weight: { type: "number", collection: false, writeable: true },
31
- srvPrefix: { type: "string", collection: false, writeable: false }
33
+ srvPrefix: { type: "string", collection: false, writeable: false },
34
+ tls: { type: "string", collection: false, writeable: false }
32
35
  }
33
36
  };
34
37
 
@@ -157,6 +160,10 @@ export class Service extends Base {
157
160
  return ServiceTypes[this.type]?.protocol;
158
161
  }
159
162
 
163
+ get tls() {
164
+ return ServiceTypes[this.type]?.tls || false;
165
+ }
166
+
160
167
  get srvPrefix() {
161
168
  const st = ServiceTypes[this.type];
162
169
  if (st?.protocol) {
@@ -166,3 +173,16 @@ export class Service extends Base {
166
173
  }
167
174
 
168
175
  export const sortByPriority = (a, b) => a.priority - b.priority;
176
+
177
+ export function serviceAddresses(
178
+ sources,
179
+ filter,
180
+ addressType = "rawAddresses"
181
+ ) {
182
+ return asArray(sources)
183
+ .map(ft => Array.from(ft.findServices(filter)))
184
+ .flat()
185
+ .sort(sortByPriority)
186
+ .map(s => s[addressType])
187
+ .flat();
188
+ }
@@ -403,10 +403,13 @@ export class Cluster extends Host {
403
403
  get backups(): Set<any>;
404
404
  get members(): Set<any>;
405
405
  preparePackages(stagingDir: any): AsyncGenerator<{
406
- sources: any[];
406
+ sources: AsyncGenerator<any, void, unknown>[];
407
+ outputs: any;
407
408
  properties: {
409
+ name: string;
408
410
  description: string;
409
411
  access: string;
412
+ dependencies: string[];
410
413
  };
411
414
  }, void, unknown>;
412
415
  #private;
package/types/dns.d.mts CHANGED
@@ -83,7 +83,6 @@ export class DNSService extends Base {
83
83
  get trusted(): any[];
84
84
  set forwardsTo(value: any[]);
85
85
  get forwardsTo(): any[];
86
- get forwardsToAdresses(): any[];
87
86
  get domains(): any[];
88
87
  resolvedConfig(): Promise<{
89
88
  DNS: string;
@@ -1,3 +1,4 @@
1
+ export function serviceAddresses(sources: any, filter: any, addressType?: string): any[];
1
2
  export class Service extends Base {
2
3
  static get typeDefinition(): {
3
4
  name: string;
@@ -86,6 +87,11 @@ export class Service extends Base {
86
87
  collection: boolean;
87
88
  writeable: boolean;
88
89
  };
90
+ tls: {
91
+ type: string;
92
+ collection: boolean;
93
+ writeable: boolean;
94
+ };
89
95
  };
90
96
  };
91
97
  alias: any;
@@ -105,6 +111,7 @@ export class Service extends Base {
105
111
  get type(): any;
106
112
  get master(): any;
107
113
  get protocol(): any;
114
+ get tls(): any;
108
115
  get srvPrefix(): string;
109
116
  #private;
110
117
  }