From e756584837b35d59a29d78ef41b1793c2d2ea3af Mon Sep 17 00:00:00 2001 From: Nick Krecklow Date: Thu, 14 May 2020 20:43:14 -0500 Subject: [PATCH] optimize skipSrvTimeout handling --- lib/dns.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/dns.js b/lib/dns.js index f8bb69b..c177284 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -52,7 +52,12 @@ class DNSResolver { // Test if the error indicates a miss, or if the records returned are empty if ((err && (err.code === 'ENOTFOUND' || err.code === 'ENODATA')) || !records || records.length === 0) { - if (!this._isSkipSrv()) { + // Compare config.skipSrvTimeout directly since SKIP_SRV_TIMEOUT has an or'd value + const isSkipSrvTimeoutActive = typeof config.skipSrvTimeout !== 'number' || config.skipSrvTimeout > 0 + + // Only activate _skipSrv if the skipSrvTimeout value is either NaN or > 0 + // 0 represents a disabled flag + if (!this._isSkipSrv() && !isSkipSrvTimeoutActive) { this._skipSrv() logger.log('warn', 'No SRV records were resolved for %s. Minetrack will skip attempting to resolve %s SRV records for %d minutes.', this._ip, this._ip, SKIP_SRV_TIMEOUT / (60 * 1000))