mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-04 14:50:47 +01:00
closes #5948
This commit is contained in:
@@ -71,8 +71,11 @@ Blacklist.test = function (clientIp, callback) {
|
||||
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.cidr.some(function (subnet) {
|
||||
return addr.match(ipaddr.parseCIDR(subnet));
|
||||
// return ip.cidrSubnet(subnet).contains(clientIp);
|
||||
var cidr = ipaddr.parseCIDR(subnet);
|
||||
if (addr.kind() !== cidr[0].kind()) {
|
||||
return false;
|
||||
}
|
||||
return addr.match(cidr);
|
||||
}) // not in a blacklisted IPv4 or IPv6 cidr range
|
||||
) {
|
||||
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'));
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user