pmcf 1.23.2 → 1.23.4
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 +56 -59
- package/package.json +1 -1
- package/src/base.mjs +4 -0
- package/src/model.mjs +2 -1
- package/types/base.d.mts +1 -0
- package/types/model.d.mts +0 -1
package/bin/pmcf-named-defs
CHANGED
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { createHmac } from "node:crypto";
|
|
5
|
-
import { Location } from "pmcf";
|
|
6
5
|
import { writeLines, isIPv4Address } from "../src/utils.mjs";
|
|
7
6
|
import { prepare } from "../src/cmd.mjs";
|
|
8
7
|
|
|
9
8
|
const { world, args, options } = prepare();
|
|
10
9
|
|
|
11
|
-
const
|
|
10
|
+
const owner = await world.load(args[0]);
|
|
12
11
|
const updates = [
|
|
13
12
|
Math.ceil(Date.now() / 1000),
|
|
14
13
|
36000,
|
|
@@ -19,78 +18,74 @@ const updates = [
|
|
|
19
18
|
|
|
20
19
|
const NAME_LEN = 35;
|
|
21
20
|
|
|
22
|
-
await generateNamedDefs(
|
|
21
|
+
await generateNamedDefs(owner, options.output);
|
|
23
22
|
|
|
24
23
|
console.log("depends", "mf-named");
|
|
25
24
|
console.log("replaces", "mf-named-zones");
|
|
26
|
-
console.log("description", `named defintions for ${
|
|
25
|
+
console.log("description", `named defintions for ${owner.name}`);
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}*/
|
|
31
|
-
|
|
32
|
-
async function generateNamedDefs(location, targetDir) {
|
|
33
|
-
const dns = location.dns;
|
|
34
|
-
const domain = location.domain;
|
|
27
|
+
async function generateNamedDefs(owner, targetDir) {
|
|
28
|
+
const dns = owner.dns;
|
|
35
29
|
const ttl = dns.recordTTL;
|
|
36
30
|
|
|
37
|
-
|
|
31
|
+
for (const domain of dns.domains) {
|
|
38
32
|
const zones = [];
|
|
39
33
|
const records = new Set();
|
|
40
34
|
|
|
41
|
-
const nameserver = (await
|
|
42
|
-
const rname =
|
|
35
|
+
const nameserver = (await owner.service({ type: "dns" }))?.owner;
|
|
36
|
+
const rname = dns.administratorEmail.replace(/@/, ".");
|
|
37
|
+
|
|
38
|
+
const createRecord = (key, type, value) => {
|
|
39
|
+
return {
|
|
40
|
+
key,
|
|
41
|
+
type,
|
|
42
|
+
value,
|
|
43
|
+
toString: () =>
|
|
44
|
+
`${key.padEnd(NAME_LEN, " ")} ${ttl} IN ${type} ${value}`
|
|
45
|
+
};
|
|
46
|
+
};
|
|
43
47
|
|
|
44
|
-
for await (const mail of
|
|
48
|
+
for await (const mail of owner.services({ type: "smtp" })) {
|
|
45
49
|
records.add(
|
|
46
|
-
|
|
47
|
-
mail.owner.domainName
|
|
48
|
-
}.`
|
|
50
|
+
createRecord("@", "MX", `${mail.priority} ${mail.owner.domainName}.`)
|
|
49
51
|
);
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
console.log(
|
|
54
|
+
console.log(owner.name, domain, nameserver?.hostName, rname);
|
|
55
|
+
|
|
56
|
+
const SOARecord = createRecord(
|
|
57
|
+
"@",
|
|
58
|
+
"SOA",
|
|
59
|
+
`${nameserver?.domainName}. ${rname}. (${updates})`
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const NSRecord = createRecord("@", "NS", `${nameserver?.ipAddress}.`);
|
|
53
63
|
|
|
54
64
|
const catalogZone = {
|
|
55
65
|
id: `catalog.${domain}`,
|
|
56
66
|
file: `catalog.${domain}.zone`,
|
|
57
67
|
records: new Set([
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
`${"@".padEnd(NAME_LEN, " ")} ${ttl} IN NS ${nameserver.ipAddress}.`,
|
|
62
|
-
`${("version." + domain + ".").padEnd(NAME_LEN, " ")} IN TXT "2"`
|
|
68
|
+
SOARecord,
|
|
69
|
+
NSRecord,
|
|
70
|
+
createRecord(`version.${domain}.`, "TXT", '"2"')
|
|
63
71
|
])
|
|
64
72
|
};
|
|
65
73
|
|
|
66
74
|
const zone = {
|
|
67
75
|
id: domain,
|
|
68
76
|
file: `${domain}.zone`,
|
|
69
|
-
records: new Set([
|
|
70
|
-
`${"@".padEnd(NAME_LEN, " ")} ${ttl} IN SOA ${
|
|
71
|
-
nameserver.domainName
|
|
72
|
-
}. ${rname}. (${updates})`,
|
|
73
|
-
`${"@".padEnd(NAME_LEN, " ")} ${ttl} IN NS ${nameserver.ipAddress}.`,
|
|
74
|
-
...records
|
|
75
|
-
])
|
|
77
|
+
records: new Set([SOARecord, NSRecord, ...records])
|
|
76
78
|
};
|
|
77
79
|
zones.push(zone);
|
|
78
80
|
|
|
79
|
-
for (const subnet of
|
|
81
|
+
for (const subnet of owner.subnets()) {
|
|
80
82
|
if (subnet.address) {
|
|
81
83
|
const reverse = reverseAddress(subnet.address);
|
|
82
84
|
const reverseArpa = reverseArpaAddress(subnet.address);
|
|
83
85
|
const zone = {
|
|
84
86
|
id: reverseArpa,
|
|
85
87
|
file: `${reverse}.zone`,
|
|
86
|
-
records: new Set([
|
|
87
|
-
`${"@".padEnd(NAME_LEN, " ")} ${ttl} IN SOA ${
|
|
88
|
-
nameserver.domainName
|
|
89
|
-
}. ${rname}. (${updates})`,
|
|
90
|
-
`${(reverseArpa + ".").padEnd(NAME_LEN, " ")} ${ttl} IN NS ${
|
|
91
|
-
nameserver.domainName
|
|
92
|
-
}.`
|
|
93
|
-
])
|
|
88
|
+
records: new Set([SOARecord, NSRecord])
|
|
94
89
|
};
|
|
95
90
|
zones.push(zone);
|
|
96
91
|
subnet.reverseZone = zone;
|
|
@@ -100,33 +95,34 @@ async function generateNamedDefs(location, targetDir) {
|
|
|
100
95
|
for await (const {
|
|
101
96
|
address,
|
|
102
97
|
networkInterface
|
|
103
|
-
} of
|
|
98
|
+
} of owner.networkAddresses()) {
|
|
104
99
|
const host = networkInterface.host;
|
|
105
100
|
zone.records.add(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
101
|
+
createRecord(
|
|
102
|
+
host.hostName,
|
|
103
|
+
isIPv4Address(address) ? "A " : "AAAA",
|
|
104
|
+
normalizeIPAddress(address)
|
|
105
|
+
)
|
|
109
106
|
);
|
|
110
107
|
|
|
111
108
|
for (const service of host.services()) {
|
|
112
109
|
if (service.master && service.alias) {
|
|
113
110
|
zone.records.add(
|
|
114
|
-
|
|
115
|
-
host.domainName
|
|
116
|
-
}.`
|
|
111
|
+
createRecord(service.alias, "CNAME", `${host.domainName}.`)
|
|
117
112
|
);
|
|
118
113
|
}
|
|
119
114
|
|
|
120
115
|
if (service.srvPrefix) {
|
|
121
116
|
zone.records.add(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
"
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
117
|
+
createRecord(
|
|
118
|
+
`${service.srvPrefix}.${host.domainName}.`,
|
|
119
|
+
"SRV",
|
|
120
|
+
`${String(service.priority).padStart(4)} ${String(
|
|
121
|
+
service.weight
|
|
122
|
+
).padStart(3)} ${String(service.port).padStart(5)} ${
|
|
123
|
+
host.domainName
|
|
124
|
+
}.`
|
|
125
|
+
)
|
|
130
126
|
);
|
|
131
127
|
}
|
|
132
128
|
}
|
|
@@ -135,10 +131,11 @@ async function generateNamedDefs(location, targetDir) {
|
|
|
135
131
|
|
|
136
132
|
if (reverseZone && isIPv4Address(address)) {
|
|
137
133
|
reverseZone.records.add(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
"
|
|
141
|
-
|
|
134
|
+
createRecord(
|
|
135
|
+
reverseArpaAddress(address) + ".",
|
|
136
|
+
"PTR",
|
|
137
|
+
`${networkInterface.host.domainName}.`
|
|
138
|
+
)
|
|
142
139
|
);
|
|
143
140
|
}
|
|
144
141
|
}
|
package/package.json
CHANGED
package/src/base.mjs
CHANGED
package/src/model.mjs
CHANGED
|
@@ -153,7 +153,7 @@ export class Owner extends Base {
|
|
|
153
153
|
bridge.delete(network);
|
|
154
154
|
bridge.add(other);
|
|
155
155
|
other.bridge = bridge;
|
|
156
|
-
this.info("RESOLVE", network, other, bridgeToJSON(bridge));
|
|
156
|
+
//this.info("RESOLVE", network, other, bridgeToJSON(bridge));
|
|
157
157
|
} else {
|
|
158
158
|
this.error(`Unresolvabale bridge network`, network);
|
|
159
159
|
}
|
|
@@ -975,6 +975,7 @@ export class Service extends Base {
|
|
|
975
975
|
return [
|
|
976
976
|
...super.propertyNames,
|
|
977
977
|
"ipAddresses",
|
|
978
|
+
"addresses",
|
|
978
979
|
"port",
|
|
979
980
|
"protocol",
|
|
980
981
|
"alias",
|
package/types/base.d.mts
CHANGED