pending-dns 1.2.4 → 1.2.5
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/config/default.toml +8 -0
- package/lib/dns-handler.js +33 -6
- package/package.json +1 -1
package/config/default.toml
CHANGED
|
@@ -66,6 +66,14 @@ retry = 600
|
|
|
66
66
|
expiration = 604800
|
|
67
67
|
minimum = 60
|
|
68
68
|
|
|
69
|
+
# Text to return for chaos requests
|
|
70
|
+
# Disabled by default
|
|
71
|
+
[chaos]
|
|
72
|
+
#"version.bind" = "PendingDNS"
|
|
73
|
+
#"hostname.bind" = "forbidden.lan"
|
|
74
|
+
#"id.server" = "forbidden.lan"
|
|
75
|
+
#"authors.bind" = ["Andris Reinman"]
|
|
76
|
+
|
|
69
77
|
# Resolver for external DNS queries, set ns=false to use system default
|
|
70
78
|
# Mostly used for ANAME resolving
|
|
71
79
|
[resolver]
|
package/lib/dns-handler.js
CHANGED
|
@@ -164,6 +164,31 @@ const processQuestion = async (response, question, domain, depth) => {
|
|
|
164
164
|
response.answers.push(entry);
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
// Chaos responses
|
|
168
|
+
if (
|
|
169
|
+
question.class === dns2.Packet.CLASS.CH &&
|
|
170
|
+
questionTypeStr === 'TXT' &&
|
|
171
|
+
question.class === dns2.Packet.CLASS.CH &&
|
|
172
|
+
config.chaos &&
|
|
173
|
+
domain in config.chaos
|
|
174
|
+
) {
|
|
175
|
+
for (let entry of [].concat(config.chaos[domain] || [])) {
|
|
176
|
+
response.answers.push({
|
|
177
|
+
name: domain,
|
|
178
|
+
type: 'TXT',
|
|
179
|
+
data: formatTXTData(entry),
|
|
180
|
+
ttl: 0,
|
|
181
|
+
class: dns2.Packet.CLASS.CH
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
response.authorities.push({
|
|
185
|
+
name: domain,
|
|
186
|
+
type: 'NS',
|
|
187
|
+
ns: domain,
|
|
188
|
+
ttl: 0,
|
|
189
|
+
class: dns2.Packet.CLASS.CH
|
|
190
|
+
});
|
|
191
|
+
}
|
|
167
192
|
return;
|
|
168
193
|
}
|
|
169
194
|
|
|
@@ -366,12 +391,14 @@ const dnsHandler = async request => {
|
|
|
366
391
|
});
|
|
367
392
|
|
|
368
393
|
// normalize answers for the DNS library
|
|
369
|
-
response.answers.
|
|
370
|
-
answer
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
394
|
+
for (let responseType of [response.answers, response.authorities]) {
|
|
395
|
+
responseType.forEach(answer => {
|
|
396
|
+
answer.type = dns2.Packet.TYPE[answer.type];
|
|
397
|
+
answer.class = typeof answer.class === 'number' ? answer.class : dns2.Packet.CLASS.IN;
|
|
398
|
+
answer.name = punycode.toASCII(answer.name);
|
|
399
|
+
answer.ttl = typeof answer.ttl === 'number' && answer.ttl >= 0 ? answer.ttl : config.dns.ttl;
|
|
400
|
+
});
|
|
401
|
+
}
|
|
375
402
|
|
|
376
403
|
return response;
|
|
377
404
|
};
|