Comparing version 0.1.0 to 0.2.0
@@ -27,5 +27,6 @@ var dns = require('dns'), | ||
for (i = 0; i < domains.length; i++) { | ||
if (domain.match(domains[i].domain)) { | ||
if (!family || family === domain[i].family) { | ||
return callback(null, domains[i].ip, family); | ||
var entry = domains[i]; | ||
if (domain.match(entry.domain)) { | ||
if (!family || family === entry.family) { | ||
return callback(null, entry.ip, entry.family); | ||
} | ||
@@ -32,0 +33,0 @@ } |
{ | ||
"name": "evil-dns", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Override the IP address returned for one or more domains.", | ||
@@ -5,0 +5,0 @@ "main": "evil-dns.js", |
@@ -6,14 +6,27 @@ var dns = require('dns'); | ||
describe('The method hijacking dns.lookup', function () { | ||
it('handles family-agnostic queries', function (done) { | ||
var error = null; | ||
try { | ||
dns.lookup('nodejs.org', { family: undefined, hints: dns.ADDRCONFIG | dns.V4MAPPED }, function (err) { | ||
expect(err).to.not.exist; | ||
done(); | ||
}); | ||
} catch (err) { | ||
expect(err).to.not.exist; | ||
done(); | ||
} | ||
it('returns the family when doing DNS queries', function (done) { | ||
evilDNS.add('*.foo.com', '1.2.3.4'); | ||
dns.lookup('a.foo.com', {family: undefined, hints: dns.ADDRCONFIG | dns.V4MAPPED}, function (err, addr, family) { | ||
expect(addr).to.equal('1.2.3.4'); | ||
expect(family).to.equal(4); | ||
done(); | ||
}); | ||
}); | ||
it('handles family-agnostic queries', function (done) { | ||
var error = null; | ||
try { | ||
dns.lookup('nodejs.org', {family: undefined, hints: dns.ADDRCONFIG | dns.V4MAPPED}, function (err) { | ||
expect(err).to.not.exist; | ||
done(); | ||
}); | ||
} catch (err) { | ||
expect(err).to.not.exist; | ||
done(); | ||
} | ||
}); | ||
afterEach(function () { | ||
evilDNS.clear(); | ||
}); | ||
}); |
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
5975
148