Comparing version 2.5.0 to 2.5.1
@@ -386,2 +386,9 @@ /* | ||
/* | ||
* Set to true if we've ever seen a successful SRV or A/AAAA response | ||
* before. Used for anti-flapping. | ||
*/ | ||
this.r_haveSeenSRV = false; | ||
this.r_haveSeenAddr = false; | ||
FSM.call(this, 'init'); | ||
@@ -525,2 +532,3 @@ | ||
self.r_lastSrvTtl = ttl; | ||
self.r_haveSeenSRV = true; | ||
@@ -574,3 +582,3 @@ var oldLookup = {}; | ||
*/ | ||
self.r_log.trace('nameserver returned NOTIMP ' + | ||
self.r_log.info('nameserver returned NOTIMP ' + | ||
'to SRV lookup on %s, will not retry SRV ' + | ||
@@ -590,3 +598,3 @@ 'for 60 min', self.r_service); | ||
self.r_log.trace('no SRV records found for service ' + | ||
self.r_log.info('no SRV records found for service ' + | ||
'%s, trying as a plain name', self.r_service); | ||
@@ -633,7 +641,2 @@ | ||
/* | ||
* Retry in one TTL. Don't proceed to try A/AAAA lookups, to | ||
* avoid flapping back and forth between SRV and A/AAAA mode | ||
* on a service. | ||
*/ | ||
var d = new Date(); | ||
@@ -644,2 +647,40 @@ d.setTime(d.getTime() + 1000*self.r_lastSrvTtl); | ||
/* | ||
* Anti-flapping measure: we avoid falling back to A/AAAA mode | ||
* unless this is the very first SRV lookup we ever tried and | ||
* it failed after all retries. | ||
* | ||
* We have to keep the fall back on initial SRV failure (even | ||
* though it can cause a nasty flap further into resolver | ||
* operation), because node-moray requires this to work (it | ||
* sets the SRV timeout to 1ms and expects this to result in | ||
* a fall-through to A record operation). | ||
* | ||
* This wasn't meant to be part of the promised API, but it | ||
* is now! | ||
*/ | ||
if (!self.r_haveSeenSRV && !self.r_haveSeenAddr) { | ||
self.r_log.debug('no SRV records found for service ' + | ||
'%s, trying as a plain name', self.r_service); | ||
S.gotoState('aaaa'); | ||
return; | ||
} else if (!self.r_haveSeenSRV) { | ||
self.r_log.info('no SRV records found for service ' + | ||
'%s, falling back to A/AAAA for 15min', | ||
self.r_service); | ||
/* | ||
* We use 15 mins here so that if there's going to be | ||
* a flap back to SRV due to an initial timeout | ||
* (caused by e.g. a network glitch), it will happen in | ||
* the first hour or so of operation. | ||
*/ | ||
d = new Date(); | ||
d.setTime(d.getTime() + 1000*60*15); | ||
self.r_nextService = d; | ||
S.gotoState('aaaa'); | ||
return; | ||
} | ||
/* | ||
* Make sure the next time we wake up is for SRV still, not | ||
@@ -742,2 +783,4 @@ * A or AAAA. | ||
self.r_haveSeenAddr = true; | ||
srv.expiry_v6 = d; | ||
@@ -861,2 +904,4 @@ srv.addresses_v6 = ans.map(function (v) { | ||
self.r_haveSeenAddr = true; | ||
srv.expiry_v4 = d; | ||
@@ -863,0 +908,0 @@ srv.addresses_v4 = ans.map(function (v) { |
{ | ||
"name": "cueball", | ||
"version": "2.5.0", | ||
"version": "2.5.1", | ||
"description": "manage a pool of connections to a multi-node service where nodes are listed in DNS", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
189561
5136