pmcf 4.28.11 → 4.29.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": "4.28.11",
3
+ "version": "4.29.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -52,9 +52,9 @@
52
52
  "dependencies": {
53
53
  "aggregated-map": "^1.0.4",
54
54
  "content-entry-transform": "^1.6.9",
55
- "ip-utilties": "^3.0.4",
55
+ "ip-utilties": "^3.1.0",
56
56
  "npm-pkgbuild": "^20.7.3",
57
- "pacc": "^9.3.2",
57
+ "pacc": "^9.3.3",
58
58
  "package-directory": "^8.2.0"
59
59
  },
60
60
  "devDependencies": {
package/src/base.mjs CHANGED
@@ -102,7 +102,21 @@ export class Base {
102
102
 
103
103
  materializeExtends() {}
104
104
 
105
- named(name) {}
105
+ named(name) {
106
+ for (const [path, attribute] of extendingAttributeIterator(
107
+ this.constructor,
108
+ (name, attribute) => /*attribute.owner &&*/ !attribute.type.primitive
109
+ )) {
110
+ const value = this[path];
111
+ if (typeof value?.get === "function") {
112
+ const object = value.get(name);
113
+ // console.log("NAMED", name, object.fullName);
114
+ if (object) {
115
+ return object;
116
+ }
117
+ }
118
+ }
119
+ }
106
120
 
107
121
  typeNamed(typeName, name) {
108
122
  if (this.owner) {
package/src/cluster.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { join } from "node:path";
2
2
  import { FileContentProvider } from "npm-pkgbuild";
3
+ import { FAMILY_IPV4 } from "ip-utilties";
3
4
  import {
4
5
  default_attribute_writable,
5
6
  default_attribute,
@@ -123,7 +124,7 @@ export class Cluster extends Host {
123
124
  )) {
124
125
  cfg.push(
125
126
  ` ${
126
- na.family === "IPv4"
127
+ na.family === FAMILY_IPV4
127
128
  ? "virtual_ipaddress"
128
129
  : "virtual_ipaddress_excluded"
129
130
  } {`
package/src/dns-utils.mjs CHANGED
@@ -50,9 +50,9 @@ export function dnsFullName(name) {
50
50
 
51
51
  export function dnsRecordTypeForAddressFamily(family) {
52
52
  switch (family) {
53
- case "IPv4":
53
+ case FAMILY_IPV4:
54
54
  return "A";
55
- case "IPv6":
55
+ case FAMILY_IPV6:
56
56
  return "AAAA";
57
57
  }
58
58
  }
package/src/endpoint.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { FAMILY_IPV6 } from "ip-utilties";
1
2
  import { addType } from "pacc";
2
3
  import { endpointAttributes, Service } from "./service.mjs";
3
4
 
@@ -146,7 +147,7 @@ export class HTTPEndpoint extends BaseEndpoint {
146
147
  this.family = address.family;
147
148
  this.url = new URL(
148
149
  (data.tls ? "https://" : "http://") +
149
- (address.family === "IPv6"
150
+ (address.family === FAMILY_IPV6
150
151
  ? "[" + address.address + "]"
151
152
  : address.address) +
152
153
  ":" +
package/src/host.mjs CHANGED
@@ -341,15 +341,6 @@ export class Host extends ServiceOwner {
341
341
  return super.typeNamed(typeName, name);
342
342
  }
343
343
 
344
- named(name) {
345
- const ni = this._networkInterfaces.get(name);
346
- if (ni) {
347
- return ni;
348
- }
349
-
350
- return super.named(name);
351
- }
352
-
353
344
  get network() {
354
345
  for (const ni of this.networkInterfaces.values()) {
355
346
  if (ni._kind !== "loopback" && ni._network) {
package/src/module.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ export * from "./type.mjs";
1
2
  export * from "./base.mjs";
2
3
  export * from "./cluster.mjs";
3
4
  export * from "./owner.mjs";
package/src/owner.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { normalizeCIDR, familyIP } from "ip-utilties";
1
+ import { normalizeCIDR, familyIP, FAMILY_IPV4 } from "ip-utilties";
2
2
  import {
3
3
  default_attribute_writable,
4
4
  string_set_attribute_writable,
@@ -197,7 +197,7 @@ export class Owner extends Base {
197
197
 
198
198
  if (!subnet) {
199
199
  subnet =
200
- familyIP(address) === "IPv4" ? SUBNET_GLOBAL_IPV4 : SUBNET_GLOBAL_IPV6;
200
+ familyIP(address) === FAMILY_IPV4 ? SUBNET_GLOBAL_IPV4 : SUBNET_GLOBAL_IPV6;
201
201
 
202
202
  this.error(
203
203
  `Address without subnet ${address}`,
@@ -64,14 +64,5 @@ export class ServiceOwner extends Base {
64
64
  throw new Error("invalidType", { cause: typeName });
65
65
  }
66
66
  return super.typeNamed(typeName, name);
67
- }
68
-
69
- /**
70
- *
71
- * @param {string} name
72
- * @returns {Service|undefined}
73
- */
74
- named(name) {
75
- return this.services.get(name);
76
- }
67
+ }
77
68
  }
@@ -1,3 +1,5 @@
1
+ import { FAMILY_IPV4, FAMILY_IPV6 } from "ip-utilties";
2
+
1
3
  export const ServiceTypes = {
2
4
  "alpm-repo": {
3
5
  extends: ["https"]
@@ -6,25 +8,25 @@ export const ServiceTypes = {
6
8
  endpoints: [
7
9
  {
8
10
  protocol: "udp",
9
- family: "IPv4",
11
+ family: FAMILY_IPV4,
10
12
  port: 514,
11
13
  tls: false
12
14
  },
13
15
  {
14
16
  protocol: "udp",
15
- family: "IPv6",
17
+ family: FAMILY_IPV6,
16
18
  port: 514,
17
19
  tls: false
18
20
  },
19
21
  {
20
22
  protocol: "tcp",
21
- family: "IPv4",
23
+ family: FAMILY_IPV4,
22
24
  port: 514,
23
25
  tls: false
24
26
  },
25
27
  {
26
28
  protocol: "tcp",
27
- family: "IPv6",
29
+ family: FAMILY_IPV6,
28
30
  port: 514,
29
31
  tls: false
30
32
  }
@@ -32,52 +34,52 @@ export const ServiceTypes = {
32
34
  },
33
35
  mqtt: {
34
36
  endpoints: [
35
- { family: "IPv4", protocol: "tcp", port: 1883, tls: false },
36
- { family: "IPv6", protocol: "tcp", port: 1883, tls: false }
37
+ { family: FAMILY_IPV4, protocol: "tcp", port: 1883, tls: false },
38
+ { family: FAMILY_IPV6, protocol: "tcp", port: 1883, tls: false }
37
39
  ]
38
40
  },
39
41
  "secure-mqtt": {
40
42
  endpoints: [
41
- { family: "IPv4", protocol: "tcp", port: 8883, tls: true },
42
- { family: "IPv6", protocol: "tcp", port: 8883, tls: true }
43
+ { family: FAMILY_IPV4, protocol: "tcp", port: 8883, tls: true },
44
+ { family: FAMILY_IPV6, protocol: "tcp", port: 8883, tls: true }
43
45
  ]
44
46
  },
45
47
  ntp: {
46
48
  endpoints: [
47
- { family: "IPv4", protocol: "udp", port: 123, tls: false },
48
- { family: "IPv6", protocol: "udp", port: 123, tls: false }
49
+ { family: FAMILY_IPV4, protocol: "udp", port: 123, tls: false },
50
+ { family: FAMILY_IPV6, protocol: "udp", port: 123, tls: false }
49
51
  ]
50
52
  },
51
53
  dns: {
52
54
  endpoints: [
53
- { family: "IPv4", protocol: "udp", port: 53, tls: false },
54
- { family: "IPv6", protocol: "udp", port: 53, tls: false }
55
+ { family: FAMILY_IPV4, protocol: "udp", port: 53, tls: false },
56
+ { family: FAMILY_IPV6, protocol: "udp", port: 53, tls: false }
55
57
  ]
56
58
  },
57
59
  mdns: {
58
60
  endpoints: [
59
- { family: "IPv4", protocol: "udp", port: 5353, tls: false },
60
- { family: "IPv6", protocol: "udp", port: 5353, tls: false }
61
+ { family: FAMILY_IPV4, protocol: "udp", port: 5353, tls: false },
62
+ { family: FAMILY_IPV6, protocol: "udp", port: 5353, tls: false }
61
63
  ]
62
64
  },
63
65
  llmnr: {
64
66
  endpoints: [
65
- { family: "IPv4", protocol: "udp", port: 5355, tls: false },
66
- { family: "IPv4", protocol: "tcp", port: 5355, tls: false },
67
- { family: "IPv6", protocol: "udp", port: 5355, tls: false },
68
- { family: "IPv6", protocol: "tcp", port: 5355, tls: false }
67
+ { family: FAMILY_IPV4, protocol: "udp", port: 5355, tls: false },
68
+ { family: FAMILY_IPV4, protocol: "tcp", port: 5355, tls: false },
69
+ { family: FAMILY_IPV6, protocol: "udp", port: 5355, tls: false },
70
+ { family: FAMILY_IPV6, protocol: "tcp", port: 5355, tls: false }
69
71
  ]
70
72
  },
71
73
  ldap: {
72
74
  endpoints: [
73
- { family: "IPv4", scheme: "ldap", protocol: "tcp", port: 389, tls: false },
74
- { family: "IPv6", scheme: "ldap", protocol: "tcp", port: 389, tls: false }
75
+ { family: FAMILY_IPV4, scheme: "ldap", protocol: "tcp", port: 389, tls: false },
76
+ { family: FAMILY_IPV6, scheme: "ldap", protocol: "tcp", port: 389, tls: false }
75
77
  ]
76
78
  },
77
79
  ldaps: {
78
80
  endpoints: [
79
- { family: "IPv4", scheme: "ldaps", protocol: "tcp", port: 636, tls: true },
80
- { family: "IPv6", scheme: "ldaps", protocol: "tcp", port: 636, tls: true }
81
+ { family: FAMILY_IPV4, scheme: "ldaps", protocol: "tcp", port: 636, tls: true },
82
+ { family: FAMILY_IPV6, scheme: "ldaps", protocol: "tcp", port: 636, tls: true }
81
83
  ]
82
84
  },
83
85
  ldapi: {
@@ -85,21 +87,21 @@ export const ServiceTypes = {
85
87
  },
86
88
  http: {
87
89
  endpoints: [
88
- { family: "IPv4", scheme: "http", protocol: "tcp", port: 80, tls: false },
89
- { family: "IPv6", scheme: "http", protocol: "tcp", port: 80, tls: false }
90
+ { family: FAMILY_IPV4, scheme: "http", protocol: "tcp", port: 80, tls: false },
91
+ { family: FAMILY_IPV6, scheme: "http", protocol: "tcp", port: 80, tls: false }
90
92
  ]
91
93
  },
92
94
  https: {
93
95
  endpoints: [
94
- { family: "IPv4", scheme: "https", protocol: "tcp", port: 443, tls: true },
95
- { family: "IPv6", scheme: "https", protocol: "tcp", port: 443, tls: true }
96
+ { family: FAMILY_IPV4, scheme: "https", protocol: "tcp", port: 443, tls: true },
97
+ { family: FAMILY_IPV6, scheme: "https", protocol: "tcp", port: 443, tls: true }
96
98
  ],
97
99
  dnsRecord: { type: "HTTPS", parameters: { alpn: "h2" } }
98
100
  },
99
101
  http3: {
100
102
  endpoints: [
101
- { family: "IPv4", scheme: "https", protocol: "udp", port: 443, tls: true },
102
- { family: "IPv6", scheme: "https", protocol: "udp", port: 443, tls: true }
103
+ { family: FAMILY_IPV4, scheme: "https", protocol: "udp", port: 443, tls: true },
104
+ { family: FAMILY_IPV6, scheme: "https", protocol: "udp", port: 443, tls: true }
103
105
  ],
104
106
  dnsRecord: {
105
107
  type: "HTTPS",
@@ -108,64 +110,64 @@ export const ServiceTypes = {
108
110
  },
109
111
  rtsp: {
110
112
  endpoints: [
111
- { family: "IPv4", protocol: "tcp", port: 554, tls: false },
112
- { family: "IPv6", protocol: "tcp", port: 554, tls: false }
113
+ { family: FAMILY_IPV4, protocol: "tcp", port: 554, tls: false },
114
+ { family: FAMILY_IPV6, protocol: "tcp", port: 554, tls: false }
113
115
  ]
114
116
  },
115
117
  smtp: {
116
118
  endpoints: [
117
- { family: "IPv4", protocol: "tcp", port: 25, tls: false },
118
- { family: "IPv6", protocol: "tcp", port: 25, tls: false }
119
+ { family: FAMILY_IPV4, protocol: "tcp", port: 25, tls: false },
120
+ { family: FAMILY_IPV6, protocol: "tcp", port: 25, tls: false }
119
121
  ],
120
122
  dnsRecord: { type: "MX" }
121
123
  },
122
124
  submission: {
123
125
  endpoints: [
124
- { family: "IPv4", protocol: "tcp", port: 587, tls: false },
125
- { family: "IPv6", protocol: "tcp", port: 587, tls: false }
126
+ { family: FAMILY_IPV4, protocol: "tcp", port: 587, tls: false },
127
+ { family: FAMILY_IPV6, protocol: "tcp", port: 587, tls: false }
126
128
  ]
127
129
  },
128
130
  lmtp: {
129
131
  endpoints: [
130
- { family: "IPv4", protocol: "tcp", port: 24, tls: false },
131
- { family: "IPv6", protocol: "tcp", port: 24, tls: false }
132
+ { family: FAMILY_IPV4, protocol: "tcp", port: 24, tls: false },
133
+ { family: FAMILY_IPV6, protocol: "tcp", port: 24, tls: false }
132
134
  ]
133
135
  },
134
136
  ssh: {
135
137
  endpoints: [
136
- { family: "IPv4", protocol: "tcp", port: 22, tls: false },
137
- { family: "IPv6", protocol: "tcp", port: 22, tls: false }
138
+ { family: FAMILY_IPV4, protocol: "tcp", port: 22, tls: false },
139
+ { family: FAMILY_IPV6, protocol: "tcp", port: 22, tls: false }
138
140
  ]
139
141
  },
140
142
  imap: {
141
143
  endpoints: [
142
- { family: "IPv4", protocol: "tcp", port: 143, tls: false },
143
- { family: "IPv6", protocol: "tcp", port: 143, tls: false }
144
+ { family: FAMILY_IPV4, protocol: "tcp", port: 143, tls: false },
145
+ { family: FAMILY_IPV6, protocol: "tcp", port: 143, tls: false }
144
146
  ]
145
147
  },
146
148
  imaps: {
147
149
  endpoints: [
148
- { family: "IPv4", protocol: "tcp", port: 993, tls: true },
149
- { family: "IPv6", protocol: "tcp", port: 993, tls: true }
150
+ { family: FAMILY_IPV4, protocol: "tcp", port: 993, tls: true },
151
+ { family: FAMILY_IPV6, protocol: "tcp", port: 993, tls: true }
150
152
  ]
151
153
  },
152
154
  dhcp: {
153
155
  endpoints: [
154
- { family: "IPv4", protocol: "udp", port: 547, tls: false },
155
- { family: "IPv6", protocol: "udp", port: 547, tls: false }
156
+ { family: FAMILY_IPV4, protocol: "udp", port: 547, tls: false },
157
+ { family: FAMILY_IPV6, protocol: "udp", port: 547, tls: false }
156
158
  ]
157
159
  },
158
160
  "dhcpv6-client": {
159
161
  endpoints: [
160
- { family: "IPv6", protocol: "tcp", port: 546, tls: false },
161
- { family: "IPv6", protocol: "udp", port: 546, tls: false }
162
+ { family: FAMILY_IPV6, protocol: "tcp", port: 546, tls: false },
163
+ { family: FAMILY_IPV6, protocol: "udp", port: 546, tls: false }
162
164
  ]
163
165
  },
164
- "dhcpv6-server": { endpoints: [{ family: "IPv6", port: 547, tls: false }] },
166
+ "dhcpv6-server": { endpoints: [{ family: FAMILY_IPV6, port: 547, tls: false }] },
165
167
  smb: {
166
168
  endpoints: [
167
- { family: "IPv4", protocol: "tcp", port: 445, tls: false },
168
- { family: "IPv6", protocol: "tcp", port: 445, tls: false }
169
+ { family: FAMILY_IPV4, protocol: "tcp", port: 445, tls: false },
170
+ { family: FAMILY_IPV6, protocol: "tcp", port: 445, tls: false }
169
171
  ]
170
172
  },
171
173
  timemachine: {
@@ -183,15 +185,15 @@ export const ServiceTypes = {
183
185
  pcp: {
184
186
  // rfc6887
185
187
  endpoints: [
186
- { family: "IPv4", protocol: "udp", port: 5351, tls: false },
187
- { family: "IPv6", protocol: "udp", port: 5351, tls: false }
188
+ { family: FAMILY_IPV4, protocol: "udp", port: 5351, tls: false },
189
+ { family: FAMILY_IPV6, protocol: "udp", port: 5351, tls: false }
188
190
  ]
189
191
  },
190
192
  "pcp-multicast": {
191
193
  // rfc6887
192
194
  endpoints: [
193
- { family: "IPv4", protocol: "udp", port: 5350, tls: false },
194
- { family: "IPv6", protocol: "udp", port: 5350, tls: false }
195
+ { family: FAMILY_IPV4, protocol: "udp", port: 5350, tls: false },
196
+ { family: FAMILY_IPV6, protocol: "udp", port: 5350, tls: false }
195
197
  ]
196
198
  }
197
199
  };
package/src/service.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { FAMILY_IPV4, FAMILY_IPV6 } from "ip-utilties";
1
2
  import {
2
3
  string_attribute_writable,
3
4
  number_attribute_writable,
@@ -136,8 +137,8 @@ export class Service extends Base {
136
137
 
137
138
  case undefined:
138
139
  case "dns":
139
- case "IPv4":
140
- case "IPv6":
140
+ case FAMILY_IPV4:
141
+ case FAMILY_IPV6:
141
142
  const options =
142
143
  this._port === undefined ? { ...e } : { ...e, port: this._port };
143
144
  delete options.kind;
@@ -1,12 +1,10 @@
1
1
  import {
2
- addType,
3
2
  default_attribute_writable,
4
3
  name_attribute_writable,
5
4
  string_attribute_writable,
6
5
  string_set_attribute_writable
7
6
  } from "pacc";
8
- import { addServiceType, Base } from "pmcf";
9
- import { Service } from "../service.mjs";
7
+ import { addType, Service, Base } from "pmcf";
10
8
 
11
9
  class alpm_repository extends Base {
12
10
  static attributes = {
@@ -36,7 +34,6 @@ export class alpm extends Service {
36
34
 
37
35
  static {
38
36
  addType(this);
39
- addServiceType(this.service, this.name);
40
37
  }
41
38
 
42
39
  repositories = new Map();
@@ -1,9 +1,8 @@
1
1
  import { join, dirname } from "node:path";
2
2
  import { createHmac } from "node:crypto";
3
3
  import { FileContentProvider } from "npm-pkgbuild";
4
- import { isLinkLocal, reverseArpa } from "ip-utilties";
4
+ import { isLinkLocal, reverseArpa, FAMILY_IPV4, FAMILY_IPV6 } from "ip-utilties";
5
5
  import {
6
- addType,
7
6
  default_attribute_writable,
8
7
  duration_attribute_writable,
9
8
  string_set_attribute_writable,
@@ -13,12 +12,13 @@ import {
13
12
  name_attribute_writable
14
13
  } from "pacc";
15
14
  import {
15
+ Service,
16
16
  Base,
17
17
  ExtraSourceService,
18
18
  serviceEndpoints,
19
19
  addresses,
20
20
  networkAddressType,
21
- addServiceType
21
+ addType
22
22
  } from "pmcf";
23
23
  import { yesno, writeLines, asArray } from "../utils.mjs";
24
24
  import {
@@ -27,7 +27,6 @@ import {
27
27
  dnsRecordTypeForAddressFamily,
28
28
  sortZoneRecords
29
29
  } from "../dns-utils.mjs";
30
- import { Service } from "../service.mjs";
31
30
  import { addHook } from "../hooks.mjs";
32
31
 
33
32
  const bindNetworkAddressTypes = networkAddressType + "|bind_group";
@@ -417,7 +416,7 @@ export class bind extends ExtraSourceService {
417
416
  "bind-statistics": {
418
417
  endpoints: [
419
418
  {
420
- family: "IPv4",
419
+ family: FAMILY_IPV4,
421
420
  port: 19521,
422
421
  protocol: "tcp",
423
422
  pathname: "/",
@@ -425,7 +424,7 @@ export class bind extends ExtraSourceService {
425
424
  kind: "loopback"
426
425
  },
427
426
  {
428
- family: "IPv6",
427
+ family: FAMILY_IPV6,
429
428
  port: 19521,
430
429
  protocol: "tcp",
431
430
  pathname: "/",
@@ -437,7 +436,7 @@ export class bind extends ExtraSourceService {
437
436
  "bind-rdnc": {
438
437
  endpoints: [
439
438
  {
440
- family: "IPv4",
439
+ family: FAMILY_IPV4,
441
440
  port: 953,
442
441
  protocol: "tcp",
443
442
  tls: false,
@@ -450,7 +449,6 @@ export class bind extends ExtraSourceService {
450
449
 
451
450
  static {
452
451
  addType(this);
453
- addServiceType(this.service, this.name);
454
452
  }
455
453
 
456
454
  groups = {};
@@ -1,9 +1,8 @@
1
1
  import { join } from "node:path";
2
+ import { FAMILY_IPV4, FAMILY_IPV6 } from "ip-utilties";
2
3
  import { FileContentProvider } from "npm-pkgbuild";
3
4
  import { isLinkLocal } from "ip-utilties";
4
- import { addType } from "pacc";
5
- import { addServiceType, ExtraSourceService } from "pmcf";
6
- import { Service, serviceEndpoints } from "../service.mjs";
5
+ import { Service, serviceEndpoints, addType, ExtraSourceService } from "pmcf";
7
6
  import { writeLines } from "../utils.mjs";
8
7
 
9
8
  export class chrony extends ExtraSourceService {
@@ -15,13 +14,13 @@ export class chrony extends ExtraSourceService {
15
14
  "chrony-cmd": {
16
15
  endpoints: [
17
16
  {
18
- family: "IPv4",
17
+ family: FAMILY_IPV4,
19
18
  port: 323,
20
19
  protocol: "tcp",
21
20
  tls: false
22
21
  },
23
22
  {
24
- family: "IPv6",
23
+ family: FAMILY_IPV6,
25
24
  port: 323,
26
25
  protocol: "tcp",
27
26
  tls: false
@@ -37,7 +36,6 @@ export class chrony extends ExtraSourceService {
37
36
 
38
37
  static {
39
38
  addType(this);
40
- addServiceType(this.service, this.name);
41
39
  }
42
40
 
43
41
  async *preparePackages(dir) {
@@ -65,7 +63,7 @@ export class chrony extends ExtraSourceService {
65
63
  if (endpoint.isPool) {
66
64
  options.push("maxsources 2");
67
65
  }
68
- if (endpoint.priority > 300 && endpoint.family === "IPv4") {
66
+ if (endpoint.priority > 300 && endpoint.family === FAMILY_IPV4) {
69
67
  options.push("prefer");
70
68
  }
71
69
  return options.join(" ");
@@ -1,6 +1,5 @@
1
- import { addType } from "pacc";
2
- import { addServiceType } from "pmcf";
3
- import { Service } from "../service.mjs";
1
+ import { FAMILY_IPV4 } from "ip-utilties";
2
+ import { Service, addType } from "pmcf";
4
3
 
5
4
  export class headscale extends Service {
6
5
  static specializationOf = Service;
@@ -11,21 +10,21 @@ export class headscale extends Service {
11
10
  path: "/run/headscale/headscale.sock"
12
11
  },
13
12
  {
14
- family: "IPv4",
13
+ family: FAMILY_IPV4,
15
14
  port: 8080,
16
15
  protocol: "tcp",
17
16
  tls: false
18
17
  },
19
18
  {
20
19
  description: "grpc",
21
- family: "IPv4",
20
+ family: FAMILY_IPV4,
22
21
  port: 50443,
23
22
  protocol: "tcp",
24
23
  tls: false
25
24
  },
26
25
  {
27
26
  description: "metrics debug",
28
- family: "IPv4",
27
+ family: FAMILY_IPV4,
29
28
  port: 9090,
30
29
  protocol: "tcp",
31
30
  tls: false
@@ -34,6 +33,5 @@ export class headscale extends Service {
34
33
  };
35
34
  static {
36
35
  addType(this);
37
- addServiceType(this.service, this.name);
38
36
  }
39
37
  }
@@ -1,13 +1,13 @@
1
1
  import { join } from "node:path";
2
+ import { FAMILY_IPV4, FAMILY_IPV6 } from "ip-utilties";
2
3
  import { FileContentProvider } from "npm-pkgbuild";
3
- import { boolean_attribute_writable_true, addType } from "pacc";
4
- import { addServiceType } from "pmcf";
4
+ import { boolean_attribute_writable_true } from "pacc";
5
+ import { Service, addType } from "pmcf";
5
6
  import {
6
7
  writeLines,
7
8
  setionLinesFromPropertyIterator,
8
9
  filterConfigurable
9
10
  } from "../utils.mjs";
10
- import { Service } from "../service.mjs";
11
11
 
12
12
  export class influxdb extends Service {
13
13
  static specializationOf = Service;
@@ -21,14 +21,14 @@ export class influxdb extends Service {
21
21
  static service = {
22
22
  endpoints: [
23
23
  {
24
- family: "IPv4",
24
+ family: FAMILY_IPV4,
25
25
  port: 8086,
26
26
  protocol: "tcp",
27
27
  tls: false,
28
28
  pathname: "/"
29
29
  },
30
30
  {
31
- family: "IPv6",
31
+ family: FAMILY_IPV6,
32
32
  port: 8086,
33
33
  protocol: "tcp",
34
34
  tls: false,
@@ -39,7 +39,6 @@ export class influxdb extends Service {
39
39
 
40
40
  static {
41
41
  addType(this);
42
- addServiceType(this.service, this.name);
43
42
  }
44
43
 
45
44
  async *preparePackages(dir) {
@@ -1,14 +1,13 @@
1
1
  import { join } from "node:path";
2
2
  import { FileContentProvider } from "npm-pkgbuild";
3
- import { reverseArpa, isLinkLocal } from "ip-utilties";
3
+ import { reverseArpa, isLinkLocal, FAMILY_IPV4, FAMILY_IPV6 } from "ip-utilties";
4
4
  import {
5
5
  string_attribute_writable,
6
6
  number_attribute_writable,
7
- boolean_attribute_writable_true,
8
- addType
7
+ boolean_attribute_writable_true
9
8
  } from "pacc";
10
9
  import {
11
- addServiceType,
10
+ addType,
12
11
  Service,
13
12
  sortDescendingByPriority,
14
13
  serviceEndpoints,
@@ -54,7 +53,7 @@ export class kea extends Service {
54
53
  "kea-ddns": {
55
54
  endpoints: [
56
55
  {
57
- family: "IPv4",
56
+ family: FAMILY_IPV4,
58
57
  kind: "loopback",
59
58
  port: 53001,
60
59
  protocol: "tcp",
@@ -65,7 +64,7 @@ export class kea extends Service {
65
64
  /*"kea-control-agent": {
66
65
  endpoints: [
67
66
  {
68
- family: "IPv4",
67
+ family: FAMILY_IPV4,
69
68
  port: 53002,
70
69
  pathname: "/",
71
70
  protocol: "tcp",
@@ -76,7 +75,7 @@ export class kea extends Service {
76
75
  "kea-ha-4": {
77
76
  endpoints: [
78
77
  {
79
- family: "IPv4",
78
+ family: FAMILY_IPV4,
80
79
  port: 53003,
81
80
  pathname: "/",
82
81
  protocol: "tcp",
@@ -87,7 +86,7 @@ export class kea extends Service {
87
86
  "kea-ha-6": {
88
87
  endpoints: [
89
88
  {
90
- family: "IPv6",
89
+ family: FAMILY_IPV6,
91
90
  port: 53004,
92
91
  pathname: "/",
93
92
  protocol: "tcp",
@@ -124,7 +123,6 @@ export class kea extends Service {
124
123
 
125
124
  static {
126
125
  addType(this);
127
- addServiceType(this.service, this.name);
128
126
  }
129
127
 
130
128
  async *preparePackages(dir) {
@@ -254,9 +252,7 @@ export class kea extends Service {
254
252
  ]
255
253
  };
256
254
 
257
- for (const [key] of Object.entries(
258
- KeaService.attributes
259
- ).filter(
255
+ for (const [key] of Object.entries(KeaService.attributes).filter(
260
256
  ([key, attribute]) => attribute.configurable && this[key] !== undefined
261
257
  )) {
262
258
  cfg[key] = this[key];
@@ -291,7 +287,7 @@ export class kea extends Service {
291
287
  name,
292
288
  "dns-servers": dnsServerEndpoints
293
289
  .filter(
294
- endpoint => endpoint.family === "IPv4" && endpoint.type === "dns"
290
+ endpoint => endpoint.family === FAMILY_IPV4 && endpoint.type === "dns"
295
291
  )
296
292
  .map(endpoint => {
297
293
  return { "ip-address": endpoint.address };
@@ -399,7 +395,7 @@ export class kea extends Service {
399
395
  subnet4: subnets
400
396
  .filter(
401
397
  s =>
402
- s.family === "IPv4" &&
398
+ s.family === FAMILY_IPV4 &&
403
399
  // TODO keep out tailscale
404
400
  s.cidr !== "100.64.0.2/32" &&
405
401
  s.cidr !== "100.64.0.3/32"
@@ -426,7 +422,7 @@ export class kea extends Service {
426
422
  subnet6: subnets
427
423
  .filter(
428
424
  s =>
429
- s.family === "IPv6" &&
425
+ s.family === FAMILY_IPV6 &&
430
426
  !isLinkLocal(s.address) &&
431
427
  // TODO keep out tailscale
432
428
  s.cidr !== "fd7a:115c:a1e0::/64"
@@ -1,6 +1,5 @@
1
- import { port_attribute, string_attribute_writable, addType } from "pacc";
2
- import { addServiceType } from "pmcf";
3
- import { Service } from "../service.mjs";
1
+ import { port_attribute, string_attribute_writable } from "pacc";
2
+ import { Service, addType } from "pmcf";
4
3
 
5
4
  export class mosquitto extends Service {
6
5
  static specializationOf = Service;
@@ -29,7 +28,6 @@ export class mosquitto extends Service {
29
28
 
30
29
  static {
31
30
  addType(this);
32
- addServiceType(this.service, this.name);
33
31
  }
34
32
 
35
33
  get listener() {
@@ -1,6 +1,5 @@
1
- import { string_attribute_writable, addType } from "pacc";
2
- import { addServiceType } from "pmcf";
3
- import { Service } from "../service.mjs";
1
+ import { string_attribute_writable } from "pacc";
2
+ import { Service, addType } from "pmcf";
4
3
 
5
4
  export class openldap extends Service {
6
5
  static specializationOf = Service;
@@ -16,7 +15,6 @@ export class openldap extends Service {
16
15
 
17
16
  static {
18
17
  addType(this);
19
- addServiceType(this.service, this.name);
20
18
  }
21
19
 
22
20
  _base;
@@ -43,7 +41,9 @@ export class openldap extends Service {
43
41
 
44
42
  const packageData = this.packageData;
45
43
 
46
- console.log([...this.walkDirections(["this", "extends"]) ].map(n=>n.fullName));
44
+ console.log(
45
+ [...this.walkDirections(["this", "extends"])].map(n => n.fullName)
46
+ );
47
47
 
48
48
  packageData.sources = await Array.fromAsync(
49
49
  this.templateContent(
@@ -1,6 +1,4 @@
1
- import { addType } from "pacc";
2
- import { addServiceType } from "pmcf";
3
- import { Service } from "../service.mjs";
1
+ import { Service, addType } from "pmcf";
4
2
 
5
3
  export class postfix extends Service {
6
4
  static specializationOf = Service;
@@ -13,7 +11,5 @@ export class postfix extends Service {
13
11
 
14
12
  static {
15
13
  addType(this);
16
- addServiceType(this.service, this.name);
17
14
  }
18
-
19
15
  }
@@ -1,11 +1,11 @@
1
+ import { FAMILY_IPV4, FAMILY_IPV6 } from "ip-utilties";
1
2
  import {
2
- addType,
3
3
  string_attribute_writable,
4
4
  string_collection_attribute_writable,
5
5
  boolean_attribute_writable,
6
6
  integer_attribute_writable
7
7
  } from "pacc";
8
- import { Service, addServiceType } from "pmcf";
8
+ import { Service, addType } from "pmcf";
9
9
  import { filterConfigurable, sectionLines } from "../utils.mjs";
10
10
 
11
11
  /**
@@ -66,14 +66,14 @@ export class SystemdJournalRemoteService extends Service {
66
66
  systemdService: "systemd-journal-remote.service",
67
67
  endpoints: [
68
68
  {
69
- family: "IPv4",
69
+ family: FAMILY_IPV4,
70
70
  port: 19532,
71
71
  protocol: "tcp",
72
72
  tls: false,
73
73
  pathname: "/"
74
74
  },
75
75
  {
76
- family: "IPv6",
76
+ family: FAMILY_IPV6,
77
77
  port: 19532,
78
78
  protocol: "tcp",
79
79
  tls: false,
@@ -84,7 +84,6 @@ export class SystemdJournalRemoteService extends Service {
84
84
 
85
85
  static {
86
86
  addType(this);
87
- addServiceType(this.service, this.name);
88
87
  }
89
88
 
90
89
  get type() {
@@ -1,10 +1,9 @@
1
1
  import {
2
2
  string_attribute_writable,
3
3
  string_collection_attribute_writable,
4
- boolean_attribute_writable,
5
- addType
4
+ boolean_attribute_writable
6
5
  } from "pacc";
7
- import { Service, addServiceType } from "pmcf";
6
+ import { Service, addType } from "pmcf";
8
7
  import { filterConfigurable, sectionLines } from "../utils.mjs";
9
8
 
10
9
  /**
@@ -48,7 +47,6 @@ export class SystemdJournalUploadService extends Service {
48
47
  };
49
48
  static {
50
49
  addType(this);
51
- addServiceType(this.service, this.name);
52
50
  }
53
51
 
54
52
  get type() {
@@ -1,9 +1,5 @@
1
- import {
2
- addType,
3
- string_attribute_writable,
4
- duration_attribute_writable
5
- } from "pacc";
6
- import { Service, addServiceType } from "pmcf";
1
+ import { string_attribute_writable, duration_attribute_writable } from "pacc";
2
+ import { Service, addType } from "pmcf";
7
3
  import { filterConfigurable, sectionLines } from "../utils.mjs";
8
4
 
9
5
  export class SystemdJournaldService extends Service {
@@ -108,7 +104,6 @@ export class SystemdJournaldService extends Service {
108
104
  };
109
105
  static {
110
106
  addType(this);
111
- addServiceType(this.service, this.name);
112
107
  }
113
108
 
114
109
  get type() {
@@ -1,17 +1,12 @@
1
+ import { FAMILY_IPV4 } from "ip-utilties";
1
2
  import {
2
- addType,
3
3
  string_collection_attribute_writable,
4
4
  duration_attribute_writable,
5
5
  string_attribute_writable,
6
6
  boolean_attribute_writable,
7
7
  yesno_attribute_writable
8
8
  } from "pacc";
9
- import {
10
- ExtraSourceService,
11
- serviceEndpoints,
12
- addServiceType,
13
- Service
14
- } from "pmcf";
9
+ import { ExtraSourceService, serviceEndpoints, addType, Service } from "pmcf";
15
10
  import {
16
11
  filterConfigurable,
17
12
  yesno,
@@ -73,7 +68,6 @@ export class SystemdResolvedService extends ExtraSourceService {
73
68
 
74
69
  static {
75
70
  addType(this);
76
- addServiceType(this.service, this.name);
77
71
  }
78
72
 
79
73
  systemdConfigs(name) {
@@ -81,7 +75,7 @@ export class SystemdResolvedService extends ExtraSourceService {
81
75
  return {
82
76
  services: `services[types[dns] && priority>=${lower} && priority<=${upper}]`,
83
77
  endpoints: e =>
84
- e.family == "IPv4" &&
78
+ e.family == FAMILY_IPV4 &&
85
79
  e.networkInterface &&
86
80
  e.networkInterface.kind !== "loopback",
87
81
  //e.family !== "dns",
@@ -1,14 +1,5 @@
1
- import {
2
- addType,
3
- string_attribute_writable,
4
- duration_attribute_writable
5
- } from "pacc";
6
- import {
7
- ExtraSourceService,
8
- Service,
9
- serviceEndpoints,
10
- addServiceType
11
- } from "pmcf";
1
+ import { string_attribute_writable, duration_attribute_writable } from "pacc";
2
+ import { ExtraSourceService, Service, serviceEndpoints, addType } from "pmcf";
12
3
  import { filterConfigurable, sectionLines } from "../utils.mjs";
13
4
 
14
5
  export class SystemdTimesyncdService extends ExtraSourceService {
@@ -30,7 +21,6 @@ export class SystemdTimesyncdService extends ExtraSourceService {
30
21
 
31
22
  static {
32
23
  addType(this);
33
- addServiceType(this.service, this.name);
34
24
  }
35
25
 
36
26
  systemdConfigs(name) {
@@ -1,12 +1,12 @@
1
- import { addType } from "pacc";
2
- import { Service } from "../service.mjs";
1
+ import { FAMILY_IPV4 } from "ip-utilties";
2
+ import { Service, addType } from "pmcf";
3
3
 
4
4
  export class tailscale extends Service {
5
5
  static specializationOf = Service;
6
6
  static service = {
7
7
  endpoints: [
8
8
  {
9
- family: "IPv4",
9
+ family: FAMILY_IPV4,
10
10
  port: 41641,
11
11
  protocol: "tcp",
12
12
  tls: false
package/src/subnet.mjs CHANGED
@@ -70,7 +70,7 @@ export class Subnet extends Base {
70
70
  /* TODO where to take values from ? */
71
71
 
72
72
  return [
73
- this.family === "IPv6"
73
+ this.family === FAMILY_IPV6
74
74
  ? this.cidr
75
75
  : rangeIP(this.prefix, this.prefixLength, 51, 6).map(a => decodeIP(a))
76
76
  ];
package/src/type.mjs ADDED
@@ -0,0 +1,10 @@
1
+ import { addType as addTypeBasic } from "pacc";
2
+ import { addServiceType } from "pmcf";
3
+
4
+ export function addType(type) {
5
+ addTypeBasic(type);
6
+
7
+ if (type.service) {
8
+ addServiceType(type.service, type.name);
9
+ }
10
+ }