pmcf 2.69.0 → 2.70.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": "2.69.0",
3
+ "version": "2.70.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -12,19 +12,19 @@
12
12
  "description": "Poor mans configuration management",
13
13
  "keywords": [
14
14
  "bind",
15
+ "chrony",
15
16
  "config",
16
17
  "config management",
17
18
  "dhcp",
18
19
  "dns",
20
+ "influxdb",
19
21
  "iwd",
20
22
  "kea",
21
23
  "keepalived",
24
+ "mosquitto",
22
25
  "openldap",
23
- "systemd",
24
- "chrony",
25
- "influxdb",
26
26
  "openldap",
27
- "mosquitto"
27
+ "systemd"
28
28
  ],
29
29
  "contributors": [
30
30
  {
@@ -57,7 +57,7 @@
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/node": "^22.15.30",
60
- "ava": "^6.3.0",
60
+ "ava": "^6.4.0",
61
61
  "c8": "^10.1.3",
62
62
  "documentation": "^14.0.3",
63
63
  "semantic-release": "^24.2.5",
package/src/endpoint.mjs CHANGED
@@ -38,6 +38,10 @@ class PortEndpoint extends BaseEndpoint {
38
38
  return this._port ?? this.service.port;
39
39
  }
40
40
 
41
+ get socketAddress() {
42
+ return `${this.address}:${this.port}`;
43
+ }
44
+
41
45
  toString() {
42
46
  return `${this.type}:${this.family}/${this.address}[${this.port}]`;
43
47
  }
@@ -49,9 +53,10 @@ export class Endpoint extends PortEndpoint {
49
53
  this.networkAddress = networkAddress;
50
54
  }
51
55
 
56
+ /*
52
57
  get socketAddress() {
53
58
  return `${this.address}:${this.port}`;
54
- }
59
+ }*/
55
60
 
56
61
  get hostName() {
57
62
  return this.networkAddress.networkInterface.hostName;
@@ -84,13 +89,16 @@ export class DomainNameEndpoint extends PortEndpoint {
84
89
  return {};
85
90
  }
86
91
 
92
+ get family() {
93
+ return "dns"; // TODO
94
+ }
95
+
87
96
  get address() {
88
97
  return this.domainName;
89
98
  }
90
99
 
91
- get isPool()
92
- {
93
- return this.domainName.indexOf('pool') >= 0; // TODO
100
+ get isPool() {
101
+ return this.domainName.indexOf("pool") >= 0; // TODO
94
102
  }
95
103
  }
96
104
 
@@ -66,3 +66,7 @@ export function addresses(sources, options) {
66
66
  export function cidrAddresses(networkAddresses) {
67
67
  return [...networkAddresses].map(na => na.cidrAddress);
68
68
  }
69
+
70
+ export function sortByFamilyAndAddress(a, b) {
71
+ return a.family.localeCompare(b.family) ?? a.address.localeCompare(b.address);
72
+ }
@@ -2,44 +2,116 @@ export const ServiceTypes = {
2
2
  "pacman-repo": {
3
3
  extends: ["https"]
4
4
  },
5
- mqtt: { endpoints: [{ protocol: "tcp", port: 1883, tls: false }] },
6
- "secure-mqtt": { endpoints: [{ protocol: "tcp", port: 8883, tls: true }] },
7
- ntp: { endpoints: [{ protocol: "udp", port: 123, tls: false }] },
8
- dns: { endpoints: [{ protocol: "udp", port: 53, tls: false }] },
9
- ldap: { endpoints: [{ protocol: "tcp", port: 389, tls: false }] },
10
- ldaps: { endpoints: [{ protocol: "tcp", port: 636, tls: true }] },
11
- http: { endpoints: [{ protocol: "tcp", port: 80, tls: false }] },
5
+ mqtt: {
6
+ endpoints: [
7
+ { family: "IPv4", protocol: "tcp", port: 1883, tls: false },
8
+ { family: "IPv6", protocol: "tcp", port: 1883, tls: false }
9
+ ]
10
+ },
11
+ "secure-mqtt": {
12
+ endpoints: [
13
+ { family: "IPv4", protocol: "tcp", port: 8883, tls: true },
14
+ { family: "IPv6", protocol: "tcp", port: 8883, tls: true }
15
+ ]
16
+ },
17
+ ntp: {
18
+ endpoints: [
19
+ { family: "IPv4", protocol: "udp", port: 123, tls: false },
20
+ { family: "IPv6", protocol: "udp", port: 123, tls: false }
21
+ ]
22
+ },
23
+ dns: {
24
+ endpoints: [
25
+ { family: "IPv4", protocol: "udp", port: 53, tls: false },
26
+ { family: "IPv6", protocol: "udp", port: 53, tls: false }
27
+ ]
28
+ },
29
+ ldap: {
30
+ endpoints: [
31
+ { family: "IPv4", protocol: "tcp", port: 389, tls: false },
32
+ { family: "IPv6", protocol: "tcp", port: 389, tls: false }
33
+ ]
34
+ },
35
+ ldaps: {
36
+ endpoints: [
37
+ { family: "IPv4", protocol: "tcp", port: 636, tls: true },
38
+ { family: "IPv6", protocol: "tcp", port: 636, tls: true }
39
+ ]
40
+ },
41
+ http: {
42
+ endpoints: [
43
+ { family: "IPv4", protocol: "tcp", port: 80, tls: false },
44
+ { family: "IPv6", protocol: "tcp", port: 80, tls: false }
45
+ ]
46
+ },
12
47
  https: {
13
- endpoints: [{ protocol: "tcp", port: 443, tls: true }],
48
+ endpoints: [
49
+ { family: "IPv4", protocol: "tcp", port: 443, tls: true },
50
+ { family: "IPv6", protocol: "tcp", port: 443, tls: true }
51
+ ],
14
52
  dnsRecord: { type: "HTTPS", parameters: { alpn: "h2" } }
15
53
  },
16
54
  http3: {
17
- endpoints: [{ protocol: "udp", port: 443, tls: false }],
55
+ endpoints: [
56
+ { family: "IPv4", protocol: "udp", port: 443, tls: true },
57
+ { family: "IPv6", protocol: "udp", port: 443, tls: true }
58
+ ],
18
59
  dnsRecord: {
19
60
  type: "HTTPS",
20
61
  parameters: { "no-default-alpn": undefined, alpn: "h3" }
21
62
  }
22
63
  },
23
- rtsp: { endpoints: [{ protocol: "tcp", port: 554, tls: false }] },
64
+ rtsp: {
65
+ endpoints: [
66
+ { family: "IPv4", protocol: "tcp", port: 554, tls: false },
67
+ { family: "IPv6", protocol: "tcp", port: 554, tls: false }
68
+ ]
69
+ },
24
70
  smtp: {
25
- endpoints: [{ protocol: "tcp", port: 25, tls: false }],
71
+ endpoints: [
72
+ { family: "IPv4", protocol: "tcp", port: 25, tls: false },
73
+ { family: "IPv6", protocol: "tcp", port: 25, tls: false }
74
+ ],
26
75
  dnsRecord: { type: "MX" }
27
76
  },
28
- ssh: { endpoints: [{ protocol: "tcp", port: 22, tls: false }] },
29
- imap: { endpoints: [{ protocol: "tcp", port: 143, tls: false }] },
30
- imaps: { endpoints: [{ protocol: "tcp", port: 993, tls: true }] },
31
- dhcp: { endpoints: [{ protocol: "udp", port: 547, tls: false }] },
77
+ ssh: {
78
+ endpoints: [
79
+ { family: "IPv4", protocol: "tcp", port: 22, tls: false },
80
+ { family: "IPv6", protocol: "tcp", port: 22, tls: false }
81
+ ]
82
+ },
83
+ imap: {
84
+ endpoints: [
85
+ { family: "IPv4", protocol: "tcp", port: 143, tls: false },
86
+ { family: "IPv6", protocol: "tcp", port: 143, tls: false }
87
+ ]
88
+ },
89
+ imaps: {
90
+ endpoints: [
91
+ { family: "IPv4", protocol: "tcp", port: 993, tls: true },
92
+ { family: "IPv6", protocol: "tcp", port: 993, tls: true }
93
+ ]
94
+ },
95
+ dhcp: {
96
+ endpoints: [
97
+ { family: "IPv4", protocol: "udp", port: 547, tls: false },
98
+ { family: "IPv6", protocol: "udp", port: 547, tls: false }
99
+ ]
100
+ },
32
101
  "dhcpv6-client": {
33
102
  endpoints: [
34
- { protocol: "tcp", port: 546, tls: false },
35
- { protocol: "udp", port: 546, tls: false }
103
+ { family: "IPv6", protocol: "tcp", port: 546, tls: false },
104
+ { family: "IPv6", protocol: "udp", port: 546, tls: false }
36
105
  ]
37
106
  },
38
- "dhcpv6-server": { endpoints: [{ port: 547, tls: false }] },
107
+ "dhcpv6-server": { endpoints: [{ family: "IPv6", port: 547, tls: false }] },
39
108
  smb: { endpoints: [{ protocol: "tcp", port: 445, tls: false }] },
40
109
  timemachine: {
41
110
  extends: ["smb"],
42
- endpoints: [{ protocol: "tcp", port: 445, tls: false }],
111
+ endpoints: [
112
+ { family: "IPv4", protocol: "tcp", port: 445, tls: false },
113
+ { family: "IPv6", protocol: "tcp", port: 445, tls: false }
114
+ ],
43
115
  dnsRecord: {
44
116
  type: "TXT",
45
117
  parameters: {
@@ -52,26 +124,51 @@ export const ServiceTypes = {
52
124
  }
53
125
  };
54
126
 
127
+ function prepareEndPoints(type, td) {
128
+ if (td.endpoints) {
129
+ td.endpoints.forEach(e => (e.type = type));
130
+ }
131
+ }
132
+
133
+ Object.entries(ServiceTypes).forEach(([type, td]) =>
134
+ prepareEndPoints(type, td)
135
+ );
136
+
55
137
  export function addServiceTypes(st) {
56
- Object.assign(ServiceTypes, st);
138
+ for (const [type, td] of Object.entries(st)) {
139
+ ServiceTypes[type] = td;
140
+ prepareEndPoints(type, td);
141
+
142
+ if (td.services) {
143
+ addServiceTypes(td.services);
144
+ }
145
+ }
57
146
  }
58
147
 
59
148
  export function serviceTypeEndpoints(type) {
60
- let st = ServiceTypes[type];
61
- if (st) {
62
- if (st.extends) {
63
- return st.extends.reduce(
64
- (a, c) => [...a, ...(ServiceTypes[c]?.endpoints || [])],
65
- st.endpoints || []
149
+ let td = ServiceTypes[type];
150
+ if (td) {
151
+ const all = td.services
152
+ ? Object.keys(td.services)
153
+ .map(type => serviceTypeEndpoints(type))
154
+ .flat()
155
+ : [];
156
+
157
+ if (td.extends) {
158
+ all.push(
159
+ td.extends.reduce(
160
+ (a, c) => [...a, ...(ServiceTypes[c]?.endpoints || [])],
161
+ []
162
+ )
66
163
  );
67
164
  }
68
165
 
69
- return st.endpoints;
166
+ if (td.endpoints) {
167
+ all.push(td.endpoints);
168
+ }
169
+
170
+ return all.flat();
70
171
  }
71
172
 
72
- return [
73
- {
74
- tls: false
75
- }
76
- ];
173
+ return [];
77
174
  }
package/src/service.mjs CHANGED
@@ -1,4 +1,11 @@
1
- import { Base, Host, Endpoint, DomainNameEndpoint } from "pmcf";
1
+ import {
2
+ Base,
3
+ Host,
4
+ Endpoint,
5
+ DomainNameEndpoint,
6
+ HTTPEndpoint,
7
+ UnixEndpoint
8
+ } from "pmcf";
2
9
  import { addType } from "./types.mjs";
3
10
  import { asArray } from "./utils.mjs";
4
11
  import { networkAddressProperties } from "./network-support.mjs";
@@ -131,18 +138,59 @@ export class Service extends Base {
131
138
  if (!data) {
132
139
  return [];
133
140
  }
134
- const l = this._port === undefined ? {} : { port: this._port };
135
- let result = [...this.host.networkAddresses()]
136
- .map(na => data.map(d => new Endpoint(this, na, { ...d, ...l })))
137
- .flat();
138
-
139
- if (result.length === 0) {
140
- result = data.map(
141
- d => new DomainNameEndpoint(this, this.domainName, { ...d, ...l })
142
- );
141
+
142
+ const result = [];
143
+
144
+ const domainNames = new Set([undefined]);
145
+
146
+ for (const e of data) {
147
+ switch (e.family) {
148
+ case "unix":
149
+ result.push(new UnixEndpoint(this, e.path, e));
150
+ break;
151
+
152
+ case undefined:
153
+ case "dns":
154
+ case "IPv4":
155
+ case "IPv6":
156
+ const options =
157
+ this._port === undefined ? { ...e } : { ...e, port: this._port };
158
+ delete options.kind;
159
+
160
+ for (const na of this.host.networkAddresses()) {
161
+ if (e.kind && e.kind !== na.networkInterface.kind) {
162
+ continue;
163
+ }
164
+
165
+ if (e.pathname) {
166
+ result.push(new HTTPEndpoint(this, na, options));
167
+ } else {
168
+ if (e.family === na.family) {
169
+ result.push(new Endpoint(this, na, options));
170
+ } else {
171
+ if (!domainNames.has(this.domainName)) {
172
+ domainNames.add(this.domainName);
173
+ result.push(
174
+ new DomainNameEndpoint(this, this.domainName, options)
175
+ );
176
+ }
177
+ }
178
+ }
179
+ }
180
+ break;
181
+ }
143
182
  }
144
183
 
145
- return filter ? result.filter(filter) : result;
184
+ switch (typeof filter) {
185
+ case "string":
186
+ return result.filter(endpoint => endpoint.type === filter);
187
+
188
+ case "undefined":
189
+ return result;
190
+
191
+ default:
192
+ return result.filter(filter);
193
+ }
146
194
  }
147
195
 
148
196
  endpoint(filter) {
@@ -230,6 +278,7 @@ export class Service extends Base {
230
278
  dnsFullName(this.domainName)
231
279
  )
232
280
  );
281
+ break; // TODO only one ?
233
282
  }
234
283
  }
235
284
 
@@ -22,21 +22,6 @@ import { addHook } from "../hooks.mjs";
22
22
 
23
23
  const address_types = ["network", "host", "network_interface"];
24
24
 
25
- const BindServiceTypes = {
26
- "bind-statistics": {
27
- endpoints: [
28
- {
29
- port: 19521,
30
- protocol: "tcp",
31
- tls: false
32
- }
33
- ]
34
- },
35
- rdnc: {
36
- endpoints: [{ type: "rdnc", port: 953, protocol: "tcp", tls: false }]
37
- }
38
- };
39
-
40
25
  const BindServiceTypeDefinition = {
41
26
  name: "bind",
42
27
  specializationOf: ServiceTypeDefinition,
@@ -104,14 +89,34 @@ const BindServiceTypeDefinition = {
104
89
  },
105
90
 
106
91
  service: {
107
- extends: ["dns"]
108
- },
109
- services: BindServiceTypes
92
+ extends: ["dns"],
93
+ services: {
94
+ "bind-statistics": {
95
+ endpoints: [
96
+ {
97
+ family: "IPv4",
98
+ port: 19521,
99
+ protocol: "tcp",
100
+ tls: false,
101
+ kind: "loopback"
102
+ }
103
+ ]
104
+ },
105
+ "bind-rdnc": {
106
+ endpoints: [
107
+ {
108
+ family: "IPv4",
109
+ port: 953,
110
+ protocol: "tcp",
111
+ tls: false,
112
+ kind: "loopback"
113
+ }
114
+ ]
115
+ }
116
+ }
117
+ }
110
118
  };
111
119
 
112
- const rdncEndpoint = BindServiceTypes.rdnc.endpoints[0];
113
- const statisticsEndpoint = BindServiceTypes["bind-statistics"].endpoints[0];
114
-
115
120
  function addressesStatement(prefix, objects, generateEmpty = false) {
116
121
  const body = asArray(objects).map(name => ` ${name};`);
117
122
 
@@ -172,21 +177,6 @@ export class BindService extends ExtraSourceService {
172
177
  return BindServiceTypeDefinition.name;
173
178
  }
174
179
 
175
- endpoints(filter) {
176
- const endpoints = super.endpoints(filter);
177
-
178
- for (const na of this.owner.networkAddresses(
179
- na => na.networkInterface.kind === "loopback"
180
- )) {
181
- endpoints.push(
182
- new Endpoint(this, na, rdncEndpoint),
183
- new Endpoint(this, na, statisticsEndpoint)
184
- );
185
- }
186
-
187
- return filter ? endpoints.filter(filter) : endpoints;
188
- }
189
-
190
180
  get soaUpdates() {
191
181
  return [this.serial, this.refresh, this.retry, this.expire, this.minimum];
192
182
  }
@@ -16,7 +16,29 @@ const ChronyServiceTypeDefinition = {
16
16
  priority: 0.1,
17
17
  properties: {},
18
18
  service: {
19
- extends: ["ntp"]
19
+ extends: ["ntp"],
20
+ services: {
21
+ "chrony-cmd": {
22
+ endpoints: [
23
+ {
24
+ family: "IPv4",
25
+ port: 323,
26
+ protocol: "tcp",
27
+ tls: false
28
+ },
29
+ {
30
+ family: "IPv6",
31
+ port: 323,
32
+ protocol: "tcp",
33
+ tls: false
34
+ },
35
+ {
36
+ family: "unux",
37
+ path: "/var/run/chrony/chronyd.sock"
38
+ }
39
+ ]
40
+ }
41
+ }
20
42
  }
21
43
  };
22
44
 
@@ -14,6 +14,13 @@ const InfluxdbServiceTypeDefinition = {
14
14
  service: {
15
15
  endpoints: [
16
16
  {
17
+ family: "IPv4",
18
+ port: 8086,
19
+ protocol: "tcp",
20
+ tls: false
21
+ },
22
+ {
23
+ family: "IPv6",
17
24
  port: 8086,
18
25
  protocol: "tcp",
19
26
  tls: false
@@ -5,9 +5,6 @@ import {
5
5
  Service,
6
6
  sortDescendingByPriority,
7
7
  ServiceTypeDefinition,
8
- Endpoint,
9
- UnixEndpoint,
10
- HTTPEndpoint,
11
8
  serviceEndpoints,
12
9
  SUBNET_LOCALHOST_IPV4,
13
10
  SUBNET_LOCALHOST_IPV6
@@ -15,55 +12,6 @@ import {
15
12
  import { addType } from "../types.mjs";
16
13
  import { writeLines } from "../utils.mjs";
17
14
 
18
- const ddnsEndpoint = {
19
- type: "kea-ddns",
20
- port: 53001,
21
- protocol: "tcp",
22
- tls: false
23
- };
24
-
25
- const controlAgentEndpoint = {
26
- type: "kea-control-agent",
27
- port: 53002,
28
- pathname: "/",
29
- protocol: "tcp",
30
- tls: false
31
- };
32
-
33
- const ha4Endpoint = {
34
- type: "kea-ha-4",
35
- port: 53003,
36
- pathname: "/",
37
- protocol: "tcp",
38
- tls: false
39
- };
40
-
41
- const ha6Endpoint = {
42
- type: "kea-ha-6",
43
- port: 53004,
44
- pathname: "/",
45
- protocol: "tcp",
46
- tls: false
47
- };
48
-
49
- const control4Endpoint = {
50
- type: "kea-control-dhcp4",
51
- family: "unix",
52
- path: "/run/kea/4-ctrl-socket"
53
- };
54
-
55
- const control6Endpoint = {
56
- type: "kea-control-dhcp6",
57
- family: "unix",
58
- path: "/run/kea/6-ctrl-socket"
59
- };
60
-
61
- const controlDDNSEndpoint = {
62
- type: "kea-control-ddns",
63
- family: "unix",
64
- path: "/run/kea/ddns-ctrl-socket"
65
- };
66
-
67
15
  const KeaServiceTypeDefinition = {
68
16
  name: "kea",
69
17
  specializationOf: ServiceTypeDefinition,
@@ -72,29 +20,76 @@ const KeaServiceTypeDefinition = {
72
20
  priority: 0.1,
73
21
  properties: {},
74
22
  service: {
75
- extends: ["dhcp"]
76
- },
77
- services: {
78
- "kea-ddns": {
79
- endpoints: [ddnsEndpoint]
80
- },
81
- "kea-control-agent": {
82
- endpoints: [controlAgentEndpoint]
83
- },
84
- "kea-ha-4": {
85
- endpoints: [ha4Endpoint]
86
- },
87
- "kea-ha-6": {
88
- endpoints: [ha6Endpoint]
89
- },
90
- "kea-control-dhcp4": {
91
- endpoints: [control4Endpoint]
92
- },
93
- "kea-control-dhcp6": {
94
- endpoints: [control6Endpoint]
95
- },
96
- "kea-control-ddns": {
97
- endpoints: [controlDDNSEndpoint]
23
+ extends: ["dhcp"],
24
+ services: {
25
+ "kea-ddns": {
26
+ endpoints: [
27
+ {
28
+ family: "IPv4",
29
+ port: 53001,
30
+ protocol: "tcp",
31
+ tls: false
32
+ }
33
+ ]
34
+ },
35
+ "kea-control-agent": {
36
+ endpoints: [
37
+ {
38
+ family: "IPv4",
39
+ port: 53002,
40
+ pathname: "/",
41
+ protocol: "tcp",
42
+ tls: false
43
+ }
44
+ ]
45
+ },
46
+ /*
47
+ "kea-ha-4": {
48
+ endpoints: [
49
+ {
50
+ family: "IPv4",
51
+ port: 53003,
52
+ pathname: "/",
53
+ protocol: "tcp",
54
+ tls: false
55
+ }
56
+ ]
57
+ },
58
+ "kea-ha-6": {
59
+ endpoints: [
60
+ {
61
+ family: "IPv6",
62
+ port: 53004,
63
+ pathname: "/",
64
+ protocol: "tcp",
65
+ tls: false
66
+ }
67
+ ]
68
+ },*/
69
+ "kea-control-dhcp4": {
70
+ endpoints: [
71
+ {
72
+ family: "unix",
73
+ path: "/run/kea/4-ctrl-socket"
74
+ }
75
+ ]
76
+ },
77
+ "kea-control-dhcp6": {
78
+ endpoints: [
79
+ {
80
+ family: "unix",
81
+ path: "/run/kea/6-ctrl-socket"
82
+ }
83
+ ]
84
+ },
85
+ "kea-control-ddns": {
86
+ endpoints: [
87
+ {
88
+ family: "unix",
89
+ path: "/run/kea/ddns-ctrl-socket"
90
+ }
91
+ ]
92
+ }
98
93
  }
99
94
  }
100
95
  };
@@ -117,43 +112,11 @@ export class KeaService extends Service {
117
112
  }
118
113
 
119
114
  get type() {
120
- return "dhcp"; //KeaServiceTypeDefinition.name;
121
- }
122
-
123
- endpoints(filter) {
124
- const endpoints = super.endpoints(filter);
125
-
126
- for (const na of this.host.networkAddresses()) {
127
- endpoints.push(new HTTPEndpoint(this, na, controlAgentEndpoint));
128
-
129
- if (fetureHasHTTPEndpoints) {
130
- endpoints.push(
131
- new HTTPEndpoint(
132
- this,
133
- na,
134
- na.family === "IPv4" ? ha4Endpoint : ha6Endpoint
135
- )
136
- );
137
- }
138
-
139
- if (na.networkInterface.kind === "loopback") {
140
- endpoints.push(new Endpoint(this, na, ddnsEndpoint));
141
- }
142
- }
143
-
144
- endpoints.push(
145
- new UnixEndpoint(this, control4Endpoint.path, control4Endpoint),
146
- new UnixEndpoint(this, control6Endpoint.path, control6Endpoint),
147
- new UnixEndpoint(this, controlDDNSEndpoint.path, controlDDNSEndpoint)
148
- );
149
-
150
- return filter ? endpoints.filter(filter) : endpoints;
115
+ return KeaServiceTypeDefinition.name;
151
116
  }
152
117
 
153
118
  async *preparePackages(dir) {
154
- const ctrlAgentEndpoint = this.endpoint(
155
- e => e.type === "kea-control-agent"
156
- );
119
+ const ctrlAgentEndpoint = this.endpoint("kea-control-agent");
157
120
 
158
121
  if (!ctrlAgentEndpoint) {
159
122
  return;
@@ -189,7 +152,7 @@ export class KeaService extends Service {
189
152
  (
190
153
  await Array.fromAsync(
191
154
  network.findServices({
192
- type: "dhcp",
155
+ type: "kea",
193
156
  priority: ">=" + (this.priority < 100 ? this.priority : 100)
194
157
  })
195
158
  )
@@ -197,11 +160,7 @@ export class KeaService extends Service {
197
160
  .sort(sortDescendingByPriority)
198
161
  .map((dhcp, i) => {
199
162
  const ctrlAgentEndpoint = dhcp.endpoint(
200
- e =>
201
- e.type ===
202
- (fetureHasHTTPEndpoints
203
- ? `kea-ha-${family}`
204
- : "kea-control-agent")
163
+ fetureHasHTTPEndpoints ? `kea-ha-${family}` : "kea-control-agent"
205
164
  );
206
165
 
207
166
  if (ctrlAgentEndpoint) {
@@ -232,9 +191,7 @@ export class KeaService extends Service {
232
191
  "interfaces-config": {
233
192
  interfaces: listenInterfaces(`IPv${family}`)
234
193
  },
235
- "control-socket": toUnix(
236
- this.endpoint(e => e.type === `kea-control-dhcp${family}`)
237
- ),
194
+ "control-socket": toUnix(this.endpoint(`kea-control-dhcp${family}`)),
238
195
  "lease-database": {
239
196
  type: "memfile",
240
197
  "lfc-interval": 3600
@@ -313,9 +270,9 @@ export class KeaService extends Service {
313
270
  "http-host": ctrlAgentEndpoint.hostname,
314
271
  "http-port": ctrlAgentEndpoint.port,
315
272
  "control-sockets": {
316
- dhcp4: toUnix(this.endpoint(e => e.type === "kea-control-dhcp4")),
317
- dhcp6: toUnix(this.endpoint(e => e.type === "kea-control-dhcp6")),
318
- d2: toUnix(this.endpoint(e => e.type === "kea-control-ddns"))
273
+ dhcp4: toUnix(this.endpoint("kea-control-dhcp4")),
274
+ dhcp6: toUnix(this.endpoint("kea-control-dhcp6")),
275
+ d2: toUnix(this.endpoint("kea-control-ddns"))
319
276
  },
320
277
  loggers
321
278
  }
@@ -333,7 +290,7 @@ export class KeaService extends Service {
333
290
  };
334
291
  });
335
292
 
336
- const ddnsEndpoint = this.endpoint(e => e.type === "kea-ddns");
293
+ const ddnsEndpoint = this.endpoint("kea-ddns");
337
294
 
338
295
  const subnetPrefixes = new Set(
339
296
  [...this.subnets]
@@ -9,9 +9,15 @@ const SystemdJournalRemoteServiceTypeDefinition = {
9
9
  priority: 0.1,
10
10
  properties: {},
11
11
  services: {
12
- extends: ["http"],
13
12
  endpoints: [
14
13
  {
14
+ family: "IPv4",
15
+ port: 19532,
16
+ protocol: "tcp",
17
+ tls: false
18
+ },
19
+ {
20
+ family: "IPv6",
15
21
  port: 19532,
16
22
  protocol: "tcp",
17
23
  tls: false
@@ -41,7 +41,8 @@ export class SystemdResolvedService extends ExtraSourceService {
41
41
  const options = (priority, limit) => {
42
42
  return {
43
43
  services: { types: "dns", priority },
44
- endpoints: e => e.networkInterface.kind !== "loopback",
44
+ endpoints: e =>
45
+ e.networkInterface.kind !== "loopback" && e.family !== "dns",
45
46
  select: endpoint => endpoint.address,
46
47
  join: " ",
47
48
  limit
@@ -46,7 +46,7 @@ export class SystemdTimesyncdService extends ExtraSourceService {
46
46
  {
47
47
  NTP: serviceEndpoints(this, {
48
48
  services: {
49
- type: "ntp",
49
+ types: "ntp",
50
50
  priority: "[200:399]"
51
51
  },
52
52
  endpoints: endpoint =>
package/src/types.mjs CHANGED
@@ -14,10 +14,6 @@ export function addType(clazz) {
14
14
  addServiceTypes({ [type.name]: type.service });
15
15
  }
16
16
 
17
- if (type.services) {
18
- addServiceTypes(type.services);
19
- }
20
-
21
17
  types[type.name] = type;
22
18
 
23
19
  type.clazz = clazz;
@@ -1,7 +1,6 @@
1
1
  export class Endpoint extends PortEndpoint {
2
2
  constructor(service: any, networkAddress: any, data: any);
3
3
  networkAddress: any;
4
- get socketAddress(): string;
5
4
  get hostName(): any;
6
5
  get domainName(): any;
7
6
  get address(): any;
@@ -12,6 +11,7 @@ export class DomainNameEndpoint extends PortEndpoint {
12
11
  constructor(service: any, domainName: any, data: any);
13
12
  domainName: any;
14
13
  get networkInterface(): {};
14
+ get family(): string;
15
15
  get address(): any;
16
16
  get isPool(): boolean;
17
17
  }
@@ -38,6 +38,7 @@ declare class PortEndpoint extends BaseEndpoint {
38
38
  protocol: any;
39
39
  tls: any;
40
40
  get port(): any;
41
+ get socketAddress(): string;
41
42
  }
42
43
  declare class BaseEndpoint {
43
44
  constructor(service: any, data: any);
@@ -11,6 +11,7 @@ export function addresses(sources: Iterable<Owner | string>, options: {
11
11
  filter: any;
12
12
  }): Iterable<string>;
13
13
  export function cidrAddresses(networkAddresses: any): any[];
14
+ export function sortByFamilyAndAddress(a: any, b: any): any;
14
15
  /**
15
16
  *
16
17
  */
@@ -6,6 +6,7 @@ export const ServiceTypes: {
6
6
  };
7
7
  mqtt: {
8
8
  endpoints: {
9
+ family: string;
9
10
  protocol: string;
10
11
  port: number;
11
12
  tls: boolean;
@@ -13,6 +14,7 @@ export const ServiceTypes: {
13
14
  };
14
15
  "secure-mqtt": {
15
16
  endpoints: {
17
+ family: string;
16
18
  protocol: string;
17
19
  port: number;
18
20
  tls: boolean;
@@ -20,6 +22,7 @@ export const ServiceTypes: {
20
22
  };
21
23
  ntp: {
22
24
  endpoints: {
25
+ family: string;
23
26
  protocol: string;
24
27
  port: number;
25
28
  tls: boolean;
@@ -27,6 +30,7 @@ export const ServiceTypes: {
27
30
  };
28
31
  dns: {
29
32
  endpoints: {
33
+ family: string;
30
34
  protocol: string;
31
35
  port: number;
32
36
  tls: boolean;
@@ -34,6 +38,7 @@ export const ServiceTypes: {
34
38
  };
35
39
  ldap: {
36
40
  endpoints: {
41
+ family: string;
37
42
  protocol: string;
38
43
  port: number;
39
44
  tls: boolean;
@@ -41,6 +46,7 @@ export const ServiceTypes: {
41
46
  };
42
47
  ldaps: {
43
48
  endpoints: {
49
+ family: string;
44
50
  protocol: string;
45
51
  port: number;
46
52
  tls: boolean;
@@ -48,6 +54,7 @@ export const ServiceTypes: {
48
54
  };
49
55
  http: {
50
56
  endpoints: {
57
+ family: string;
51
58
  protocol: string;
52
59
  port: number;
53
60
  tls: boolean;
@@ -55,6 +62,7 @@ export const ServiceTypes: {
55
62
  };
56
63
  https: {
57
64
  endpoints: {
65
+ family: string;
58
66
  protocol: string;
59
67
  port: number;
60
68
  tls: boolean;
@@ -68,6 +76,7 @@ export const ServiceTypes: {
68
76
  };
69
77
  http3: {
70
78
  endpoints: {
79
+ family: string;
71
80
  protocol: string;
72
81
  port: number;
73
82
  tls: boolean;
@@ -82,6 +91,7 @@ export const ServiceTypes: {
82
91
  };
83
92
  rtsp: {
84
93
  endpoints: {
94
+ family: string;
85
95
  protocol: string;
86
96
  port: number;
87
97
  tls: boolean;
@@ -89,6 +99,7 @@ export const ServiceTypes: {
89
99
  };
90
100
  smtp: {
91
101
  endpoints: {
102
+ family: string;
92
103
  protocol: string;
93
104
  port: number;
94
105
  tls: boolean;
@@ -99,6 +110,7 @@ export const ServiceTypes: {
99
110
  };
100
111
  ssh: {
101
112
  endpoints: {
113
+ family: string;
102
114
  protocol: string;
103
115
  port: number;
104
116
  tls: boolean;
@@ -106,6 +118,7 @@ export const ServiceTypes: {
106
118
  };
107
119
  imap: {
108
120
  endpoints: {
121
+ family: string;
109
122
  protocol: string;
110
123
  port: number;
111
124
  tls: boolean;
@@ -113,6 +126,7 @@ export const ServiceTypes: {
113
126
  };
114
127
  imaps: {
115
128
  endpoints: {
129
+ family: string;
116
130
  protocol: string;
117
131
  port: number;
118
132
  tls: boolean;
@@ -120,6 +134,7 @@ export const ServiceTypes: {
120
134
  };
121
135
  dhcp: {
122
136
  endpoints: {
137
+ family: string;
123
138
  protocol: string;
124
139
  port: number;
125
140
  tls: boolean;
@@ -127,6 +142,7 @@ export const ServiceTypes: {
127
142
  };
128
143
  "dhcpv6-client": {
129
144
  endpoints: {
145
+ family: string;
130
146
  protocol: string;
131
147
  port: number;
132
148
  tls: boolean;
@@ -134,6 +150,7 @@ export const ServiceTypes: {
134
150
  };
135
151
  "dhcpv6-server": {
136
152
  endpoints: {
153
+ family: string;
137
154
  port: number;
138
155
  tls: boolean;
139
156
  }[];
@@ -148,6 +165,7 @@ export const ServiceTypes: {
148
165
  timemachine: {
149
166
  extends: string[];
150
167
  endpoints: {
168
+ family: string;
151
169
  protocol: string;
152
170
  port: number;
153
171
  tls: boolean;
@@ -334,8 +334,8 @@ export class Service extends Base {
334
334
  get networks(): Set<any>;
335
335
  get subnets(): Set<any>;
336
336
  get serviceTypeEndpoints(): any;
337
- endpoints(filter: any): any[];
338
- endpoint(filter: any): any;
337
+ endpoints(filter: any): (UnixEndpoint | HTTPEndpoint | Endpoint | DomainNameEndpoint)[];
338
+ endpoint(filter: any): UnixEndpoint | HTTPEndpoint | Endpoint | DomainNameEndpoint;
339
339
  address(options?: {
340
340
  endpoints: (e: any) => boolean;
341
341
  select: (e: any) => any;
@@ -363,3 +363,7 @@ export function sortAscendingByPriority(a: any, b: any): number;
363
363
  export function sortDescendingByPriority(a: any, b: any): number;
364
364
  import { Base } from "pmcf";
365
365
  import { Host } from "pmcf";
366
+ import { UnixEndpoint } from "pmcf";
367
+ import { HTTPEndpoint } from "pmcf";
368
+ import { Endpoint } from "pmcf";
369
+ import { DomainNameEndpoint } from "pmcf";
@@ -362,22 +362,25 @@ export class BindService extends ExtraSourceService {
362
362
  };
363
363
  service: {
364
364
  extends: string[];
365
- };
366
- services: {
367
- "bind-statistics": {
368
- endpoints: {
369
- port: number;
370
- protocol: string;
371
- tls: boolean;
372
- }[];
373
- };
374
- rdnc: {
375
- endpoints: {
376
- type: string;
377
- port: number;
378
- protocol: string;
379
- tls: boolean;
380
- }[];
365
+ services: {
366
+ "bind-statistics": {
367
+ endpoints: {
368
+ family: string;
369
+ port: number;
370
+ protocol: string;
371
+ tls: boolean;
372
+ kind: string;
373
+ }[];
374
+ };
375
+ "bind-rdnc": {
376
+ endpoints: {
377
+ family: string;
378
+ port: number;
379
+ protocol: string;
380
+ tls: boolean;
381
+ kind: string;
382
+ }[];
383
+ };
381
384
  };
382
385
  };
383
386
  };
@@ -266,6 +266,23 @@ export class ChronyService extends ExtraSourceService {
266
266
  properties: {};
267
267
  service: {
268
268
  extends: string[];
269
+ services: {
270
+ "chrony-cmd": {
271
+ endpoints: ({
272
+ family: string;
273
+ port: number;
274
+ protocol: string;
275
+ tls: boolean;
276
+ path?: undefined;
277
+ } | {
278
+ family: string;
279
+ path: string;
280
+ port?: undefined;
281
+ protocol?: undefined;
282
+ tls?: undefined;
283
+ })[];
284
+ };
285
+ };
269
286
  };
270
287
  };
271
288
  preparePackages(dir: any): AsyncGenerator<{
@@ -254,6 +254,7 @@ export class InfluxdbService extends Service {
254
254
  properties: {};
255
255
  service: {
256
256
  endpoints: {
257
+ family: string;
257
258
  port: number;
258
259
  protocol: string;
259
260
  tls: boolean;
@@ -255,63 +255,42 @@ export class KeaService extends Service {
255
255
  properties: {};
256
256
  service: {
257
257
  extends: string[];
258
- };
259
- services: {
260
- "kea-ddns": {
261
- endpoints: {
262
- type: string;
263
- port: number;
264
- protocol: string;
265
- tls: boolean;
266
- }[];
267
- };
268
- "kea-control-agent": {
269
- endpoints: {
270
- type: string;
271
- port: number;
272
- pathname: string;
273
- protocol: string;
274
- tls: boolean;
275
- }[];
276
- };
277
- "kea-ha-4": {
278
- endpoints: {
279
- type: string;
280
- port: number;
281
- pathname: string;
282
- protocol: string;
283
- tls: boolean;
284
- }[];
285
- };
286
- "kea-ha-6": {
287
- endpoints: {
288
- type: string;
289
- port: number;
290
- pathname: string;
291
- protocol: string;
292
- tls: boolean;
293
- }[];
294
- };
295
- "kea-control-dhcp4": {
296
- endpoints: {
297
- type: string;
298
- family: string;
299
- path: string;
300
- }[];
301
- };
302
- "kea-control-dhcp6": {
303
- endpoints: {
304
- type: string;
305
- family: string;
306
- path: string;
307
- }[];
308
- };
309
- "kea-control-ddns": {
310
- endpoints: {
311
- type: string;
312
- family: string;
313
- path: string;
314
- }[];
258
+ services: {
259
+ "kea-ddns": {
260
+ endpoints: {
261
+ family: string;
262
+ port: number;
263
+ protocol: string;
264
+ tls: boolean;
265
+ }[];
266
+ };
267
+ "kea-control-agent": {
268
+ endpoints: {
269
+ family: string;
270
+ port: number;
271
+ pathname: string;
272
+ protocol: string;
273
+ tls: boolean;
274
+ }[];
275
+ };
276
+ "kea-control-dhcp4": {
277
+ endpoints: {
278
+ family: string;
279
+ path: string;
280
+ }[];
281
+ };
282
+ "kea-control-dhcp6": {
283
+ endpoints: {
284
+ family: string;
285
+ path: string;
286
+ }[];
287
+ };
288
+ "kea-control-ddns": {
289
+ endpoints: {
290
+ family: string;
291
+ path: string;
292
+ }[];
293
+ };
315
294
  };
316
295
  };
317
296
  };
@@ -253,8 +253,8 @@ export class SystemdJournalRemoteService extends Service {
253
253
  priority: number;
254
254
  properties: {};
255
255
  services: {
256
- extends: string[];
257
256
  endpoints: {
257
+ family: string;
258
258
  port: number;
259
259
  protocol: string;
260
260
  tls: boolean;