pmcf 2.33.1 → 2.33.3

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.33.1",
3
+ "version": "2.33.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/cluster.mjs CHANGED
@@ -147,7 +147,7 @@ export class Cluster extends Host {
147
147
  cfg.push(` protocol ${service.protocol.toUpperCase()}`);
148
148
 
149
149
  for (const member of this.members) {
150
- const memberService = member.findService({ type: service.type });
150
+ const memberService = member.findService({ type: service.type }) || member.host.findService({ type: service.type }); // TODO
151
151
 
152
152
  cfg.push(` real_server ${member.address} ${memberService.port} {`);
153
153
  cfg.push(` weight ${memberService.weight}`);
package/src/location.mjs CHANGED
@@ -70,27 +70,20 @@ export class Location extends Owner {
70
70
  }
71
71
  };
72
72
 
73
- await writeLines(
74
- join(dir, "etc/systemd/resolved.conf.d"),
75
- `${this.name}.conf`,
76
- sectionLines(...this.findService({ type: "dns" }).systemdConfig)
77
- );
73
+ const configs = [
74
+ { type: "dns" },
75
+ { type: "ntp" },
76
+ { type: "systemd-journald" }
77
+ ];
78
78
 
79
- await writeLines(
80
- join(dir, "etc/systemd/journald.conf.d"),
81
- `${this.name}.conf`,
82
- sectionLines("Journal", {
83
- Compress: "yes",
84
- SystemMaxUse: "500M",
85
- SyncIntervalSec: "15m"
86
- })
87
- );
79
+ for (const cfg of configs) {
80
+ const service = this.findService(cfg);
88
81
 
89
- await writeLines(
90
- join(dir, "etc/systemd/timesyncd.conf.d"),
91
- `${this.name}.conf`,
92
- sectionLines(...this.findService({ type: "ntp" }).systemdConfig)
93
- );
82
+ if (service) {
83
+ const { name, content } = service.systemdConfig(this.name);
84
+ await writeLines(dir, name, sectionLines(...content));
85
+ }
86
+ }
94
87
 
95
88
  yield packageData;
96
89
  }
package/src/module.mjs CHANGED
@@ -19,4 +19,5 @@ export * from "./endpoint.mjs";
19
19
  export * from "./services/dns.mjs";
20
20
  export * from "./services/ntp.mjs";
21
21
  export * from "./services/dhcp.mjs";
22
+ export * from "./services/systemd-journald.mjs";
22
23
  export * from "./types.mjs";
@@ -1,6 +1,6 @@
1
1
  import { join } from "node:path";
2
2
  import { writeLines, sectionLines } from "../utils.mjs";
3
- import { NetworkAddress } from "pmcf";
3
+ import { NetworkAddress, Host } from "pmcf";
4
4
  import { ServiceOwner } from "../service-owner.mjs";
5
5
  import { cidrAddresses } from "../network-support.mjs";
6
6
 
@@ -29,7 +29,9 @@ export class SkeletonNetworkInterface extends ServiceOwner {
29
29
  }
30
30
 
31
31
  get host() {
32
- return this.owner;
32
+ if(this.owner instanceof Host) {
33
+ return this.owner;
34
+ }
33
35
  }
34
36
 
