introduced new hook filter:blacklist.test

v1.18.x
Julian Lam 8 years ago
parent 0498832317
commit 8346130cdc

@ -7,6 +7,7 @@ var async = require('async');
var db = require('../database'); var db = require('../database');
var pubsub = require('../pubsub'); var pubsub = require('../pubsub');
var plugins = require('../plugins');
var Blacklist = { var Blacklist = {
_rules: [], _rules: [],
@ -62,11 +63,16 @@ Blacklist.test = function (clientIp, callback) {
}) && // not in a blacklisted IPv4 cidr range }) && // not in a blacklisted IPv4 cidr range
!ipRangeCheck(clientIp, Blacklist._rules.cidr6) // not in a blacklisted IPv6 cidr range !ipRangeCheck(clientIp, Blacklist._rules.cidr6) // not in a blacklisted IPv6 cidr range
) { ) {
if (typeof callback === 'function') { plugins.fireHook('filter:blacklist.test', {
setImmediate(callback); ip: clientIp,
} else { result: false,
return false; }, function (err, data) {
} if (typeof callback === 'function') {
callback(err);
} else {
return data.result;
}
});
} else { } else {
var err = new Error('[[error:blacklisted-ip]]'); var err = new Error('[[error:blacklisted-ip]]');
err.code = 'blacklisted-ip'; err.code = 'blacklisted-ip';

Loading…
Cancel
Save