Skip to content

Commit a5e9ee4

Browse files
authored
Merge pull request #2 from lnedry/master
2 parents f50599c + 1f4e415 commit a5e9ee4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// dns-lists plugin
22

3-
const dns = require('dns').promises;
43
const net = require('net');
54
const net_utils = require('haraka-net-utils');
5+
const dnsPromises = require('dns').promises;
6+
const dns = new dnsPromises.Resolver({timeout: 25000, tries: 1});
67

78
exports.disable_allowed = false;
89
let redis_client;
@@ -184,9 +185,9 @@ exports.lookup = async function (ip, zone) {
184185
catch (err) {
185186
this.stats_incr_zone(err, zone, start); // Statistics
186187

187-
if (err.code === dns.NOTFOUND) return; // unlisted, not an error
188+
if (err.code === dnsPromises.NOTFOUND) return; // unlisted, not an error
188189

189-
if (err.code === dns.TIMEOUT) { // list timed out
190+
if (err.code === dnsPromises.TIMEOUT) { // list timed out
190191
this.disable_zone(zone, err.code); // disable it
191192
return
192193
}
@@ -313,9 +314,9 @@ exports.checkZoneNegative = async function (zone, ip) {
313314
}
314315
catch (err) {
315316
switch (err.code) {
316-
case dns.NOTFOUND: // IP not listed
317+
case dnsPromises.NOTFOUND: // IP not listed
317318
return true
318-
case dns.TIMEOUT: // list timed out
319+
case dnsPromises.TIMEOUT: // list timed out
319320
this.disable_zone(zone, err.code)
320321
}
321322
console.error(`${query} -> got err ${err}`)

0 commit comments

Comments
 (0)