35
37
  *hosts() {
package/src/service.mjs CHANGED
@@ -11,6 +11,11 @@ import {
11
11
  } from "./dns-utils.mjs";
12
12
 
13
13
  const ServiceTypes = {
14
+ "systemd-resolved": { endpoints: [] },
15
+ "systemd-timesyncd": { endpoints: [] },
16
+ "systemd-journald": { endpoints: [] },
17
+ "systemd-journal-remote": { endpoints: [] },
18
+ "systemd-journal-upload": { endpoints: [] },
14
19
  ntp: { endpoints: [{ protocol: "udp", port: 123, tls: false }] },
15
20
  dns: { endpoints: [{ protocol: "udp", port: 53, tls: false }] },
16
21
  ldap: { endpoints: [{ protocol: "tcp", port: 389, tls: false }] },
@@ -149,7 +154,7 @@ export class Service extends Base {
149
154
  }
150
155
 
151
156
  get host() {
152
- if(this.owner instanceof Host) {
157
+ if (this.owner instanceof Host) {
153
158
  return this.owner;
154
159
  }
155
160
  }
@@ -210,24 +210,27 @@ export class DNSService extends ExtraSourceService {
210
210
  return this._excludeInterfaceKinds;
211
211
  }
212
212
 
213
- get systemdConfig() {
214
- return [
215
- "Resolve",
216
- {
217
- DNS: serviceAddresses(this, {
218
- ...DNS_SERVICE_FILTER,
219
- priority: "<10"
220
- }).join(" "),
221
- FallbackDNS: serviceAddresses(this, {
222
- ...DNS_SERVICE_FILTER,
223
- priority: ">=10"
224
- }).join(" "),
225
- Domains: [...this.localDomains].join(" "),
226
- DNSSEC: "no",
227
- MulticastDNS: this.network.multicastDNS ? "yes" : "no",
228
- LLMNR: "no"
229
- }
230
- ];
213
+ systemdConfig(name) {
214
+ return {
215
+ name: `etc/systemd/resolved.conf.d/${name}.conf`,
216
+ content: [
217
+ "Resolve",
218
+ {
219
+ DNS: serviceAddresses(this, {
220
+ ...DNS_SERVICE_FILTER,
221
+ priority: "<10"
222
+ }).join(" "),
223
+ FallbackDNS: serviceAddresses(this, {
224
+ ...DNS_SERVICE_FILTER,
225
+ priority: ">=10"
226
+ }).join(" "),
227
+ Domains: [...this.localDomains].join(" "),
228
+ DNSSEC: "no",
229
+ MulticastDNS: this.network.multicastDNS ? "yes" : "no",
230
+ LLMNR: "no"
231
+ }
232
+ ]
233
+ };
231
234
  }
232
235
 
233
236
  async *preparePackages(dir) {
@@ -367,7 +370,12 @@ async function generateZoneDefs(dns, location, packageData) {
367
370
  );
368
371
  }
369
372
 
370
- console.log("LOCAL DOMAINS", location.localDomains, location.domain, location.toString());
373
+ console.log(
374
+ "LOCAL DOMAINS",
375
+ location.localDomains,
376
+ location.domain,
377
+ location.toString()
378
+ );
371
379
 
372
380
  for (const domain of location.localDomains) {
373
381
  const locationName = location.name;
@@ -418,7 +426,7 @@ async function generateZoneDefs(dns, location, packageData) {
418
426
  domainNames,
419
427
  family
420
428
  } of location.networkAddresses()) {
421
- console.log("ADDRESS",address);
429
+ console.log("ADDRESS", address);
422
430
 
423
431
  if (
424
432
  !dns.exclude.has(networkInterface.network) &&
@@ -48,21 +48,24 @@ export class NTPService extends ExtraSourceService {
48
48
  return NTPServiceTypeDefinition.name;
49
49
  }
50
50
 
51
- get systemdConfig() {
52
- return [
53
- "Time",
54
- {
55
- NTP: serviceAddresses(
56
- this,
57
- {
58
- ...NTP_SERVICE_FILTER,
59
- priority: "<20"
60
- },
61
- "domainName",
62
- () => true
63
- ).join(" ")
64
- }
65
- ];
51
+ systemdConfig(name) {
52
+ return {
53
+ name: `etc/systemd/timesyncd.conf.d/${name}.conf`,
54
+ content: [
55
+ "Time",
56
+ {
57
+ NTP: serviceAddresses(
58
+ this,
59
+ {
60
+ ...NTP_SERVICE_FILTER,
61
+ priority: "<20"
62
+ },
63
+ "domainName",
64
+ () => true
65
+ ).join(" ")
66
+ }
67
+ ]
68
+ };
66
69
  }
67
70
 
68
71
  async *preparePackages(dir) {
@@ -91,7 +94,7 @@ export class NTPService extends ExtraSourceService {
91
94
  ...NTP_SERVICE_FILTER,
92
95
  priority: ">=10"
93
96
  },
94
- e => e.family === 'IPv4' && e.networkInterface.kind !== "loopback"
97
+ e => e.family === "IPv4" && e.networkInterface.kind !== "loopback"
95
98
  ).map(
96
99
  endpoint =>
97
100
  `${endpoint.service.isPool ? "pool" : "server"} ${
@@ -0,0 +1,44 @@
1
+ import { Service, ServiceTypeDefinition } from "pmcf";
2
+ import { addType } from "../types.mjs";
3
+
4
+ const SystemdJournaldServiceTypeDefinition = {
5
+ name: "systemd-journald",
6
+ specializationOf: ServiceTypeDefinition,
7
+ owners: ServiceTypeDefinition.owners,
8
+ extends: ServiceTypeDefinition,
9
+ priority: 0.1,
10
+ properties: {}
11
+ };
12
+
13
+ export class SystemdJournaldService extends Service {
14
+ static {
15
+ addType(this);
16
+ }
17
+
18
+ static get typeDefinition() {
19
+ return SystemdJournaldServiceTypeDefinition;
20
+ }
21
+
22
+ constructor(owner, data) {
23
+ super(owner, data);
24
+ this.read(data, SystemdJournaldServiceTypeDefinition);
25
+ }
26
+
27
+ get type() {
28
+ return SystemdJournaldServiceTypeDefinition.name;
29
+ }
30
+
31
+ systemdConfig(name) {
32
+ return {
33
+ name: `etc/systemd/journal.conf.d/${name}.conf`,
34
+ content: [
35
+ "Journal",
36
+ {
37
+ Compress: "yes",
38
+ SystemMaxUse: "500M",
39
+ SyncIntervalSec: "15m"
40
+ }
41
+ ]
42
+ };
43
+ }
44
+ }
@@ -19,4 +19,5 @@ export * from "./endpoint.mjs";
19
19
  export * from "./services/dns.mjs";
20
20
  export * from "./services/ntp.mjs";
21
21
  export * from "./services/dhcp.mjs";
22
+ export * from "./services/systemd-journald.mjs";
22
23
  export * from "./types.mjs";
@@ -331,7 +331,6 @@ export class NetworkInterface extends SkeletonNetworkInterface {
331
331
  get gatewayAddress(): any;
332
332
  set hostName(value: any);
333
333
  get hostName(): any;
334
- get domainNames(): any;
335
334
  set scope(value: any);
336
335
  get scope(): any;
337
336
  set hwaddr(value: any);
@@ -4,6 +4,7 @@ export class SkeletonNetworkInterface extends ServiceOwner {
4
4
  get typeName(): string;
5
5
  set extends(value: any[]);
6
6
  get extends(): any[];
7
+ get host(): Host;
7
8
  hosts(): Generator<any, void, any>;
8
9
  get network_interface(): this;
9
10
  get domainNames(): Set<any>;
@@ -24,4 +25,5 @@ export class SkeletonNetworkInterface extends ServiceOwner {
24
25
  systemdDefinitions(packageData: any): Promise<void>;
25
26
  }
26
27
  import { ServiceOwner } from "../service-owner.mjs";
28
+ import { Host } from "pmcf";
27
29
  import { NetworkAddress } from "pmcf";
@@ -377,14 +377,17 @@ export class DNSService extends ExtraSourceService {
377
377
  get exclude(): Set<any>;
378
378
  set excludeInterfaceKinds(value: Set<any>);
379
379
  get excludeInterfaceKinds(): Set<any>;
380
- get systemdConfig(): (string | {
381
- DNS: string;
382
- FallbackDNS: string;
383
- Domains: string;
384
- DNSSEC: string;
385
- MulticastDNS: string;
386
- LLMNR: string;
387
- })[];
380
+ systemdConfig(name: any): {
381
+ name: string;
382
+ content: (string | {
383
+ DNS: string;
384
+ FallbackDNS: string;
385
+ Domains: string;
386
+ DNSSEC: string;
387
+ MulticastDNS: string;
388
+ LLMNR: string;
389
+ })[];
390
+ };
388
391
  preparePackages(dir: any): AsyncGenerator<{
389
392
  dir: string;
390
393
  sources: FileContentProvider[];
@@ -272,9 +272,12 @@ export class NTPService extends ExtraSourceService {
272
272
  };
273
273
  };
274
274
  };
275
- get systemdConfig(): (string | {
276
- NTP: string;
277
- })[];
275
+ systemdConfig(name: any): {
276
+ name: string;
277
+ content: (string | {
278
+ NTP: string;
279
+ })[];
280
+ };
278
281
  preparePackages(dir: any): AsyncGenerator<{
279
282
  dir: any;
280
283
  sources: FileContentProvider[];
@@ -0,0 +1,266 @@
1
+ export class SystemdJournaldService extends Service {
2
+ static get typeDefinition(): {
3
+ name: string;
4
+ specializationOf: {
5
+ name: string;
6
+ owners: string[];
7
+ priority: number;
8
+ extends: {
9
+ name: string;
10
+ owners: any[];
11
+ properties: {
12
+ owner: {
13
+ type: string;
14
+ collection: boolean;
15
+ writeable: boolean;
16
+ };
17
+ type: {
18
+ type: string;
19
+ collection: boolean;
20
+ writeable: boolean;
21
+ };
22
+ name: {
23
+ type: string;
24
+ collection: boolean;
25
+ identifier: boolean;
26
+ writeable: boolean;
27
+ };
28
+ description: {
29
+ type: string;
30
+ collection: boolean;
31
+ writeable: boolean;
32
+ };
33
+ priority: {
34
+ type: string;
35
+ collection: boolean;
36
+ writeable: boolean;
37
+ };
38
+ directory: {
39
+ type: string;
40
+ collection: boolean;
41
+ writeable: boolean;
42
+ };
43
+ packaging: {
44
+ type: string;
45
+ collection: boolean;
46
+ writeable: boolean;
47
+ };
48
+ tags: {
49
+ type: string;
50
+ collection: boolean;
51
+ writeable: boolean;
52
+ };
53
+ };
54
+ };
55
+ specializations: {};
56
+ factoryFor(owner: any, value: any): any;
57
+ properties: {
58
+ ipAddresses: {
59
+ type: string;
60
+ collection: boolean;
61
+ writeable: boolean;
62
+ };
63
+ alias: {
64
+ type: string;
65
+ collection: boolean;
66
+ writeable: boolean;
67
+ };
68
+ weight: {
69
+ type: string;
70
+ collection: boolean;
71
+ writeable: boolean;
72
+ default: number;
73
+ };
74
+ systemd: {
75
+ type: string;
76
+ collection: boolean;
77
+ writeable: boolean;
78
+ };
79
+ port: {
80
+ type: string;
81
+ collection: boolean;
82
+ writeable: boolean;
83
+ };
84
+ protocol: {
85
+ type: string;
86
+ collection: boolean;
87
+ writeable: boolean;
88
+ values: string[];
89
+ };
90
+ type: {
91
+ type: string;
92
+ collection: boolean;
93
+ writeable: boolean;
94
+ };
95
+ tls: {
96
+ type: string;
97
+ collection: boolean;
98
+ writeable: boolean;
99
+ default: boolean;
100
+ };
101
+ hostName: {
102
+ type: string;
103
+ collection: boolean;
104
+ writeable: boolean;
105
+ };
106
+ cidrAddresses: {
107
+ type: string;
108
+ collection: boolean;
109
+ writeable: boolean;
110
+ };
111
+ cidrAddress: {
112
+ type: string;
113
+ collection: boolean;
114
+ writeable: boolean;
115
+ };
116
+ addresses: {
117
+ type: string;
118
+ collection: boolean;
119
+ writeable: boolean;
120
+ };
121
+ address: {
122
+ type: string;
123
+ collection: boolean;
124
+ writeable: boolean;
125
+ };
126
+ };
127
+ };
128
+ owners: string[];
129
+ extends: {
130
+ name: string;
131
+ owners: string[];
132
+ priority: number;
133
+ extends: {
134
+ name: string;
135
+ owners: any[];
136
+ properties: {
137
+ owner: {
138
+ type: string;
139
+ collection: boolean;
140
+ writeable: boolean;
141
+ };
142
+ type: {
143
+ type: string;
144
+ collection: boolean;
145
+ writeable: boolean;
146
+ };
147
+ name: {
148
+ type: string;
149
+ collection: boolean;
150
+ identifier: boolean;
151
+ writeable: boolean;
152
+ };
153
+ description: {
154
+ type: string;
155
+ collection: boolean;
156
+ writeable: boolean;
157
+ };
158
+ priority: {
159
+ type: string;
160
+ collection: boolean;
161
+ writeable: boolean;
162
+ };
163
+ directory: {
164
+ type: string;
165
+ collection: boolean;
166
+ writeable: boolean;
167
+ };
168
+ packaging: {
169
+ type: string;
170
+ collection: boolean;
171
+ writeable: boolean;
172
+ };
173
+ tags: {
174
+ type: string;
175
+ collection: boolean;
176
+ writeable: boolean;
177
+ };
178
+ };
179
+ };
180
+ specializations: {};
181
+ factoryFor(owner: any, value: any): any;
182
+ properties: {
183
+ ipAddresses: {
184
+ type: string;
185
+ collection: boolean;
186
+ writeable: boolean;
187
+ };
188
+ alias: {
189
+ type: string;
190
+ collection: boolean;
191
+ writeable: boolean;
192
+ };
193
+ weight: {
194
+ type: string;
195
+ collection: boolean;
196
+ writeable: boolean;
197
+ default: number;
198
+ };
199
+ systemd: {
200
+ type: string;
201
+ collection: boolean;
202
+ writeable: boolean;
203
+ };
204
+ port: {
205
+ type: string;
206
+ collection: boolean;
207
+ writeable: boolean;
208
+ };
209
+ protocol: {
210
+ type: string;
211
+ collection: boolean;
212
+ writeable: boolean;
213
+ values: string[];
214
+ };
215
+ type: {
216
+ type: string;
217
+ collection: boolean;
218
+ writeable: boolean;
219
+ };
220
+ tls: {
221
+ type: string;
222
+ collection: boolean;
223
+ writeable: boolean;
224
+ default: boolean;
225
+ };
226
+ hostName: {
227
+ type: string;
228
+ collection: boolean;
229
+ writeable: boolean;
230
+ };
231
+ cidrAddresses: {
232
+ type: string;
233
+ collection: boolean;
234
+ writeable: boolean;
235
+ };
236
+ cidrAddress: {
237
+ type: string;
238
+ collection: boolean;
239
+ writeable: boolean;
240
+ };
241
+ addresses: {
242
+ type: string;
243
+ collection: boolean;
244
+ writeable: boolean;
245
+ };
246
+ address: {
247
+ type: string;
248
+ collection: boolean;
249
+ writeable: boolean;
250
+ };
251
+ };
252
+ };
253
+ priority: number;
254
+ properties: {};
255
+ };
256
+ get type(): string;
257
+ systemdConfig(name: any): {
258
+ name: string;
259
+ content: (string | {
260
+ Compress: string;
261
+ SystemMaxUse: string;
262
+ SyncIntervalSec: string;
263
+ })[];
264
+ };
265
+ }
266
+ import { Service } from "pmcf";