pmcf 1.22.0 → 1.23.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-host-defs +21 -29
- package/package.json +1 -1
- package/src/model.mjs +30 -12
- package/types/model.d.mts +3 -0
package/bin/pmcf-host-defs
CHANGED
|
@@ -43,42 +43,34 @@ async function generateMachineInfo(host, dir) {
|
|
|
43
43
|
async function generateNetworkDefs(host, dir) {
|
|
44
44
|
const networkDir = join(dir, "etc/systemd/network");
|
|
45
45
|
|
|
46
|
-
for (const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
await writeLines(networkDir, `${name}.link`, [
|
|
51
|
-
sectionLines("Match", { MACAddress: network.hwaddr }),
|
|
46
|
+
for (const ni of Object.values(host.networkInterfaces)) {
|
|
47
|
+
if (ni.name !== "eth0" && ni.hwaddr) {
|
|
48
|
+
await writeLines(networkDir, `${ni.name}.link`, [
|
|
49
|
+
sectionLines("Match", { MACAddress: ni.hwaddr }),
|
|
52
50
|
"",
|
|
53
|
-
sectionLines("Link", { Name: name })
|
|
51
|
+
sectionLines("Link", { Name: ni.name })
|
|
54
52
|
]);
|
|
55
53
|
}
|
|
56
54
|
|
|
57
|
-
const networkSections = [
|
|
58
|
-
sectionLines("Match", { Name: name }),
|
|
59
|
-
"",
|
|
60
|
-
sectionLines("Address", {
|
|
61
|
-
Address: network.ipv4 + "/" + network.network.ipv4_netmask
|
|
62
|
-
})
|
|
63
|
-
];
|
|
55
|
+
const networkSections = [sectionLines("Match", { Name: ni.name })];
|
|
64
56
|
|
|
65
|
-
|
|
57
|
+
for (const Address of ni.ipAddressesWithNetmask) {
|
|
66
58
|
networkSections.push(
|
|
67
59
|
"",
|
|
68
60
|
sectionLines("Address", {
|
|
69
|
-
Address
|
|
61
|
+
Address
|
|
70
62
|
})
|
|
71
63
|
);
|
|
72
64
|
}
|
|
73
65
|
|
|
74
|
-
switch (
|
|
66
|
+
switch (ni.kind) {
|
|
75
67
|
case "ethernet":
|
|
76
68
|
case "wifi":
|
|
77
|
-
const routeSectionExtra =
|
|
78
|
-
? { Destination:
|
|
69
|
+
const routeSectionExtra = ni.destination
|
|
70
|
+
? { Destination: ni.destination }
|
|
79
71
|
: { Gateway: host.location.gateway_ipv4 };
|
|
80
72
|
|
|
81
|
-
const networkSectionExtra =
|
|
73
|
+
const networkSectionExtra = ni.arpbridge
|
|
82
74
|
? {
|
|
83
75
|
IPForward: "yes",
|
|
84
76
|
IPv4ProxyARP: "yes"
|
|
@@ -98,8 +90,8 @@ async function generateNetworkDefs(host, dir) {
|
|
|
98
90
|
"",
|
|
99
91
|
sectionLines("Route", {
|
|
100
92
|
...routeSectionExtra,
|
|
101
|
-
Scope:
|
|
102
|
-
Metric:
|
|
93
|
+
Scope: ni.scope,
|
|
94
|
+
Metric: ni.metric,
|
|
103
95
|
InitialCongestionWindow: 20,
|
|
104
96
|
InitialAdvertisedReceiveWindow: 20
|
|
105
97
|
}),
|
|
@@ -112,7 +104,7 @@ async function generateNetworkDefs(host, dir) {
|
|
|
112
104
|
})
|
|
113
105
|
);
|
|
114
106
|
|
|
115
|
-
if (
|
|
107
|
+
if (ni.arpbridge) {
|
|
116
108
|
networkSections.push(
|
|
117
109
|
"",
|
|
118
110
|
sectionLines("Link", { Promiscuous: "yes" })
|
|
@@ -120,9 +112,9 @@ async function generateNetworkDefs(host, dir) {
|
|
|
120
112
|
}
|
|
121
113
|
}
|
|
122
114
|
|
|
123
|
-
await writeLines(networkDir, `${name}.network`, networkSections);
|
|
115
|
+
await writeLines(networkDir, `${ni.name}.network`, networkSections);
|
|
124
116
|
|
|
125
|
-
switch (
|
|
117
|
+
switch (ni?.kind) {
|
|
126
118
|
case "wireguard":
|
|
127
119
|
{
|
|
128
120
|
}
|
|
@@ -131,21 +123,21 @@ async function generateNetworkDefs(host, dir) {
|
|
|
131
123
|
const d = join(dir, "etc/wpa_supplicant");
|
|
132
124
|
await mkdir(d, { recursive: true });
|
|
133
125
|
writeFile(
|
|
134
|
-
join(d, `wpa_supplicant-${name}.conf`),
|
|
126
|
+
join(d, `wpa_supplicant-${ni.name}.conf`),
|
|
135
127
|
`country=${host.location.country}
|
|
136
128
|
ctrl_interface=DIR=/run/wpa_supplicant GROUP=netdev
|
|
137
129
|
update_config=1
|
|
138
130
|
p2p_disabled=1
|
|
139
131
|
network={
|
|
140
|
-
ssid="${
|
|
141
|
-
psk=${
|
|
132
|
+
ssid="${ni.ssid}"
|
|
133
|
+
psk=${ni.psk}
|
|
142
134
|
scan_ssid=1
|
|
143
135
|
}`,
|
|
144
136
|
"utf8"
|
|
145
137
|
);
|
|
146
138
|
|
|
147
139
|
host.postinstall.push(
|
|
148
|
-
`systemctl enable wpa_supplicant@${name}.service`
|
|
140
|
+
`systemctl enable wpa_supplicant@${ni.name}.service`
|
|
149
141
|
);
|
|
150
142
|
}
|
|
151
143
|
}
|
package/package.json
CHANGED
package/src/model.mjs
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { readFile, glob } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
asArray,
|
|
5
|
+
bridgeToJSON,
|
|
6
|
+
isIPv4Address,
|
|
7
|
+
isIPv6Address
|
|
8
|
+
} from "./utils.mjs";
|
|
4
9
|
import { Base } from "./base.mjs";
|
|
5
10
|
import { DNSService } from "./dns.mjs";
|
|
6
11
|
|
|
@@ -696,6 +701,7 @@ export class NetworkInterface extends Base {
|
|
|
696
701
|
#ssid;
|
|
697
702
|
#psk;
|
|
698
703
|
#network;
|
|
704
|
+
#kind;
|
|
699
705
|
arpbridge;
|
|
700
706
|
hwaddr;
|
|
701
707
|
|
|
@@ -707,11 +713,6 @@ export class NetworkInterface extends Base {
|
|
|
707
713
|
delete data.ipv4;
|
|
708
714
|
}
|
|
709
715
|
|
|
710
|
-
if (data["link-local-ipv6"]) {
|
|
711
|
-
this.#ipAddresses.push(...asArray(data["link-local-ipv6"]));
|
|
712
|
-
delete data["link-local-ipv6"];
|
|
713
|
-
}
|
|
714
|
-
|
|
715
716
|
if (data.ipv6) {
|
|
716
717
|
this.#ipAddresses.push(...asArray(data.ipv6));
|
|
717
718
|
delete data.ipv6;
|
|
@@ -736,7 +737,11 @@ export class NetworkInterface extends Base {
|
|
|
736
737
|
}
|
|
737
738
|
if (data.metric) {
|
|
738
739
|
this.#metric = data.metric;
|
|
739
|
-
delete data.
|
|
740
|
+
delete data.metric;
|
|
741
|
+
}
|
|
742
|
+
if (data.kind) {
|
|
743
|
+
this.#kind = data.kind;
|
|
744
|
+
delete data.kind;
|
|
740
745
|
}
|
|
741
746
|
|
|
742
747
|
if (data.network) {
|
|
@@ -765,13 +770,17 @@ export class NetworkInterface extends Base {
|
|
|
765
770
|
return this.#ipAddresses;
|
|
766
771
|
}
|
|
767
772
|
|
|
768
|
-
get
|
|
769
|
-
|
|
773
|
+
get ipAddressesWithNetmask() {
|
|
774
|
+
return this.#ipAddresses.map(a =>
|
|
775
|
+
isIPv4Address(a) ? `${a}/${this.network.ipv4_netmask}` : a
|
|
776
|
+
);
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
get ipv4Addresses() {
|
|
770
780
|
return this.#ipAddresses.filter(a => isIPv4Address(a));
|
|
771
781
|
}
|
|
772
782
|
|
|
773
|
-
get ipv6Addresses()
|
|
774
|
-
{
|
|
783
|
+
get ipv6Addresses() {
|
|
775
784
|
return this.#ipAddresses.filter(a => isIPv6Address(a));
|
|
776
785
|
}
|
|
777
786
|
|
|
@@ -814,6 +823,10 @@ export class NetworkInterface extends Base {
|
|
|
814
823
|
return this.#psk || this.network?.psk;
|
|
815
824
|
}
|
|
816
825
|
|
|
826
|
+
get kind() {
|
|
827
|
+
return this.#kind || this.network?.kind;
|
|
828
|
+
}
|
|
829
|
+
|
|
817
830
|
get propertyNames() {
|
|
818
831
|
return [
|
|
819
832
|
...super.propertyNames,
|
|
@@ -824,7 +837,8 @@ export class NetworkInterface extends Base {
|
|
|
824
837
|
"psk",
|
|
825
838
|
"scope",
|
|
826
839
|
"metric",
|
|
827
|
-
"ipAddresses"
|
|
840
|
+
"ipAddresses",
|
|
841
|
+
"kind"
|
|
828
842
|
];
|
|
829
843
|
}
|
|
830
844
|
}
|
|
@@ -941,6 +955,10 @@ export class Service extends Base {
|
|
|
941
955
|
return this.#ipAddresses || this.owner.ipAddresses;
|
|
942
956
|
}
|
|
943
957
|
|
|
958
|
+
get addresses() {
|
|
959
|
+
return this.ipAddresses.map(a => `${a}:${this.port}`);
|
|
960
|
+
}
|
|
961
|
+
|
|
944
962
|
get port() {
|
|
945
963
|
return this.#port || ServiceTypes[this.type]?.port;
|
|
946
964
|
}
|
package/types/model.d.mts
CHANGED
|
@@ -101,12 +101,14 @@ export class NetworkInterface extends Base {
|
|
|
101
101
|
set network(networkOrName: any);
|
|
102
102
|
get network(): any;
|
|
103
103
|
get ipAddresses(): any[];
|
|
104
|
+
get ipAddressesWithNetmask(): any[];
|
|
104
105
|
get ipv4Addresses(): any[];
|
|
105
106
|
get ipv6Addresses(): any[];
|
|
106
107
|
get scope(): any;
|
|
107
108
|
get metric(): any;
|
|
108
109
|
get ssid(): any;
|
|
109
110
|
get psk(): any;
|
|
111
|
+
get kind(): any;
|
|
110
112
|
#private;
|
|
111
113
|
}
|
|
112
114
|
export class Subnet extends Base {
|
|
@@ -118,6 +120,7 @@ export class Service extends Base {
|
|
|
118
120
|
get protocol(): any;
|
|
119
121
|
get srvPrefix(): string;
|
|
120
122
|
get ipAddresses(): any;
|
|
123
|
+
get addresses(): any;
|
|
121
124
|
get port(): any;
|
|
122
125
|
get priority(): any;
|
|
123
126
|
get weight(): any;
|