migrate blocklist to a txt file
this allows easy copy/pasting of existing deny lists which contain comments and blank lines
This commit is contained in:
@@ -6,6 +6,7 @@ exports = module.exports = {
|
||||
};
|
||||
|
||||
var assert = require('assert'),
|
||||
auditSource = require('../auditsource.js'),
|
||||
BoxError = require('../boxerror.js'),
|
||||
HttpError = require('connect-lastmile').HttpError,
|
||||
HttpSuccess = require('connect-lastmile').HttpSuccess,
|
||||
@@ -22,12 +23,11 @@ function getBlocklist(req, res, next) {
|
||||
function setBlocklist(req, res, next) {
|
||||
assert.strictEqual(typeof req.body, 'object');
|
||||
|
||||
if (!Array.isArray(req.body.blocklist)) return next(new HttpError(400, 'blocklist is required'));
|
||||
if (!req.body.blocklist.every(x => typeof x === 'string')) return next(new HttpError(400, 'blocklist must be array of strings'));
|
||||
if (typeof req.body.blocklist !== 'string') return next(new HttpError(400, 'blocklist must be a string'));
|
||||
|
||||
req.clearTimeout(); // can take a while if there is a lot of network ranges
|
||||
|
||||
network.setBlocklist(req.body.blocklist, function (error) {
|
||||
network.setBlocklist(req.body.blocklist, auditSource.fromRequest(req), function (error) {
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, {}));
|
||||
|
||||
Reference in New Issue
Block a user