pmcf 6.26.4 → 6.27.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/README.md +21 -21
- package/package.json +1 -1
- package/src/base.mjs +2 -2
- package/src/common-attributes.mjs +3 -0
- package/src/core-service.mjs +3 -1
- package/src/endpoint.mjs +58 -2
- package/src/host.mjs +7 -1
- package/src/network-address.mjs +4 -3
- package/src/services/bind.mjs +17 -19
package/README.md
CHANGED
|
@@ -79,30 +79,30 @@ generates config packages for:
|
|
|
79
79
|
* [domainNames](#domainnames)
|
|
80
80
|
* [InitializationContext](#initializationcontext)
|
|
81
81
|
* [Parameters](#parameters-14)
|
|
82
|
+
* [SkeletonNetworkInterface](#skeletonnetworkinterface)
|
|
83
|
+
* [networkAddresses](#networkaddresses)
|
|
84
|
+
* [Parameters](#parameters-15)
|
|
82
85
|
* [zones](#zones)
|
|
83
86
|
* [type](#type)
|
|
84
87
|
* [addressesStatement](#addressesstatement)
|
|
85
|
-
* [Parameters](#parameters-
|
|
88
|
+
* [Parameters](#parameters-16)
|
|
86
89
|
* [SystemdJournalRemoteService](#systemdjournalremoteservice)
|
|
87
90
|
* [Properties](#properties)
|
|
88
91
|
* [systemdConfigs](#systemdconfigs)
|
|
89
|
-
* [Parameters](#parameters-
|
|
92
|
+
* [Parameters](#parameters-17)
|
|
90
93
|
* [SystemdJournalUploadService](#systemdjournaluploadservice)
|
|
91
94
|
* [Properties](#properties-1)
|
|
92
95
|
* [systemdConfigs](#systemdconfigs-1)
|
|
93
|
-
* [Parameters](#parameters-
|
|
96
|
+
* [Parameters](#parameters-18)
|
|
94
97
|
* [NetworkAddress](#networkaddress)
|
|
95
|
-
* [Parameters](#parameters-
|
|
98
|
+
* [Parameters](#parameters-19)
|
|
96
99
|
* [subnet](#subnet)
|
|
97
100
|
* [networkInterface](#networkinterface)
|
|
98
101
|
* [address](#address)
|
|
99
102
|
* [addresses](#addresses)
|
|
100
|
-
* [Parameters](#parameters-19)
|
|
101
|
-
* [cidrAddresses](#cidraddresses)
|
|
102
103
|
* [Parameters](#parameters-20)
|
|
103
|
-
* [
|
|
104
|
-
* [
|
|
105
|
-
* [Parameters](#parameters-21)
|
|
104
|
+
* [cidrAddresses](#cidraddresses)
|
|
105
|
+
* [Parameters](#parameters-21)
|
|
106
106
|
* [families](#families)
|
|
107
107
|
* [secretName](#secretname)
|
|
108
108
|
* [directHosts](#directhosts)
|
|
@@ -301,6 +301,18 @@ Keeps track of all in flight object creations and loose ends during config initi
|
|
|
301
301
|
|
|
302
302
|
* `directory` (optional, default `"/"`)
|
|
303
303
|
|
|
304
|
+
## SkeletonNetworkInterface
|
|
305
|
+
|
|
306
|
+
**Extends ServiceOwner**
|
|
307
|
+
|
|
308
|
+
### networkAddresses
|
|
309
|
+
|
|
310
|
+
#### Parameters
|
|
311
|
+
|
|
312
|
+
* `filter` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `n=>true`)
|
|
313
|
+
|
|
314
|
+
Returns **Iterable<[NetworkAddress](#networkaddress)>** 
|
|
315
|
+
|
|
304
316
|
## zones
|
|
305
317
|
|
|
306
318
|
Type: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<bind\_zone>
|
|
@@ -397,18 +409,6 @@ Returns **Iterable<[string](https://developer.mozilla.org/docs/Web/JavaScript/Re
|
|
|
397
409
|
|
|
398
410
|
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** 
|
|
399
411
|
|
|
400
|
-
## SkeletonNetworkInterface
|
|
401
|
-
|
|
402
|
-
**Extends ServiceOwner**
|
|
403
|
-
|
|
404
|
-
### networkAddresses
|
|
405
|
-
|
|
406
|
-
#### Parameters
|
|
407
|
-
|
|
408
|
-
* `filter` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `n=>true`)
|
|
409
|
-
|
|
410
|
-
Returns **Iterable<[NetworkAddress](#networkaddress)>** 
|
|
411
|
-
|
|
412
412
|
## families
|
|
413
413
|
|
|
414
414
|
Returns **[Set](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** 
|
package/package.json
CHANGED
package/src/base.mjs
CHANGED
|
@@ -430,7 +430,7 @@ export class Base {
|
|
|
430
430
|
root: this.root,
|
|
431
431
|
current: this,
|
|
432
432
|
valueFor: (name, at) =>
|
|
433
|
-
at ===
|
|
433
|
+
typeof at?.value === "function" ? at.value(name) : globals[name],
|
|
434
434
|
...options
|
|
435
435
|
});
|
|
436
436
|
}
|
|
@@ -622,7 +622,7 @@ export class Base {
|
|
|
622
622
|
root: this.root,
|
|
623
623
|
current: this,
|
|
624
624
|
valueFor: (name, at) =>
|
|
625
|
-
at ===
|
|
625
|
+
typeof at?.value === "function" ? at.value(name) : globals[name]
|
|
626
626
|
});
|
|
627
627
|
}
|
|
628
628
|
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
string_collection_attribute_writable,
|
|
6
6
|
string_set_attribute_writable,
|
|
7
7
|
string_attribute_writable,
|
|
8
|
+
string_attribute,
|
|
8
9
|
integer_attribute_writable,
|
|
9
10
|
hostname_attribute as hostname_attribute_base,
|
|
10
11
|
boolean_attribute_writable
|
|
@@ -88,6 +89,8 @@ export const bridges_attribute = {
|
|
|
88
89
|
backpointer: { ...networks_attribute, name: "bridges" }
|
|
89
90
|
};
|
|
90
91
|
|
|
92
|
+
export const family_attribute = { ...string_attribute, name: "family" };
|
|
93
|
+
|
|
91
94
|
export const psk_attribute = { ...string_attribute_writable, name: "psk" };
|
|
92
95
|
export const ssid_attribute = { ...string_attribute_writable, name: "ssid" };
|
|
93
96
|
export const hostname_attribute = {
|
package/src/core-service.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FAMILY_IPV4, FAMILY_IPV6 } from "ip-utilties";
|
|
2
2
|
import {
|
|
3
|
+
string_attribute,
|
|
3
4
|
string_attribute_writable,
|
|
4
5
|
number_attribute_writable,
|
|
5
6
|
string_set_attribute_writable,
|
|
@@ -44,7 +45,8 @@ export const endpointAttributes = {
|
|
|
44
45
|
values: new Set(["tcp", "udp", "quic"])
|
|
45
46
|
},
|
|
46
47
|
types: { ...string_set_attribute_writable, name: "types" },
|
|
47
|
-
tls: { ...boolean_attribute_false, name: "tls" }
|
|
48
|
+
tls: { ...boolean_attribute_false, name: "tls" },
|
|
49
|
+
address: { ...string_attribute, name: "address" }
|
|
48
50
|
};
|
|
49
51
|
|
|
50
52
|
export class CoreService extends Base {
|
package/src/endpoint.mjs
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
import { getAttribute, string_attribute, url_attribute } from "pacc";
|
|
1
2
|
import { FAMILY_IPV6 } from "ip-utilties";
|
|
2
3
|
import { addType } from "pmcf";
|
|
3
4
|
import { endpointAttributes, CoreService } from "./core-service.mjs";
|
|
5
|
+
import { family_attribute } from "./common-attributes.mjs";
|
|
4
6
|
|
|
5
7
|
export const FAMILY_UNIX = "unix";
|
|
6
8
|
export const FAMILY_DNS = "dns";
|
|
7
9
|
|
|
8
10
|
class BaseEndpoint {
|
|
9
|
-
static name = "
|
|
11
|
+
static name = "base_endpoint";
|
|
10
12
|
static priority = 1.1;
|
|
11
13
|
static owners = [CoreService, "network_interface"];
|
|
12
14
|
static key = "type";
|
|
13
|
-
attributes = endpointAttributes;
|
|
15
|
+
static attributes = endpointAttributes;
|
|
14
16
|
|
|
15
17
|
static {
|
|
16
18
|
addType(this);
|
|
@@ -26,6 +28,10 @@ class BaseEndpoint {
|
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
|
|
31
|
+
get fullName() {
|
|
32
|
+
return this.service.fullName + "/" + this.type;
|
|
33
|
+
}
|
|
34
|
+
|
|
29
35
|
get type() {
|
|
30
36
|
return this._type?.name ?? this.service.type;
|
|
31
37
|
}
|
|
@@ -37,12 +43,26 @@ class BaseEndpoint {
|
|
|
37
43
|
toString() {
|
|
38
44
|
return `${this.type}`;
|
|
39
45
|
}
|
|
46
|
+
|
|
47
|
+
attribute(name) {
|
|
48
|
+
return getAttribute(this, name);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
value(name) {
|
|
52
|
+
return this.attribute(name);
|
|
53
|
+
}
|
|
40
54
|
}
|
|
41
55
|
|
|
42
56
|
/**
|
|
43
57
|
* Endpoint with an ip port
|
|
44
58
|
*/
|
|
45
59
|
class PortEndpoint extends BaseEndpoint {
|
|
60
|
+
static name = "port_endpoint";
|
|
61
|
+
|
|
62
|
+
static {
|
|
63
|
+
addType(this);
|
|
64
|
+
}
|
|
65
|
+
|
|
46
66
|
_port;
|
|
47
67
|
constructor(service, data) {
|
|
48
68
|
super(service, data);
|
|
@@ -78,6 +98,15 @@ class PortEndpoint extends BaseEndpoint {
|
|
|
78
98
|
}
|
|
79
99
|
|
|
80
100
|
export class Endpoint extends PortEndpoint {
|
|
101
|
+
static name = "endpoint";
|
|
102
|
+
static attributes = {
|
|
103
|
+
family: family_attribute
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
static {
|
|
107
|
+
addType(this);
|
|
108
|
+
}
|
|
109
|
+
|
|
81
110
|
constructor(service, networkAddress, data) {
|
|
82
111
|
super(service, data);
|
|
83
112
|
this.networkAddress = networkAddress;
|
|
@@ -105,6 +134,15 @@ export class Endpoint extends PortEndpoint {
|
|
|
105
134
|
}
|
|
106
135
|
|
|
107
136
|
export class DomainNameEndpoint extends PortEndpoint {
|
|
137
|
+
static name = "domain_endpoint";
|
|
138
|
+
static attributes = {
|
|
139
|
+
domainName: { ...string_attribute, name: "domainName" }
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
static {
|
|
143
|
+
addType(this);
|
|
144
|
+
}
|
|
145
|
+
|
|
108
146
|
constructor(service, domainName, data) {
|
|
109
147
|
super(service, data);
|
|
110
148
|
this.domainName = domainName;
|
|
@@ -131,6 +169,15 @@ export class DomainNameEndpoint extends PortEndpoint {
|
|
|
131
169
|
* Endpoint based on http
|
|
132
170
|
*/
|
|
133
171
|
export class HTTPEndpoint extends BaseEndpoint {
|
|
172
|
+
static name = "url_endpoint";
|
|
173
|
+
static attributes = {
|
|
174
|
+
url: url_attribute
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
static {
|
|
178
|
+
addType(this);
|
|
179
|
+
}
|
|
180
|
+
|
|
134
181
|
/**
|
|
135
182
|
*
|
|
136
183
|
* @param {Service} service
|
|
@@ -194,6 +241,15 @@ export class HTTPEndpoint extends BaseEndpoint {
|
|
|
194
241
|
}
|
|
195
242
|
|
|
196
243
|
export class UnixEndpoint extends BaseEndpoint {
|
|
244
|
+
static name = "unix_endpoint";
|
|
245
|
+
static attributes = {
|
|
246
|
+
url: url_attribute
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
static {
|
|
250
|
+
addType(this);
|
|
251
|
+
}
|
|
252
|
+
|
|
197
253
|
constructor(service, path, data) {
|
|
198
254
|
super(service, data);
|
|
199
255
|
this.path = path;
|
package/src/host.mjs
CHANGED
|
@@ -246,6 +246,13 @@ export class Host extends ServiceOwner {
|
|
|
246
246
|
return parts[parts.length - 1].toLowerCase();
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
+
get services() {
|
|
250
|
+
return new AggregatedMap([
|
|
251
|
+
this._services,
|
|
252
|
+
...this._networkInterfaces.values().map(ni => ni._services)
|
|
253
|
+
]);
|
|
254
|
+
}
|
|
255
|
+
|
|
249
256
|
get foreignDomainNames() {
|
|
250
257
|
return [...this.aliases].filter(n => n.split(".").length > 1);
|
|
251
258
|
}
|
|
@@ -341,7 +348,6 @@ export class Host extends ServiceOwner {
|
|
|
341
348
|
|
|
342
349
|
if (!this.isTemplate && networkInterface.network) {
|
|
343
350
|
assign(hosts_attribute, networkInterface.network, this);
|
|
344
|
-
//networkInterface.network.hosts = this;
|
|
345
351
|
}
|
|
346
352
|
}
|
|
347
353
|
|
package/src/network-address.mjs
CHANGED
|
@@ -2,13 +2,14 @@ import {
|
|
|
2
2
|
default_attribute,
|
|
3
3
|
string_attribute,
|
|
4
4
|
name_attribute,
|
|
5
|
+
type_attribute,
|
|
5
6
|
getAttribute
|
|
6
7
|
} from "pacc";
|
|
7
|
-
|
|
8
8
|
import { familyIP, formatCIDR, decodeIP, addressType } from "ip-utilties";
|
|
9
9
|
import { Subnet } from "./subnet.mjs";
|
|
10
10
|
import { Owner, addType } from "pmcf";
|
|
11
11
|
import { NetworkInterface } from "./network-interfaces/network-interface.mjs";
|
|
12
|
+
import { family_attribute } from "./common-attributes.mjs";
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
*
|
|
@@ -19,14 +20,14 @@ export class NetworkAddress {
|
|
|
19
20
|
static key = "address";
|
|
20
21
|
static attributes = {
|
|
21
22
|
address: { ...name_attribute, name: "address" },
|
|
22
|
-
type:
|
|
23
|
+
type: type_attribute,
|
|
23
24
|
cidrAddress: { ...string_attribute, name: "cidrAddress" },
|
|
24
25
|
networkInterface: {
|
|
25
26
|
...default_attribute,
|
|
26
27
|
name: "networkInterface",
|
|
27
28
|
type: "network_interface"
|
|
28
29
|
},
|
|
29
|
-
family:
|
|
30
|
+
family: family_attribute
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
static {
|
package/src/services/bind.mjs
CHANGED
|
@@ -20,12 +20,11 @@ import {
|
|
|
20
20
|
} from "pacc";
|
|
21
21
|
import {
|
|
22
22
|
Base,
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
CoreService,
|
|
24
|
+
Endpoint,
|
|
25
25
|
addresses,
|
|
26
26
|
networkAddressType,
|
|
27
|
-
addType
|
|
28
|
-
FAMILY_DNS
|
|
27
|
+
addType
|
|
29
28
|
} from "pmcf";
|
|
30
29
|
import { yesno, writeLines, asArray } from "../utils.mjs";
|
|
31
30
|
import {
|
|
@@ -572,11 +571,13 @@ function addressesStatement(prefix, objects, empty = false, indent = "") {
|
|
|
572
571
|
return [];
|
|
573
572
|
}
|
|
574
573
|
|
|
575
|
-
export class bind extends
|
|
574
|
+
export class bind extends CoreService {
|
|
576
575
|
static attributes = {
|
|
577
576
|
forwarders: {
|
|
578
|
-
...
|
|
579
|
-
|
|
577
|
+
...default_collection_attribute_writable,
|
|
578
|
+
type: Endpoint,
|
|
579
|
+
name: "forwarders",
|
|
580
|
+
deferredExpression: true
|
|
580
581
|
},
|
|
581
582
|
groups: {
|
|
582
583
|
...default_collection_attribute_writable,
|
|
@@ -640,21 +641,18 @@ export class bind extends ExtraSourceService {
|
|
|
640
641
|
return this.primaries ? "secondary" : "primary";
|
|
641
642
|
}
|
|
642
643
|
|
|
643
|
-
get forwarders() {
|
|
644
|
-
const forwarders = serviceEndpoints(this.source, {
|
|
645
|
-
services: "services[types[dns] && priority>=100 && priority<200]",
|
|
646
|
-
endpoints: endpoint => endpoint.family !== FAMILY_DNS,
|
|
647
|
-
select: e => e.address,
|
|
648
|
-
limit: 5
|
|
649
|
-
});
|
|
650
|
-
|
|
651
|
-
return forwarders;
|
|
652
|
-
}
|
|
653
|
-
|
|
654
644
|
async writeForwarders(outputControl) {
|
|
655
|
-
|
|
645
|
+
// TODO formulate everything as pacc expression
|
|
646
|
+
const forwarders = [...this.forwarders]
|
|
647
|
+
.map(e => e.endpoints())
|
|
648
|
+
.flat()
|
|
649
|
+
.filter(e => e.networkAddress)
|
|
650
|
+
.map(e => e.networkAddress?.address);
|
|
656
651
|
|
|
657
652
|
if (forwarders.length) {
|
|
653
|
+
if (forwarders.length > 5) {
|
|
654
|
+
forwarders.length = 5;
|
|
655
|
+
}
|
|
658
656
|
await writeLines(
|
|
659
657
|
join(outputControl.dir, "etc/named/options"),
|
|
660
658
|
`forwarders.conf`,
|