pmcf 2.6.8 → 2.7.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 +2 -2
- package/src/dns-utils.mjs +20 -0
- package/src/host.mjs +17 -12
- package/src/services/dhcp.mjs +24 -6
- package/src/services/dns.mjs +1 -21
- package/types/dns-utils.d.mts +2 -0
- package/types/host.d.mts +1 -0
- package/types/services/dns.d.mts +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmcf",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"pkg-dir": "^8.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@types/node": "^22.
|
|
46
|
+
"@types/node": "^22.14.0",
|
|
47
47
|
"ava": "^6.2.0",
|
|
48
48
|
"c8": "^10.1.3",
|
|
49
49
|
"documentation": "^14.0.3",
|
package/src/dns-utils.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
asIterator,
|
|
3
3
|
decodeIPv6,
|
|
4
4
|
encodeIPv6,
|
|
5
|
+
isIPv6Address,
|
|
5
6
|
normalizeIPAddress
|
|
6
7
|
} from "./utils.mjs";
|
|
7
8
|
|
|
@@ -58,3 +59,22 @@ export function dnsMergeParameters(a, b) {
|
|
|
58
59
|
])
|
|
59
60
|
);
|
|
60
61
|
}
|
|
62
|
+
|
|
63
|
+
export function reverseAddress(address) {
|
|
64
|
+
if (isIPv6Address(address)) {
|
|
65
|
+
return normalizeIPAddress(address)
|
|
66
|
+
.replaceAll(":", "")
|
|
67
|
+
.split("")
|
|
68
|
+
.reverse()
|
|
69
|
+
.join(".");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return address.split(".").reverse().join(".");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function reverseArpaAddress(address) {
|
|
76
|
+
return (
|
|
77
|
+
reverseAddress(address) +
|
|
78
|
+
(isIPv6Address(address) ? ".ip6.arpa" : ".in-addr.arpa")
|
|
79
|
+
);
|
|
80
|
+
}
|
package/src/host.mjs
CHANGED
|
@@ -107,7 +107,7 @@ export class Host extends Base {
|
|
|
107
107
|
if (data.extends) {
|
|
108
108
|
this.finalize(() => {
|
|
109
109
|
for (const host of this.extends) {
|
|
110
|
-
if(host === this) {
|
|
110
|
+
if (host === this) {
|
|
111
111
|
this.error("Cant extend myself");
|
|
112
112
|
}
|
|
113
113
|
host.execFinalize();
|
|
@@ -637,11 +637,13 @@ export class NetworkInterface extends Base {
|
|
|
637
637
|
return this;
|
|
638
638
|
}
|
|
639
639
|
|
|
640
|
+
extendedProperty(name) {
|
|
641
|
+
return this.extends.find(i => i[name])?.[name];
|
|
642
|
+
}
|
|
643
|
+
|
|
640
644
|
get network() {
|
|
641
645
|
return (
|
|
642
|
-
this._network ??
|
|
643
|
-
this.extends.find(i => i.network)?.network ??
|
|
644
|
-
this.host.network
|
|
646
|
+
this._network ?? this.extendedProperty("_network") ?? this.host.network
|
|
645
647
|
);
|
|
646
648
|
}
|
|
647
649
|
|
|
@@ -656,7 +658,7 @@ export class NetworkInterface extends Base {
|
|
|
656
658
|
get scope() {
|
|
657
659
|
return (
|
|
658
660
|
this._scope ??
|
|
659
|
-
this.
|
|
661
|
+
this.extendedProperty("_scope") ??
|
|
660
662
|
this.network?.scope ??
|
|
661
663
|
"global"
|
|
662
664
|
);
|
|
@@ -667,7 +669,7 @@ export class NetworkInterface extends Base {
|
|
|
667
669
|
}
|
|
668
670
|
|
|
669
671
|
get hwaddr() {
|
|
670
|
-
return this._hwaddr ?? this.
|
|
672
|
+
return this._hwaddr ?? this.extendedProperty("_hwaddr");
|
|
671
673
|
}
|
|
672
674
|
|
|
673
675
|
set metric(value) {
|
|
@@ -675,7 +677,12 @@ export class NetworkInterface extends Base {
|
|
|
675
677
|
}
|
|
676
678
|
|
|
677
679
|
get metric() {
|
|
678
|
-
return
|
|
680
|
+
return (
|
|
681
|
+
this._metric ??
|
|
682
|
+
this.extendedProperty("_metric") ??
|
|
683
|
+
this.network?.metric ??
|
|
684
|
+
1004
|
|
685
|
+
);
|
|
679
686
|
}
|
|
680
687
|
|
|
681
688
|
set ssid(value) {
|
|
@@ -683,9 +690,7 @@ export class NetworkInterface extends Base {
|
|
|
683
690
|
}
|
|
684
691
|
|
|
685
692
|
get ssid() {
|
|
686
|
-
return (
|
|
687
|
-
this._ssid ?? this.extends.find(i => i.ssid)?.ssid ?? this.network?.ssid
|
|
688
|
-
);
|
|
693
|
+
return this._ssid ?? this.extendedProperty("_ssid") ?? this.network?.ssid;
|
|
689
694
|
}
|
|
690
695
|
|
|
691
696
|
set psk(value) {
|
|
@@ -693,7 +698,7 @@ export class NetworkInterface extends Base {
|
|
|
693
698
|
}
|
|
694
699
|
|
|
695
700
|
get psk() {
|
|
696
|
-
return this._psk ?? this.
|
|
701
|
+
return this._psk ?? this.extendedProperty("_psk") ?? this.network?.psk;
|
|
697
702
|
}
|
|
698
703
|
|
|
699
704
|
set kind(value) {
|
|
@@ -702,7 +707,7 @@ export class NetworkInterface extends Base {
|
|
|
702
707
|
|
|
703
708
|
get kind() {
|
|
704
709
|
return (
|
|
705
|
-
this._kind ?? this.
|
|
710
|
+
this._kind ?? this.extendedProperty("_kind") ?? this.network?.kind
|
|
706
711
|
);
|
|
707
712
|
}
|
|
708
713
|
}
|
package/src/services/dhcp.mjs
CHANGED
|
@@ -42,6 +42,11 @@ export class DHCPService extends Service {
|
|
|
42
42
|
|
|
43
43
|
console.log("kea", host.name, network.name);
|
|
44
44
|
|
|
45
|
+
const dnsServerAddreses = serviceAddresses(network, {
|
|
46
|
+
type: "dns",
|
|
47
|
+
priority: "<10"
|
|
48
|
+
});
|
|
49
|
+
|
|
45
50
|
const packageData = {
|
|
46
51
|
dir,
|
|
47
52
|
sources: [new FileContentProvider(dir + "/")[Symbol.asyncIterator]()],
|
|
@@ -111,6 +116,16 @@ export class DHCPService extends Service {
|
|
|
111
116
|
}
|
|
112
117
|
};
|
|
113
118
|
|
|
119
|
+
const dnsServersSlot = domains =>
|
|
120
|
+
domains.map(domain => {
|
|
121
|
+
return {
|
|
122
|
+
name: domain,
|
|
123
|
+
"dns-servers": dnsServerAddreses.map(address => {
|
|
124
|
+
return { "ip-address": address };
|
|
125
|
+
})
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
|
|
114
129
|
const ddns = {
|
|
115
130
|
DhcpDdns: {
|
|
116
131
|
"ip-address": "127.0.0.1",
|
|
@@ -120,8 +135,14 @@ export class DHCPService extends Service {
|
|
|
120
135
|
"socket-name": "/run/kea/ddns-ctrl-socket"
|
|
121
136
|
},
|
|
122
137
|
"tsig-keys": [],
|
|
123
|
-
"forward-ddns": {
|
|
124
|
-
|
|
138
|
+
"forward-ddns": {
|
|
139
|
+
"ddns-domains": dnsServersSlot([...this.domains])
|
|
140
|
+
},
|
|
141
|
+
/*
|
|
142
|
+
"reverse-ddns": {
|
|
143
|
+
"ddns-domains": dnsSlot()
|
|
144
|
+
},
|
|
145
|
+
*/
|
|
125
146
|
loggers
|
|
126
147
|
}
|
|
127
148
|
};
|
|
@@ -171,10 +192,7 @@ export class DHCPService extends Service {
|
|
|
171
192
|
"option-data": [
|
|
172
193
|
{
|
|
173
194
|
name: "domain-name-servers",
|
|
174
|
-
data:
|
|
175
|
-
type: "dns",
|
|
176
|
-
priority: "<10"
|
|
177
|
-
}).join(",")
|
|
195
|
+
data: dnsServerAddreses.join(",")
|
|
178
196
|
},
|
|
179
197
|
{
|
|
180
198
|
name: "domain-search",
|
package/src/services/dns.mjs
CHANGED
|
@@ -4,11 +4,10 @@ import { FileContentProvider } from "npm-pkgbuild";
|
|
|
4
4
|
import {
|
|
5
5
|
writeLines,
|
|
6
6
|
isIPv6Address,
|
|
7
|
-
normalizeIPAddress,
|
|
8
7
|
isLinkLocal,
|
|
9
8
|
isLocalhost
|
|
10
9
|
} from "../utils.mjs";
|
|
11
|
-
import { DNSRecord, dnsFullName } from "../dns-utils.mjs";
|
|
10
|
+
import { DNSRecord, dnsFullName, reverseArpaAddress } from "../dns-utils.mjs";
|
|
12
11
|
import { addType } from "../types.mjs";
|
|
13
12
|
import { ServiceTypeDefinition, serviceAddresses } from "../service.mjs";
|
|
14
13
|
import {
|
|
@@ -457,22 +456,3 @@ async function generateZoneDefs(dns, location, packageData) {
|
|
|
457
456
|
);
|
|
458
457
|
}
|
|
459
458
|
}
|
|
460
|
-
|
|
461
|
-
export function reverseAddress(address) {
|
|
462
|
-
if (isIPv6Address(address)) {
|
|
463
|
-
return normalizeIPAddress(address)
|
|
464
|
-
.replaceAll(":", "")
|
|
465
|
-
.split("")
|
|
466
|
-
.reverse()
|
|
467
|
-
.join(".");
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
return address.split(".").reverse().join(".");
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
export function reverseArpaAddress(address) {
|
|
474
|
-
return (
|
|
475
|
-
reverseAddress(address) +
|
|
476
|
-
(isIPv6Address(address) ? ".ip6.arpa" : ".in-addr.arpa")
|
|
477
|
-
);
|
|
478
|
-
}
|
package/types/dns-utils.d.mts
CHANGED
package/types/host.d.mts
CHANGED