Comparing version 0.3.8 to 0.3.10
@@ -22,10 +22,8 @@ /* | ||
const mod_bunyan = require('bunyan'); | ||
const mod_bloom = require('bloomfilter'); | ||
const mod_ipaddr = require('ipaddr.js'); | ||
const mod_fs = require('fs'); | ||
const mod_crypto = require('crypto'); | ||
const mod_fs = require('fs'); | ||
const FSM = mod_mooremachine.FSM; | ||
const EventEmitter = mod_events.EventEmitter; | ||
const BloomFilter = mod_bloom.BloomFilter; | ||
@@ -82,13 +80,5 @@ /* | ||
this.r_service = options.service || '_http._tcp'; | ||
this.r_maxres = options.maxDNSConcurrency || 5; | ||
this.r_maxres = options.maxDNSConcurrency || 3; | ||
this.r_defport = options.defaultPort || 80; | ||
/* | ||
* Use a bloom filter to avoid always trying UDP first on names that | ||
* are truncated and only queriable over TCP. This could just be a | ||
* hash, but we don't want to spend a lot of memory on potentially | ||
* remembering every name we ever look up. | ||
*/ | ||
this.r_tcpNeeded = new BloomFilter(8 * 1024, 16); | ||
mod_assert.optionalObject(options.log, 'options.log'); | ||
@@ -145,2 +135,6 @@ this.r_log = options.log || mod_bunyan.createLogger({ | ||
this.r_nsclient = new mod_nsc.DnsClient({ | ||
concurrency: this.r_maxres | ||
}); | ||
this.r_stopping = false; | ||
@@ -644,96 +638,29 @@ | ||
CueBallResolver.prototype.resolve = function (domain, type, timeout) { | ||
var rs = mod_utils.shuffle(this.r_resolvers.slice()). | ||
slice(0, this.r_maxres); | ||
var opts = {}; | ||
opts.domain = domain; | ||
opts.type = type; | ||
opts.timeout = timeout; | ||
opts.resolvers = this.r_resolvers; | ||
var gotAnswer = false; | ||
var errCount = 0; | ||
var self = this; | ||
var prot = 'udp'; | ||
var key = domain + '|' + type; | ||
if (this.r_tcpNeeded.test(key)) | ||
prot = 'tcp'; | ||
var em = new EventEmitter(); | ||
em.send = function () { | ||
em.reqs = rs.map(function (res) { | ||
return (self._dnsLookup(domain, res, type, prot, | ||
timeout, function (err, ans, ttl) { | ||
if (err && err.code === 'NXDOMAIN') | ||
err = new NoRecordsError(domain); | ||
if (err) { | ||
if (++errCount >= rs.length) | ||
em.emit('error', err); | ||
return; | ||
} | ||
if (gotAnswer) | ||
return; | ||
gotAnswer = true; | ||
em.reqs.forEach(function (req) { | ||
req.cancel(); | ||
}); | ||
em.emit('answers', ans, ttl); | ||
})); | ||
}); | ||
self.r_nsclient.lookup(opts, onLookup); | ||
}; | ||
return (em); | ||
}; | ||
CueBallResolver.prototype._dnsLookup = | ||
function (dom, res, type, prot, timeout, cb) { | ||
var self = this; | ||
var req = new mod_nsc.DnsMessage(); | ||
req.addQuestion(dom, type); | ||
req.addEDNS({ maxUDPLength: 1420 }); | ||
var timer = setTimeout(function () { | ||
if (timer !== undefined) { | ||
timer = undefined; | ||
cb(new TimeoutError(dom)); | ||
} | ||
}, timeout); | ||
function onError(err) { | ||
if (timer === undefined) | ||
return; | ||
clearTimeout(timer); | ||
timer = undefined; | ||
cb(err); | ||
} | ||
req.on('error', onError); | ||
req.on('reply', function (msg, done) { | ||
var err = msg.toError(); | ||
if (err && err instanceof mod_nsc.TruncationError && | ||
prot === 'udp') { | ||
self.r_tcpNeeded.add(dom + '|' + type); | ||
var nreq = self._dnsLookup(dom, res, type, 'tcp', | ||
timeout, cb); | ||
clearTimeout(timer); | ||
timer = undefined; | ||
req.cancel = function () { | ||
nreq.cancel(); | ||
}; | ||
done(); | ||
return; | ||
} | ||
function onLookup(err, msg) { | ||
if (err && err.code === 'NXDOMAIN') | ||
err = new NoRecordsError(domain); | ||
if (err) { | ||
done(); | ||
onError(err); | ||
em.emit('error', err); | ||
return; | ||
} | ||
clearTimeout(timer); | ||
timer = undefined; | ||
done(); | ||
var ans; | ||
var answers = msg.getAnswers(); | ||
var minTTL = undefined; | ||
if (type === 'A' || type === 'AAAA') { | ||
var ans = answers.map(function (a) { | ||
ans = answers.map(function (a) { | ||
if (minTTL === undefined || | ||
@@ -748,3 +675,2 @@ a.ttl < minTTL) { | ||
}); | ||
cb(null, ans, minTTL); | ||
@@ -775,3 +701,2 @@ } else if (type === 'SRV') { | ||
}); | ||
cb(null, ans, minTTL); | ||
@@ -781,24 +706,4 @@ } else { | ||
} | ||
}); | ||
var sock; | ||
if (prot === 'udp') { | ||
var family = mod_net.isIPv4(res) ? 'udp4' : 'udp6'; | ||
sock = new mod_nsc.DnsUdpSocket({ family: family }); | ||
} else if (prot === 'tcp') { | ||
sock = new mod_nsc.DnsTcpSocket({ | ||
address: res, | ||
port: 53 | ||
}); | ||
em.emit('answers', ans, minTTL); | ||
} | ||
sock.on('ready', function () { | ||
sock.send(req, { | ||
address: res, | ||
port: 53 | ||
}); | ||
sock.end(); | ||
}); | ||
sock.on('error', onError); | ||
return (req); | ||
}; |
{ | ||
"name": "cueball", | ||
"version": "0.3.8", | ||
"version": "0.3.10", | ||
"description": "", | ||
@@ -8,7 +8,6 @@ "main": "lib/index.js", | ||
"assert-plus": ">=1.0.0 <2.0.0", | ||
"bloomfilter": "0.0.16", | ||
"bunyan": ">=1.5.1 <2.0.0", | ||
"ipaddr.js": ">=1.1.0 <2.0.0", | ||
"mooremachine": ">=1.2.0 <2.0.0", | ||
"named-client": "git://github.com/arekinath/node-named-client#v0.1.2", | ||
"named-client": "git://github.com/arekinath/node-named-client#v0.3.1", | ||
"node-uuid": ">=1.4.7 <2.0.0", | ||
@@ -15,0 +14,0 @@ "restify-clients": ">=1.1.2 <2.0.0", |
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
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable and can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable and can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
8
75270
2006
- Removedbloomfilter@0.0.16
- Removedbloomfilter@0.0.16(transitive)
Updatednamed-client@git://github.com/arekinath/node-named-client#v0.3.1