pmcf 4.30.8 → 5.0.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/bin/pmcf-diagram +1 -1
- package/package.json +7 -7
- package/src/base.mjs +81 -182
- package/src/cluster.mjs +22 -40
- package/src/{network-support.mjs → common-attributes.mjs} +66 -5
- package/src/extra-source-service.mjs +8 -7
- package/src/host.mjs +50 -53
- package/src/initialization-context.mjs +110 -216
- package/src/module.mjs +1 -2
- package/src/network-address.mjs +2 -2
- package/src/network-interfaces/ethernet.mjs +7 -15
- package/src/network-interfaces/loopback.mjs +1 -8
- package/src/network-interfaces/network-interface.mjs +28 -40
- package/src/network-interfaces/skeleton.mjs +14 -9
- package/src/network-interfaces/tun.mjs +0 -5
- package/src/network-interfaces/wireguard.mjs +0 -4
- package/src/network-interfaces/wlan.mjs +7 -18
- package/src/network.mjs +39 -43
- package/src/owner.mjs +120 -236
- package/src/root.mjs +13 -7
- package/src/service-owner.mjs +7 -26
- package/src/service.mjs +32 -19
- package/src/services/alpm.mjs +10 -6
- package/src/services/bind.mjs +73 -79
- package/src/services/chrony.mjs +3 -4
- package/src/services/headscale.mjs +0 -1
- package/src/services/influxdb.mjs +2 -2
- package/src/services/kea.mjs +16 -6
- package/src/services/mosquitto.mjs +4 -1
- package/src/services/openldap.mjs +4 -5
- package/src/services/postfix.mjs +0 -2
- package/src/services/systemd-journal-remote.mjs +12 -2
- package/src/services/systemd-journal-upload.mjs +8 -2
- package/src/services/systemd-journald.mjs +23 -1
- package/src/services/systemd-resolved.mjs +41 -19
- package/src/services/systemd-timesyncd.mjs +32 -10
- package/src/services/tailscale.mjs +0 -1
- package/src/subnet.mjs +38 -34
- package/src/type.mjs +86 -1
- package/src/utils.mjs +2 -2
- package/src/location.mjs +0 -48
|
@@ -12,19 +12,12 @@ const _localDomains = new Set(["localhost"]);
|
|
|
12
12
|
|
|
13
13
|
export class loopback extends SkeletonNetworkInterface {
|
|
14
14
|
static specializationOf = NetworkInterface;
|
|
15
|
+
static commonNamePattern = /^lo\d*$/;
|
|
15
16
|
|
|
16
17
|
static {
|
|
17
18
|
addType(this);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
static isCommonName(name) {
|
|
21
|
-
return name.match(/^lo\d*$/);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
get kind() {
|
|
25
|
-
return this.constructor.name;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
21
|
set scope(v) {}
|
|
29
22
|
get scope() {
|
|
30
23
|
return "host";
|
|
@@ -1,32 +1,31 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import { hasWellKnownSubnet, normalizeIP } from "ip-utilties";
|
|
3
2
|
import {
|
|
4
|
-
default_attribute_writable,
|
|
5
3
|
string_attribute_writable,
|
|
6
|
-
|
|
7
|
-
addType
|
|
4
|
+
default_collection_attribute_writable
|
|
8
5
|
} from "pacc";
|
|
9
|
-
import {
|
|
6
|
+
import { network_attribute } from "../common-attributes.mjs";
|
|
7
|
+
import { Host, cidrAddresses, addType } from "pmcf";
|
|
10
8
|
import {
|
|
11
9
|
networkAttributes,
|
|
12
|
-
networkAddressAttributes
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
networkAddressAttributes,
|
|
11
|
+
hostname_attribute,
|
|
12
|
+
cluster_attribute
|
|
13
|
+
} from "../common-attributes.mjs";
|
|
14
|
+
import { writeLines, sectionLines } from "../utils.mjs";
|
|
15
15
|
import { SkeletonNetworkInterface } from "./skeleton.mjs";
|
|
16
|
-
import { Network } from "../network.mjs";
|
|
17
16
|
import { yesno } from "../utils.mjs";
|
|
18
17
|
|
|
19
18
|
export class NetworkInterface extends SkeletonNetworkInterface {
|
|
20
19
|
static name = "network_interface";
|
|
21
20
|
static owners = [Host];
|
|
21
|
+
static specializationOf = NetworkInterface;
|
|
22
22
|
static specializations = {};
|
|
23
23
|
static factoryFor(owner, value) {
|
|
24
24
|
let st = this.specializations[value.kind];
|
|
25
25
|
|
|
26
|
-
//console.log("factoryFor", owner, value);
|
|
27
26
|
if (!st) {
|
|
28
27
|
for (st of Object.values(this.specializations)) {
|
|
29
|
-
if (st.isCommonName
|
|
28
|
+
if (st.isCommonName(value.name)) {
|
|
30
29
|
break;
|
|
31
30
|
}
|
|
32
31
|
}
|
|
@@ -41,28 +40,26 @@ export class NetworkInterface extends SkeletonNetworkInterface {
|
|
|
41
40
|
return this;
|
|
42
41
|
}
|
|
43
42
|
static attributes = {
|
|
43
|
+
network: network_attribute,
|
|
44
|
+
cluster: cluster_attribute,
|
|
44
45
|
...networkAttributes,
|
|
45
46
|
...networkAddressAttributes,
|
|
46
|
-
hostName:
|
|
47
|
-
ipAddresses:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
owner: false
|
|
47
|
+
hostName: hostname_attribute,
|
|
48
|
+
ipAddresses: {
|
|
49
|
+
...default_collection_attribute_writable,
|
|
50
|
+
type: "ip",
|
|
51
|
+
name: "ipAddresses",
|
|
52
|
+
private: true
|
|
53
53
|
},
|
|
54
|
-
|
|
54
|
+
hwaddr: { ...string_attribute_writable, name: "hwaddr" },
|
|
55
|
+
destination: { ...string_attribute_writable, name: "destination" }
|
|
55
56
|
};
|
|
56
57
|
|
|
57
58
|
static {
|
|
58
59
|
addType(this);
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
_ipAddresses = new Map();
|
|
62
|
+
ipAddresses = new Map();
|
|
66
63
|
_scope;
|
|
67
64
|
_metric;
|
|
68
65
|
_kind;
|
|
@@ -71,22 +68,13 @@ export class NetworkInterface extends SkeletonNetworkInterface {
|
|
|
71
68
|
_class;
|
|
72
69
|
|
|
73
70
|
addSubnet(address) {
|
|
74
|
-
if (
|
|
75
|
-
if (!hasWellKnownSubnet(address)) {
|
|
76
|
-
this.error("Missing network", address);
|
|
77
|
-
}
|
|
78
|
-
} else {
|
|
71
|
+
if (this.network) {
|
|
79
72
|
return this.network.addSubnet(address);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
set ipAddresses(value) {
|
|
88
|
-
for (const address of asArray(value)) {
|
|
89
|
-
this._ipAddresses.set(normalizeIP(address), this.addSubnet(address));
|
|
73
|
+
} else {
|
|
74
|
+
/*if (!hasWellKnownSubnet(address)) {
|
|
75
|
+
this.error("Missing network", address);
|
|
76
|
+
}*/
|
|
77
|
+
return address;
|
|
90
78
|
}
|
|
91
79
|
}
|
|
92
80
|
|
|
@@ -181,7 +169,7 @@ export class NetworkInterface extends SkeletonNetworkInterface {
|
|
|
181
169
|
}
|
|
182
170
|
|
|
183
171
|
get kind() {
|
|
184
|
-
return this.attribute("_kind") ?? this.network?.kind;
|
|
172
|
+
return this.attribute("_kind") ?? this.network?.kind ?? super.kind;
|
|
185
173
|
}
|
|
186
174
|
|
|
187
175
|
async systemdDefinitions(dir, packageData) {
|
|
@@ -9,10 +9,15 @@ import { ServiceOwner } from "../service-owner.mjs";
|
|
|
9
9
|
*
|
|
10
10
|
*/
|
|
11
11
|
export class SkeletonNetworkInterface extends ServiceOwner {
|
|
12
|
-
|
|
13
12
|
static get typeName() {
|
|
14
13
|
return "network_interface";
|
|
15
14
|
}
|
|
15
|
+
|
|
16
|
+
static commonNamePattern = new RegExp(`^${this.name}\d+$`);
|
|
17
|
+
|
|
18
|
+
static isCommonName(name) {
|
|
19
|
+
return this.commonNamePattern.test(name);
|
|
20
|
+
}
|
|
16
21
|
|
|
17
22
|
static {
|
|
18
23
|
addType(this);
|
|
@@ -20,8 +25,8 @@ export class SkeletonNetworkInterface extends ServiceOwner {
|
|
|
20
25
|
|
|
21
26
|
_network;
|
|
22
27
|
|
|
23
|
-
get
|
|
24
|
-
return
|
|
28
|
+
get kind() {
|
|
29
|
+
return this.constructor.name;
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
get host() {
|
|
@@ -31,17 +36,15 @@ export class SkeletonNetworkInterface extends ServiceOwner {
|
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
get services() {
|
|
34
|
-
return
|
|
39
|
+
return this.owner
|
|
40
|
+
? new AggregatedMap([super.services, this.owner.services])
|
|
41
|
+
: super.services;
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
get hosts() {
|
|
38
45
|
return asArray(this.host);
|
|
39
46
|
}
|
|
40
47
|
|
|
41
|
-
get network_interface() {
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
48
|
get domainName() {
|
|
46
49
|
return this.host?.domainName;
|
|
47
50
|
}
|
|
@@ -68,7 +71,9 @@ export class SkeletonNetworkInterface extends ServiceOwner {
|
|
|
68
71
|
}
|
|
69
72
|
|
|
70
73
|
get subnets() {
|
|
71
|
-
return new
|
|
74
|
+
return new Map(
|
|
75
|
+
[...new Set(this.ipAddresses.values())].map(s => [s.name, s])
|
|
76
|
+
);
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
get ipAddresses() {
|
|
@@ -2,15 +2,10 @@ import { addType } from "pacc";
|
|
|
2
2
|
import { NetworkInterface } from "./network-interface.mjs";
|
|
3
3
|
|
|
4
4
|
export class tun extends NetworkInterface {
|
|
5
|
-
static specializationOf = NetworkInterface;
|
|
6
5
|
|
|
7
6
|
static {
|
|
8
7
|
addType(this);
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
get kind() {
|
|
12
|
-
return this.constructor.name;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
10
|
async systemdDefinitions(dir, packageData) {}
|
|
16
11
|
}
|
|
@@ -1,38 +1,27 @@
|
|
|
1
1
|
import { mkdir } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
string_attribute_writable,
|
|
5
|
-
secret_attribute_writable,
|
|
6
|
-
addType
|
|
7
|
-
} from "pacc";
|
|
3
|
+
import { string_attribute_writable, addType } from "pacc";
|
|
8
4
|
import { writeLines, sectionLines } from "../utils.mjs";
|
|
9
|
-
import {
|
|
5
|
+
import { psk_attribute, ssid_attribute } from "../common-attributes.mjs";
|
|
10
6
|
import { ethernet } from "./ethernet.mjs";
|
|
11
7
|
|
|
12
8
|
export class wlan extends ethernet {
|
|
13
|
-
static specializationOf = NetworkInterface;
|
|
14
9
|
static attributes = {
|
|
15
|
-
ssid:
|
|
16
|
-
psk:
|
|
17
|
-
secretName: string_attribute_writable
|
|
10
|
+
ssid: ssid_attribute,
|
|
11
|
+
psk: psk_attribute,
|
|
12
|
+
secretName: { ...string_attribute_writable, name: "secretName" }
|
|
18
13
|
};
|
|
19
14
|
|
|
15
|
+
static commonNamePattern = /^wlan\d*$/;
|
|
16
|
+
|
|
20
17
|
static {
|
|
21
18
|
addType(this);
|
|
22
19
|
}
|
|
23
20
|
|
|
24
|
-
static isCommonName(name) {
|
|
25
|
-
return name.match(/^wlan\d+$/);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
21
|
_ssid;
|
|
29
22
|
_psk;
|
|
30
23
|
_secretName;
|
|
31
24
|
|
|
32
|
-
get kind() {
|
|
33
|
-
return this.constructor.name;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
25
|
set secretName(value) {
|
|
37
26
|
this._secretName = value;
|
|
38
27
|
}
|
package/src/network.mjs
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { addType } from "pmcf";
|
|
1
|
+
import { AggregatedMap } from "aggregated-map";
|
|
2
|
+
import { addType, assign } from "pmcf";
|
|
3
3
|
import { Owner } from "./owner.mjs";
|
|
4
|
+
import {
|
|
5
|
+
networkAttributes,
|
|
6
|
+
bridges_attribute,
|
|
7
|
+
subnets_attribute
|
|
8
|
+
} from "./common-attributes.mjs";
|
|
4
9
|
import { Subnet } from "./subnet.mjs";
|
|
5
|
-
import { networkAttributes } from "./network-support.mjs";
|
|
6
10
|
|
|
7
11
|
export class Network extends Owner {
|
|
8
12
|
static name = "network";
|
|
9
|
-
static owners = [
|
|
13
|
+
static owners = [Owner, "root"];
|
|
10
14
|
static attributes = {
|
|
11
15
|
...networkAttributes,
|
|
12
|
-
|
|
13
|
-
...default_attribute_writable,
|
|
14
|
-
type: Network,
|
|
15
|
-
collection: true,
|
|
16
|
-
owner: false
|
|
17
|
-
},
|
|
18
|
-
gateway: { ...default_attribute_writable, type: "host", owner: false }
|
|
16
|
+
bridges: bridges_attribute
|
|
19
17
|
};
|
|
20
18
|
|
|
21
19
|
static {
|
|
@@ -25,52 +23,50 @@ export class Network extends Owner {
|
|
|
25
23
|
kind;
|
|
26
24
|
scope;
|
|
27
25
|
metric;
|
|
28
|
-
|
|
29
|
-
_bridge;
|
|
26
|
+
bridges = new Set();
|
|
30
27
|
|
|
31
|
-
get
|
|
32
|
-
|
|
28
|
+
get gateway() {
|
|
29
|
+
for (const b of [this, ...this.bridges]) {
|
|
30
|
+
if (b._gateway) {
|
|
31
|
+
return b._gateway;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return subnet.address;
|
|
38
|
-
}
|
|
36
|
+
set gateway(value) {
|
|
37
|
+
this._gateway = value;
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return this;
|
|
44
|
-
}
|
|
45
|
-
return super.networkNamed(name);
|
|
40
|
+
get network() {
|
|
41
|
+
return this;
|
|
46
42
|
}
|
|
47
43
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
object.networks.add(this);
|
|
44
|
+
get address() {
|
|
45
|
+
for (const subnet of this.subnets.values()) {
|
|
46
|
+
return subnet.address;
|
|
52
47
|
}
|
|
53
48
|
}
|
|
54
49
|
|
|
55
50
|
get hosts() {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return hosts;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return super.hosts;
|
|
51
|
+
return this.bridges.size > 0
|
|
52
|
+
? new AggregatedMap(
|
|
53
|
+
[this, ...this.bridges].map(network => network.directHosts)
|
|
54
|
+
)
|
|
55
|
+
: super.hosts;
|
|
65
56
|
}
|
|
66
57
|
|
|
67
|
-
get
|
|
68
|
-
|
|
69
|
-
|
|
58
|
+
get subnets() {
|
|
59
|
+
if (!this._subnets.get("fe80::/64")) {
|
|
60
|
+
const linkLocal = new Subnet("fe80::/64");
|
|
61
|
+
this._subnets.set(linkLocal.address,linkLocal);
|
|
62
|
+
//assign(subnets_attribute, this, linkLocal);
|
|
63
|
+
}
|
|
70
64
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
return this.bridges.size > 0
|
|
66
|
+
? new AggregatedMap(
|
|
67
|
+
[this, ...this.bridges].map(network => network._subnets)
|
|
68
|
+
)
|
|
69
|
+
: super.subnets;
|
|
74
70
|
}
|
|
75
71
|
|
|
76
72
|
set secretName(value) {
|