pmcf 6.33.5 → 6.34.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": "6.33.5",
3
+ "version": "6.34.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -110,11 +110,7 @@ export class CoreService extends Base {
110
110
  }
111
111
 
112
112
  endpoints(filter) {
113
- const data = serviceTypeEndpoints(ServiceTypes[this.type]);
114
- if (!data) {
115
- return [];
116
- }
117
-
113
+ const data = serviceTypeEndpoints(ServiceTypes[this.type], true);
118
114
  const result = [];
119
115
 
120
116
  const domainNames = new Set([undefined]);
package/src/endpoint.mjs CHANGED
@@ -1,11 +1,12 @@
1
1
  import { getAttribute, string_attribute, url_attribute } from "pacc";
2
- import { FAMILY_IPV6 } from "ip-utilties";
2
+ import { FAMILY_IPV4, FAMILY_IPV6 } from "ip-utilties";
3
3
  import { addType } from "pmcf";
4
4
  import { CoreService } from "./core-service.mjs";
5
5
  import { family_attribute, endpointAttributes } from "./common-attributes.mjs";
6
6
 
7
7
  export const FAMILY_UNIX = "unix";
8
8
  export const FAMILY_DNS = "dns";
9
+ export const FAMILY_IPV4_IPV6 = new Set([FAMILY_IPV4, FAMILY_IPV6]);
9
10
 
10
11
  class BaseEndpoint {
11
12
  static name = "base_endpoint";
@@ -1,5 +1,6 @@
1
1
  import { FAMILY_IPV4, FAMILY_IPV6 } from "ip-utilties";
2
- import { FAMILY_UNIX } from "./endpoint.mjs";
2
+ import { FAMILY_UNIX, FAMILY_IPV4_IPV6 } from "./endpoint.mjs";
3
+ import { asArray } from "./utils.mjs";
3
4
 
4
5
  export const ServiceTypes = {
5
6
  "alpm-repo": {
@@ -13,25 +14,13 @@ export const ServiceTypes = {
13
14
  endpoints: [
14
15
  {
15
16
  protocol: "udp",
16
- family: FAMILY_IPV4,
17
- port: 514,
18
- tls: false
19
- },
20
- {
21
- protocol: "udp",
22
- family: FAMILY_IPV6,
23
- port: 514,
24
- tls: false
25
- },
26
- {
27
- protocol: "tcp",
28
- family: FAMILY_IPV4,
17
+ family: FAMILY_IPV4_IPV6,
29
18
  port: 514,
30
19
  tls: false
31
20
  },
32
21
  {
33
22
  protocol: "tcp",
34
- family: FAMILY_IPV6,
23
+ family: FAMILY_IPV4_IPV6,
35
24
  port: 514,
36
25
  tls: false
37
26
  }
@@ -39,53 +28,39 @@ export const ServiceTypes = {
39
28
  },
40
29
  mqtt: {
41
30
  endpoints: [
42
- { family: FAMILY_IPV4, protocol: "tcp", port: 1883, tls: false },
43
- { family: FAMILY_IPV6, protocol: "tcp", port: 1883, tls: false }
31
+ { family: FAMILY_IPV4_IPV6, protocol: "tcp", port: 1883, tls: false }
44
32
  ]
45
33
  },
46
34
  "secure-mqtt": {
47
35
  endpoints: [
48
- { family: FAMILY_IPV4, protocol: "tcp", port: 8883, tls: true },
49
- { family: FAMILY_IPV6, protocol: "tcp", port: 8883, tls: true }
36
+ { family: FAMILY_IPV4_IPV6, protocol: "tcp", port: 8883, tls: true }
50
37
  ]
51
38
  },
52
39
  ntp: {
53
40
  endpoints: [
54
- { family: FAMILY_IPV4, protocol: "udp", port: 123, tls: false },
55
- { family: FAMILY_IPV6, protocol: "udp", port: 123, tls: false }
41
+ { family: FAMILY_IPV4_IPV6, protocol: "udp", port: 123, tls: false }
56
42
  ]
57
43
  },
58
44
  dns: {
59
45
  endpoints: [
60
- { family: FAMILY_IPV4, protocol: "udp", port: 53, tls: false },
61
- { family: FAMILY_IPV6, protocol: "udp", port: 53, tls: false }
46
+ { family: FAMILY_IPV4_IPV6, protocol: "udp", port: 53, tls: false }
62
47
  ]
63
48
  },
64
49
  mdns: {
65
50
  endpoints: [
66
- { family: FAMILY_IPV4, protocol: "udp", port: 5353, tls: false },
67
- { family: FAMILY_IPV6, protocol: "udp", port: 5353, tls: false }
51
+ { family: FAMILY_IPV4_IPV6, protocol: "udp", port: 5353, tls: false }
68
52
  ]
69
53
  },
70
54
  llmnr: {
71
55
  endpoints: [
72
- { family: FAMILY_IPV4, protocol: "udp", port: 5355, tls: false },
73
- { family: FAMILY_IPV4, protocol: "tcp", port: 5355, tls: false },
74
- { family: FAMILY_IPV6, protocol: "udp", port: 5355, tls: false },
75
- { family: FAMILY_IPV6, protocol: "tcp", port: 5355, tls: false }
56
+ { family: FAMILY_IPV4_IPV6, protocol: "udp", port: 5355, tls: false },
57
+ { family: FAMILY_IPV4_IPV6, protocol: "tcp", port: 5355, tls: false }
76
58
  ]
77
59
  },
78
60
  ldap: {
79
61
  endpoints: [
80
62
  {
81
- family: FAMILY_IPV4,
82
- scheme: "ldap",
83
- protocol: "tcp",
84
- port: 389,
85
- tls: false
86
- },
87
- {
88
- family: FAMILY_IPV6,
63
+ family: FAMILY_IPV4_IPV6,
89
64
  scheme: "ldap",
90
65
  protocol: "tcp",
91
66
  port: 389,
@@ -96,14 +71,7 @@ export const ServiceTypes = {
96
71
  ldaps: {
97
72
  endpoints: [
98
73
  {
99
- family: FAMILY_IPV4,
100
- scheme: "ldaps",
101
- protocol: "tcp",
102
- port: 636,
103
- tls: true
104
- },
105
- {
106
- family: FAMILY_IPV6,
74
+ family: FAMILY_IPV4_IPV6,
107
75
  scheme: "ldaps",
108
76
  protocol: "tcp",
109
77
  port: 636,
@@ -117,14 +85,7 @@ export const ServiceTypes = {
117
85
  http: {
118
86
  endpoints: [
119
87
  {
120
- family: FAMILY_IPV4,
121
- scheme: "http",
122
- protocol: "tcp",
123
- port: 80,
124
- tls: false
125
- },
126
- {
127
- family: FAMILY_IPV6,
88
+ family: FAMILY_IPV4_IPV6,
128
89
  scheme: "http",
129
90
  protocol: "tcp",
130
91
  port: 80,
@@ -135,14 +96,7 @@ export const ServiceTypes = {
135
96
  https: {
136
97
  endpoints: [
137
98
  {
138
- family: FAMILY_IPV4,
139
- scheme: "https",
140
- protocol: "tcp",
141
- port: 443,
142
- tls: true
143
- },
144
- {
145
- family: FAMILY_IPV6,
99
+ family: FAMILY_IPV4_IPV6,
146
100
  scheme: "https",
147
101
  protocol: "tcp",
148
102
  port: 443,
@@ -154,14 +108,7 @@ export const ServiceTypes = {
154
108
  http3: {
155
109
  endpoints: [
156
110
  {
157
- family: FAMILY_IPV4,
158
- scheme: "https",
159
- protocol: "udp",
160
- port: 443,
161
- tls: true
162
- },
163
- {
164
- family: FAMILY_IPV6,
111
+ family: FAMILY_IPV4_IPV6,
165
112
  scheme: "https",
166
113
  protocol: "udp",
167
114
  port: 443,
@@ -175,64 +122,54 @@ export const ServiceTypes = {
175
122
  },
176
123
  rtsp: {
177
124
  endpoints: [
178
- { family: FAMILY_IPV4, protocol: "tcp", port: 554, tls: false },
179
- { family: FAMILY_IPV6, protocol: "tcp", port: 554, tls: false }
125
+ { family: FAMILY_IPV4_IPV6, protocol: "tcp", port: 554, tls: false }
180
126
  ]
181
127
  },
182
128
  smtp: {
183
129
  endpoints: [
184
- { family: FAMILY_IPV4, protocol: "tcp", port: 25, tls: false },
185
- { family: FAMILY_IPV6, protocol: "tcp", port: 25, tls: false }
130
+ { family: FAMILY_IPV4_IPV6, protocol: "tcp", port: 25, tls: false }
186
131
  ],
187
132
  dnsRecord: { type: "MX" }
188
133
  },
189
134
  smtps: {
190
135
  endpoints: [
191
- { family: FAMILY_IPV4, protocol: "tcp", port: 465, tls: true },
192
- { family: FAMILY_IPV6, protocol: "tcp", port: 465, tls: true }
136
+ { family: FAMILY_IPV4_IPV6, protocol: "tcp", port: 465, tls: true }
193
137
  ],
194
138
  dnsRecord: { type: "MX" }
195
139
  },
196
140
  submission: {
197
141
  endpoints: [
198
- { family: FAMILY_IPV4, protocol: "tcp", port: 587, tls: false },
199
- { family: FAMILY_IPV6, protocol: "tcp", port: 587, tls: false }
142
+ { family: FAMILY_IPV4_IPV6, protocol: "tcp", port: 587, tls: false }
200
143
  ]
201
144
  },
202
145
  lmtp: {
203
146
  endpoints: [
204
- { family: FAMILY_IPV4, protocol: "tcp", port: 24, tls: false },
205
- { family: FAMILY_IPV6, protocol: "tcp", port: 24, tls: false }
147
+ { family: FAMILY_IPV4_IPV6, protocol: "tcp", port: 24, tls: false }
206
148
  ]
207
149
  },
208
150
  ssh: {
209
151
  endpoints: [
210
- { family: FAMILY_IPV4, protocol: "tcp", port: 22, tls: false },
211
- { family: FAMILY_IPV6, protocol: "tcp", port: 22, tls: false }
152
+ { family: FAMILY_IPV4_IPV6, protocol: "tcp", port: 22, tls: false }
212
153
  ]
213
154
  },
214
155
  imap: {
215
156
  endpoints: [
216
- { family: FAMILY_IPV4, protocol: "tcp", port: 143, tls: false },
217
- { family: FAMILY_IPV6, protocol: "tcp", port: 143, tls: false }
157
+ { family: FAMILY_IPV4_IPV6, protocol: "tcp", port: 143, tls: false }
218
158
  ]
219
159
  },
220
160
  imaps: {
221
161
  endpoints: [
222
- { family: FAMILY_IPV4, protocol: "tcp", port: 993, tls: true },
223
- { family: FAMILY_IPV6, protocol: "tcp", port: 993, tls: true }
162
+ { family: FAMILY_IPV4_IPV6, protocol: "tcp", port: 993, tls: true }
224
163
  ]
225
164
  },
226
165
  dhcp: {
227
166
  endpoints: [
228
- { family: FAMILY_IPV4, protocol: "udp", port: 547, tls: false },
229
- { family: FAMILY_IPV6, protocol: "udp", port: 547, tls: false }
167
+ { family: FAMILY_IPV4_IPV6, protocol: "udp", port: 547, tls: false }
230
168
  ]
231
169
  },
232
170
  "dhcpv6-client": {
233
171
  endpoints: [
234
- { family: FAMILY_IPV6, protocol: "tcp", port: 546, tls: false },
235
- { family: FAMILY_IPV6, protocol: "udp", port: 546, tls: false }
172
+ { family: FAMILY_IPV4_IPV6, protocol: "tcp", port: 546, tls: false }
236
173
  ]
237
174
  },
238
175
  "dhcpv6-server": {
@@ -240,8 +177,7 @@ export const ServiceTypes = {
240
177
  },
241
178
  smb: {
242
179
  endpoints: [
243
- { family: FAMILY_IPV4, protocol: "tcp", port: 445, tls: false },
244
- { family: FAMILY_IPV6, protocol: "tcp", port: 445, tls: false }
180
+ { family: FAMILY_IPV4_IPV6, protocol: "tcp", port: 445, tls: false }
245
181
  ]
246
182
  },
247
183
  nginx: {
@@ -262,15 +198,13 @@ export const ServiceTypes = {
262
198
  pcp: {
263
199
  // rfc6887
264
200
  endpoints: [
265
- { family: FAMILY_IPV4, protocol: "udp", port: 5351, tls: false },
266
- { family: FAMILY_IPV6, protocol: "udp", port: 5351, tls: false }
201
+ { family: FAMILY_IPV4_IPV6, protocol: "udp", port: 5351, tls: false }
267
202
  ]
268
203
  },
269
204
  "pcp-multicast": {
270
205
  // rfc6887
271
206
  endpoints: [
272
- { family: FAMILY_IPV4, protocol: "udp", port: 5350, tls: false },
273
- { family: FAMILY_IPV6, protocol: "udp", port: 5350, tls: false }
207
+ { family: FAMILY_IPV4_IPV6, protocol: "udp", port: 5350, tls: false }
274
208
  ]
275
209
  }
276
210
  };
@@ -293,11 +227,11 @@ export function addServiceType(type, name) {
293
227
  }
294
228
 
295
229
  if (type.services) {
296
- Object.entries(type.services).forEach(([name, type]) =>
230
+ type.services = Object.entries(type.services).map(([name, type]) =>
297
231
  addServiceType(type, name)
298
232
  );
299
233
  } else {
300
- type.services = {};
234
+ type.services = [];
301
235
  }
302
236
 
303
237
  if (type.extends) {
@@ -324,23 +258,25 @@ export function serviceTypes(type) {
324
258
  return new Set();
325
259
  }
326
260
 
327
- export function serviceTypeEndpoints(type) {
261
+ export function serviceTypeEndpoints(type, bundeledToo) {
328
262
  if (type) {
329
- const all = type.services
330
- ? Object.values(type.services)
331
- .map(type => serviceTypeEndpoints(type))
332
- .flat()
333
- : [];
334
-
335
- if (type.extends) {
336
- all.push(type.extends.reduce((a, c) => [...a, ...c?.endpoints], []));
337
- }
338
-
339
- if (type.endpoints) {
340
- all.push(type.endpoints);
341
- }
263
+ const aggregator = (acc, type) => {
264
+ acc.push(...serviceTypeEndpoints(type, bundeledToo));
265
+ return acc;
266
+ };
342
267
 
343
- return all.flat();
268
+ return type.extends.reduce(
269
+ aggregator,
270
+ type.endpoints.reduce(
271
+ (acc, ep) => {
272
+ for (const family of asArray(ep.family)) {
273
+ acc.push({ ...ep, family });
274
+ }
275
+ return acc;
276
+ },
277
+ bundeledToo ? type.services.reduce(aggregator, []) : []
278
+ )
279
+ );
344
280
  }
345
281
 
346
282
  return [];
@@ -30,7 +30,8 @@ import {
30
30
  Endpoint,
31
31
  addresses,
32
32
  networkAddressType,
33
- addType
33
+ addType,
34
+ FAMILY_IPV4_IPV6
34
35
  } from "pmcf";
35
36
  import { yesno, writeLines, asArray } from "../utils.mjs";
36
37
  import {
@@ -739,18 +740,10 @@ export class bind extends CoreService {
739
740
  systemGroupName: "named",
740
741
  services: {
741
742
  "bind-statistics": {
742
- // extends: ["http"],
743
+ // extends: ["http"],
743
744
  endpoints: [
744
745
  {
745
- family: FAMILY_IPV4,
746
- port: 19521,
747
- protocol: "tcp",
748
- pathname: "/",
749
- tls: false,
750
- kind: "loopback"
751
- },
752
- {
753
- family: FAMILY_IPV6,
746
+ family: FAMILY_IPV4_IPV6,
754
747
  port: 19521,
755
748
  protocol: "tcp",
756
749
  pathname: "/",
@@ -762,7 +755,7 @@ export class bind extends CoreService {
762
755
  "bind-rndc": {
763
756
  endpoints: [
764
757
  {
765
- family: FAMILY_IPV4,
758
+ family: FAMILY_IPV4_IPV6,
766
759
  port: 953,
767
760
  protocol: "tcp",
768
761
  tls: false,
@@ -1,7 +1,13 @@
1
1
  import { join } from "node:path";
2
- import { FAMILY_IPV4, FAMILY_IPV6, isLinkLocal } from "ip-utilties";
2
+ import { FAMILY_IPV4, isLinkLocal } from "ip-utilties";
3
3
  import { FileContentProvider } from "npm-pkgbuild";
4
- import { serviceEndpoints, addType, ExtraSourceService, FAMILY_UNIX } from "pmcf";
4
+ import {
5
+ serviceEndpoints,
6
+ addType,
7
+ ExtraSourceService,
8
+ FAMILY_UNIX,
9
+ FAMILY_IPV4_IPV6
10
+ } from "pmcf";
5
11
  import { writeLines } from "../utils.mjs";
6
12
 
7
13
  export class chrony extends ExtraSourceService {
@@ -12,13 +18,7 @@ export class chrony extends ExtraSourceService {
12
18
  "chrony-cmd": {
13
19
  endpoints: [
14
20
  {
15
- family: FAMILY_IPV4,
16
- port: 323,
17
- protocol: "tcp",
18
- tls: false
19
- },
20
- {
21
- family: FAMILY_IPV6,
21
+ family: FAMILY_IPV4_IPV6,
22
22
  port: 323,
23
23
  protocol: "tcp",
24
24
  tls: false
@@ -1,9 +1,8 @@
1
1
  import { join } from "node:path";
2
2
  import { stringify } from "yaml";
3
- import { FAMILY_IPV4, FAMILY_IPV6 } from "ip-utilties";
4
3
  import { FileContentProvider } from "npm-pkgbuild";
5
4
  import { boolean_attribute_writable_true } from "pacc";
6
- import { CoreService, addType } from "pmcf";
5
+ import { CoreService, addType, FAMILY_IPV4_IPV6 } from "pmcf";
7
6
  import { writeLines, filterConfigurable } from "../utils.mjs";
8
7
 
9
8
  export class influxdb extends CoreService {
@@ -18,14 +17,7 @@ export class influxdb extends CoreService {
18
17
  static service = {
19
18
  endpoints: [
20
19
  {
21
- family: FAMILY_IPV4,
22
- port: 8086,
23
- protocol: "tcp",
24
- tls: false,
25
- pathname: "/"
26
- },
27
- {
28
- family: FAMILY_IPV6,
20
+ family: FAMILY_IPV4_IPV6,
29
21
  port: 8086,
30
22
  protocol: "tcp",
31
23
  tls: false,
@@ -70,17 +70,6 @@ export class kea extends CoreService {
70
70
  }
71
71
  ]
72
72
  },
73
- /*"kea-control-agent": {
74
- endpoints: [
75
- {
76
- family: FAMILY_IPV4,
77
- port: 53002,
78
- pathname: "/",
79
- protocol: "tcp",
80
- tls: false
81
- }
82
- ]
83
- },*/
84
73
  "kea-ha-4": {
85
74
  endpoints: [
86
75
  {
@@ -1,11 +1,10 @@
1
- import { FAMILY_IPV4, FAMILY_IPV6 } from "ip-utilties";
2
1
  import {
3
2
  string_attribute_writable,
4
3
  string_collection_attribute_writable,
5
4
  boolean_attribute_writable,
6
5
  integer_attribute_writable
7
6
  } from "pacc";
8
- import { CoreService, addType } from "pmcf";
7
+ import { CoreService, addType, FAMILY_IPV4_IPV6 } from "pmcf";
9
8
  import { filterConfigurable, sectionLines } from "../utils.mjs";
10
9
 
11
10
  /**
@@ -76,14 +75,7 @@ export class SystemdJournalRemoteService extends CoreService {
76
75
  //extends: ["http"],
77
76
  endpoints: [
78
77
  {
79
- family: FAMILY_IPV4,
80
- port: 19532,
81
- protocol: "tcp",
82
- tls: false,
83
- pathname: "/"
84
- },
85
- {
86
- family: FAMILY_IPV6,
78
+ family: FAMILY_IPV4_IPV6,
87
79
  port: 19532,
88
80
  protocol: "tcp",
89
81
  tls: false,
@@ -6,7 +6,7 @@ import {
6
6
  boolean_attribute_writable,
7
7
  yesno_attribute_writable
8
8
  } from "pacc";
9
- import { ExtraSourceService, serviceEndpoints, addType, FAMILY_DNS } from "pmcf";
9
+ import { ExtraSourceService, serviceEndpoints, addType } from "pmcf";
10
10
  import {
11
11
  filterConfigurable,
12
12
  yesno,
package/src/utils.mjs CHANGED
@@ -96,15 +96,17 @@ export function bridgeToJSON(bridge) {
96
96
  * @returns {Array<any>}
97
97
  */
98
98
  export function asArray(value) {
99
- if (value === undefined) {
100
- return [];
101
- }
102
- if (Array.isArray(value)) {
103
- return value;
104
- }
105
-
106
- if (value instanceof Iterator) {
107
- return [...value];
99
+ switch (typeof value) {
100
+ case "undefined":
101
+ return [];
102
+ case "object":
103
+ if (Array.isArray(value)) {
104
+ return value;
105
+ }
106
+
107
+ if (value instanceof Iterator || value[Symbol.iterator]) {
108
+ return [...value];
109
+ }
108
110
  }
109
111
 
110
112
  return [value];