pmcf 1.35.3 → 1.35.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 +26 -17
- package/package.json +1 -1
package/bin/pmcf-named-defs
CHANGED
|
@@ -19,6 +19,10 @@ console.log("depends", "mf-named");
|
|
|
19
19
|
console.log("replaces", "mf-named-zones");
|
|
20
20
|
console.log("description", `named defintions for ${owner.name}`);
|
|
21
21
|
|
|
22
|
+
function fullName(name) {
|
|
23
|
+
return name.endsWith(".") ? name : name + ".";
|
|
24
|
+
}
|
|
25
|
+
|
|
22
26
|
async function generateNamedDefs(owner, targetDir) {
|
|
23
27
|
const dns = owner.dns;
|
|
24
28
|
const ttl = dns.recordTTL;
|
|
@@ -33,20 +37,24 @@ async function generateNamedDefs(owner, targetDir) {
|
|
|
33
37
|
|
|
34
38
|
let maxKeyLength;
|
|
35
39
|
|
|
36
|
-
const createRecord = (key, type,
|
|
40
|
+
const createRecord = (key, type, ...values) => {
|
|
41
|
+
values = values.map(v =>
|
|
42
|
+
typeof v === "number" ? String(v).padStart(3) : v
|
|
43
|
+
);
|
|
44
|
+
|
|
37
45
|
return {
|
|
38
46
|
key,
|
|
39
47
|
toString: () =>
|
|
40
48
|
`${key.padEnd(maxKeyLength, " ")} ${ttl} IN ${type.padEnd(
|
|
41
49
|
5,
|
|
42
50
|
" "
|
|
43
|
-
)} ${
|
|
51
|
+
)} ${values.join(" ")}`
|
|
44
52
|
};
|
|
45
53
|
};
|
|
46
54
|
|
|
47
55
|
for await (const mail of owner.services({ type: "smtp" })) {
|
|
48
56
|
records.add(
|
|
49
|
-
createRecord("@", "MX",
|
|
57
|
+
createRecord("@", "MX", mail.priority, fullName(mail.owner.domainName))
|
|
50
58
|
);
|
|
51
59
|
}
|
|
52
60
|
|
|
@@ -55,10 +63,12 @@ async function generateNamedDefs(owner, targetDir) {
|
|
|
55
63
|
const SOARecord = createRecord(
|
|
56
64
|
"@",
|
|
57
65
|
"SOA",
|
|
58
|
-
|
|
66
|
+
fullName(nameserver?.domainName),
|
|
67
|
+
fullName(rname),
|
|
68
|
+
`(${updates})`
|
|
59
69
|
);
|
|
60
70
|
|
|
61
|
-
const NSRecord = createRecord("@", "NS",
|
|
71
|
+
const NSRecord = createRecord("@", "NS", fullName(nameserver?.ipAddress));
|
|
62
72
|
|
|
63
73
|
const catalogZone = {
|
|
64
74
|
id: `catalog.${domain}`,
|
|
@@ -66,7 +76,7 @@ async function generateNamedDefs(owner, targetDir) {
|
|
|
66
76
|
records: new Set([
|
|
67
77
|
SOARecord,
|
|
68
78
|
NSRecord,
|
|
69
|
-
createRecord(`version.${domain}
|
|
79
|
+
createRecord(fullName(`version.${domain}`), "TXT", '"2"')
|
|
70
80
|
])
|
|
71
81
|
};
|
|
72
82
|
|
|
@@ -101,8 +111,8 @@ async function generateNamedDefs(owner, targetDir) {
|
|
|
101
111
|
if (!hosts.has(host)) {
|
|
102
112
|
zone.records.add(
|
|
103
113
|
createRecord(
|
|
104
|
-
host.domainName
|
|
105
|
-
isIPv4Address(address) ? "A
|
|
114
|
+
fullName(host.domainName),
|
|
115
|
+
isIPv4Address(address) ? "A" : "AAAA",
|
|
106
116
|
normalizeIPAddress(address)
|
|
107
117
|
)
|
|
108
118
|
);
|
|
@@ -110,20 +120,19 @@ async function generateNamedDefs(owner, targetDir) {
|
|
|
110
120
|
for (const service of host.services()) {
|
|
111
121
|
if (service.master && service.alias) {
|
|
112
122
|
zone.records.add(
|
|
113
|
-
createRecord(service.alias, "CNAME",
|
|
123
|
+
createRecord(service.alias, "CNAME", fullName(host.domainName))
|
|
114
124
|
);
|
|
115
125
|
}
|
|
116
126
|
|
|
117
127
|
if (dns.hasSVRRecords && service.srvPrefix) {
|
|
118
128
|
zone.records.add(
|
|
119
129
|
createRecord(
|
|
120
|
-
`${service.srvPrefix}.${host.domainName}
|
|
130
|
+
fullName(`${service.srvPrefix}.${host.domainName}`),
|
|
121
131
|
"SRV",
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}.`
|
|
132
|
+
service.priority,
|
|
133
|
+
service.weight,
|
|
134
|
+
service.port,
|
|
135
|
+
fullName(host.domainName)
|
|
127
136
|
)
|
|
128
137
|
);
|
|
129
138
|
}
|
|
@@ -135,9 +144,9 @@ async function generateNamedDefs(owner, targetDir) {
|
|
|
135
144
|
if (reverseZone) {
|
|
136
145
|
reverseZone.records.add(
|
|
137
146
|
createRecord(
|
|
138
|
-
reverseArpaAddress(address)
|
|
147
|
+
fullName(reverseArpaAddress(address)),
|
|
139
148
|
"PTR",
|
|
140
|
-
|
|
149
|
+
fullName(networkInterface.host.domainName)
|
|
141
150
|
)
|
|
142
151
|
);
|
|
143
152
|
}
|