pmcf 6.45.0 → 6.46.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "6.45.0",
3
+ "version": "6.46.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -1,15 +1,30 @@
1
1
  import { join } from "node:path";
2
- import { FAMILY_IPV4, isLinkLocal } from "ip-utilties";
3
2
  import { FileContentProvider } from "npm-pkgbuild";
3
+ import { default_collection_attribute_writable } from "pacc";
4
4
  import {
5
- serviceEndpoints,
6
- addType,ExtraSourceService,
5
+ addType,
7
6
  FAMILY_UNIX,
8
- FAMILY_IPV4_IPV6
7
+ FAMILY_IPV4_IPV6,
8
+ CoreService
9
9
  } from "pmcf";
10
10
  import { writeLines } from "../utils.mjs";
11
11
 
12
- export class chrony extends ExtraSourceService {
12
+ export class chrony extends CoreService {
13
+ static attributes = {
14
+ servers: {
15
+ ...default_collection_attribute_writable,
16
+ type: "endpoint",
17
+ name: "servers",
18
+ deferredExpression: true
19
+ },
20
+ peers: {
21
+ ...default_collection_attribute_writable,
22
+ type: "endpoint",
23
+ name: "peers",
24
+ deferredExpression: true
25
+ }
26
+ };
27
+
13
28
  static service = {
14
29
  systemdService: "chronyd.service",
15
30
  extends: ["ntp"],
@@ -52,30 +67,28 @@ export class chrony extends ExtraSourceService {
52
67
  const subnets = [...new Map(this.subnets).values()]; // TODO should be normal
53
68
  const host = this.host;
54
69
 
70
+ function chronyServer(endpoint) {
71
+ const values = [
72
+ endpoint.isPool ? "pool" : "server",
73
+ endpoint.address,
74
+ "iburst"
75
+ ];
76
+
77
+ if (endpoint.isPool) {
78
+ values.push("maxsources 2");
79
+ }
80
+ if (endpoint.priority > 300) {
81
+ values.push("prefer");
82
+ }
83
+
84
+ return values.join(" ");
85
+ }
55
86
  const lines = [
56
- ...serviceEndpoints(this, {
57
- services: "services[types[ntp] && priority>=100]",
58
- endpoints: e =>
59
- e.type === "ntp" &&
60
- !isLinkLocal(e.address) &&
61
- e.service.host !== host &&
62
- e.networkInterface &&
63
- e.networkInterface.kind !== "loopback",
64
- select: endpoint => {
65
- const options = [
66
- endpoint.isPool ? "pool" : "server",
67
- endpoint.address,
68
- "iburst"
69
- ];
70
- if (endpoint.isPool) {
71
- options.push("maxsources 2");
72
- }
73
- if (endpoint.priority > 300 && endpoint.family === FAMILY_IPV4) {
74
- options.push("prefer");
75
- }
76
- return options.join(" ");
77
- }
78
- }),
87
+ this.servers.flat().map(chronyServer),
88
+ this.peers
89
+ .flat()
90
+ .filter(endpoint => endpoint.host !== host)
91
+ .map(chronyServer),
79
92
  `mailonchange ${this.administratorEmail} 0.5`,
80
93
  "local stratum 10 orphan",
81
94
  "leapsectz right/UTC",