pmcf 1.46.2 → 1.46.3
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-named-defs +16 -20
- package/package.json +1 -1
- package/src/base.mjs +12 -4
- package/src/host.mjs +1 -0
- package/src/location.mjs +2 -1
- package/src/owner.mjs +3 -9
- package/src/utils.mjs +1 -1
- package/types/host.d.mts +3 -0
- package/types/location.d.mts +4 -0
- package/types/owner.d.mts +1 -1
package/bin/pmcf-named-defs
CHANGED
|
@@ -4,7 +4,7 @@ import { join } from "node:path";
|
|
|
4
4
|
import { createHmac } from "node:crypto";
|
|
5
5
|
import {
|
|
6
6
|
writeLines,
|
|
7
|
-
|
|
7
|
+
isIPv6Address,
|
|
8
8
|
normalizeIPAddress
|
|
9
9
|
} from "../src/utils.mjs";
|
|
10
10
|
import { prepare } from "../src/cmd.mjs";
|
|
@@ -58,17 +58,7 @@ async function generateNamedDefs(owner, targetDir) {
|
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
...new Set([...owner.networks()].map(n => [...n.subnets()]).flat())
|
|
63
|
-
];
|
|
64
|
-
|
|
65
|
-
console.log(
|
|
66
|
-
owner.fullName,
|
|
67
|
-
domain,
|
|
68
|
-
nameserver?.hostName,
|
|
69
|
-
rname,
|
|
70
|
-
subnets.map(s => `${s.owner.name}/${s.name}`)
|
|
71
|
-
);
|
|
61
|
+
console.log(owner.fullName, domain, nameserver?.hostName, rname);
|
|
72
62
|
const reverseZones = new Map();
|
|
73
63
|
|
|
74
64
|
const SOARecord = createRecord(
|
|
@@ -99,6 +89,7 @@ async function generateNamedDefs(owner, targetDir) {
|
|
|
99
89
|
zones.push(zone);
|
|
100
90
|
|
|
101
91
|
const hosts = new Set();
|
|
92
|
+
const addresses = new Set();
|
|
102
93
|
|
|
103
94
|
for await (const {
|
|
104
95
|
address,
|
|
@@ -107,14 +98,19 @@ async function generateNamedDefs(owner, targetDir) {
|
|
|
107
98
|
} of owner.networkAddresses()) {
|
|
108
99
|
const host = networkInterface.host;
|
|
109
100
|
|
|
110
|
-
if (!
|
|
101
|
+
if (!addresses.has(address)) {
|
|
102
|
+
addresses.add(address);
|
|
103
|
+
|
|
111
104
|
zone.records.add(
|
|
112
105
|
createRecord(
|
|
113
106
|
fullName(host.domainName),
|
|
114
|
-
|
|
107
|
+
isIPv6Address(address) ? "AAAA" : "A",
|
|
115
108
|
normalizeIPAddress(address)
|
|
116
109
|
)
|
|
117
110
|
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (!hosts.has(host)) {
|
|
118
114
|
hosts.add(host);
|
|
119
115
|
for (const service of host.services()) {
|
|
120
116
|
if (service.master && service.alias) {
|
|
@@ -207,20 +203,20 @@ async function generateNamedDefs(owner, targetDir) {
|
|
|
207
203
|
}
|
|
208
204
|
|
|
209
205
|
export function reverseAddress(address) {
|
|
210
|
-
if (
|
|
211
|
-
return address
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return normalizeIPAddress(address)
|
|
206
|
+
if (isIPv6Address(address)) {
|
|
207
|
+
return normalizeIPAddress(address)
|
|
215
208
|
.replaceAll(":", "")
|
|
216
209
|
.split("")
|
|
217
210
|
.reverse()
|
|
218
211
|
.join(".");
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return address.split(".").reverse().join(".");
|
|
219
215
|
}
|
|
220
216
|
|
|
221
217
|
export function reverseArpaAddress(address) {
|
|
222
218
|
return (
|
|
223
219
|
reverseAddress(address) +
|
|
224
|
-
(
|
|
220
|
+
(isIPv6Address(address) ? ".ip6.arpa" : ".in-addr.arpa")
|
|
225
221
|
);
|
|
226
222
|
}
|
package/package.json
CHANGED
package/src/base.mjs
CHANGED
|
@@ -67,16 +67,24 @@ export class Base {
|
|
|
67
67
|
for (const [slotName, typeDef] of Object.entries(
|
|
68
68
|
this.constructor.typeDefinition.properties
|
|
69
69
|
)) {
|
|
70
|
-
|
|
70
|
+
let slot = data[slotName];
|
|
71
71
|
if (slot) {
|
|
72
72
|
delete data[slotName];
|
|
73
73
|
|
|
74
|
-
const type =
|
|
74
|
+
const type =
|
|
75
|
+
typeof typeDef.type === "string"
|
|
76
|
+
? typesByName[typeDef.type]
|
|
77
|
+
: typeDef.type;
|
|
75
78
|
|
|
76
79
|
if (typeDef.collection) {
|
|
77
80
|
if (Array.isArray(slot) || typeof slot === "string") {
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
slot = asArray(slot);
|
|
82
|
+
if (type) {
|
|
83
|
+
for (const item of slot) {
|
|
84
|
+
new type(this, item);
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
this[slotName] = slot;
|
|
80
88
|
}
|
|
81
89
|
} else {
|
|
82
90
|
for (const [objectName, objectData] of Object.entries(slot)) {
|
package/src/host.mjs
CHANGED
|
@@ -310,6 +310,7 @@ export class NetworkInterface extends Base {
|
|
|
310
310
|
ssid: { type: "string" },
|
|
311
311
|
psk: { type: "string" },
|
|
312
312
|
metric: { type: "number" },
|
|
313
|
+
MTU: { type: "number" },
|
|
313
314
|
cidrAddresses: { type: "string", collection: true, writeable: false },
|
|
314
315
|
rawAddresses: { type: "string", collection: true, writeable: false },
|
|
315
316
|
network: { type: "network" },
|
package/src/location.mjs
CHANGED
|
@@ -21,7 +21,8 @@ export class Location extends Owner {
|
|
|
21
21
|
clusters: { type: Cluster, collection: true },
|
|
22
22
|
subnets: { type: Subnet, collection: true },
|
|
23
23
|
dns: { type: DNSService },
|
|
24
|
-
country: { type: "string" }
|
|
24
|
+
country: { type: "string" },
|
|
25
|
+
locales: { type: "string", collection: true }
|
|
25
26
|
}
|
|
26
27
|
};
|
|
27
28
|
}
|
package/src/owner.mjs
CHANGED
|
@@ -171,14 +171,10 @@ export class Owner extends Base {
|
|
|
171
171
|
|
|
172
172
|
const subnets = [...this.subnets()];
|
|
173
173
|
|
|
174
|
-
const subnet = subnets.find(s =>s.matchesAddress(address));
|
|
175
|
-
if(subnet) {
|
|
174
|
+
const subnet = subnets.find(s => s.matchesAddress(address));
|
|
175
|
+
if (subnet) {
|
|
176
176
|
return subnet;
|
|
177
177
|
}
|
|
178
|
-
/*
|
|
179
|
-
if (subnets.length === 1) {
|
|
180
|
-
return subnets[0];
|
|
181
|
-
}*/
|
|
182
178
|
|
|
183
179
|
this.error(
|
|
184
180
|
`Address without subnet ${address}`,
|
|
@@ -277,9 +273,7 @@ export class Owner extends Base {
|
|
|
277
273
|
|
|
278
274
|
*networkAddresses() {
|
|
279
275
|
for (const host of this.hosts()) {
|
|
280
|
-
|
|
281
|
-
yield networkAddresses;
|
|
282
|
-
}
|
|
276
|
+
yield* host.networkAddresses();
|
|
283
277
|
}
|
|
284
278
|
}
|
|
285
279
|
|
package/src/utils.mjs
CHANGED
|
@@ -142,7 +142,7 @@ export function normalizeCIDR(address) {
|
|
|
142
142
|
prefix = "fe80::";
|
|
143
143
|
prefixLength = 64;
|
|
144
144
|
} else {
|
|
145
|
-
const definition =
|
|
145
|
+
const definition = isIPv6Address(prefix) ? ipv6 : ipv4;
|
|
146
146
|
let n = _encode(definition, prefix);
|
|
147
147
|
|
|
148
148
|
if (prefixLength) {
|
package/types/host.d.mts
CHANGED
package/types/location.d.mts
CHANGED
package/types/owner.d.mts
CHANGED
|
@@ -59,7 +59,7 @@ export class Owner extends Base {
|
|
|
59
59
|
clusters(): any;
|
|
60
60
|
addBridge(network: any, destinationNetworks: any): any;
|
|
61
61
|
_resolveBridges(): void;
|
|
62
|
-
networkAddresses(): Generator<any, void,
|
|
62
|
+
networkAddresses(): Generator<any, void, any>;
|
|
63
63
|
domains(): Generator<any, void, unknown>;
|
|
64
64
|
#private;
|
|
65
65
|
}
|