v1.18.x
Barış Soner Uşaklı 7 years ago
parent da9da8190f
commit b70f328520

@ -71,8 +71,11 @@ Blacklist.test = function (clientIp, callback) {
Blacklist._rules.ipv4.indexOf(clientIp) === -1 && // not explicitly specified in ipv4 list Blacklist._rules.ipv4.indexOf(clientIp) === -1 && // not explicitly specified in ipv4 list
Blacklist._rules.ipv6.indexOf(clientIp) === -1 && // not explicitly specified in ipv6 list Blacklist._rules.ipv6.indexOf(clientIp) === -1 && // not explicitly specified in ipv6 list
!Blacklist._rules.cidr.some(function (subnet) { !Blacklist._rules.cidr.some(function (subnet) {
return addr.match(ipaddr.parseCIDR(subnet)); var cidr = ipaddr.parseCIDR(subnet);
// return ip.cidrSubnet(subnet).contains(clientIp); if (addr.kind() !== cidr[0].kind()) {
return false;
}
return addr.match(cidr);
}) // not in a blacklisted IPv4 or IPv6 cidr range }) // not in a blacklisted IPv4 or IPv6 cidr range
) { ) {
plugins.fireHook('filter:blacklist.test', { // To return test failure, pass back an error in callback plugins.fireHook('filter:blacklist.test', { // To return test failure, pass back an error in callback

@ -72,4 +72,9 @@ describe('blacklist', function () {
assert(blacklist.test('1.1.1.1')); assert(blacklist.test('1.1.1.1'));
done(); done();
}); });
it('should pass ip test and not crash with ipv6 address', function (done) {
assert(!blacklist.test('2001:db8:85a3:0:0:8a2e:370:7334'));
done();
});
}); });

Loading…
Cancel
Save