spee.ch/server/middleware/torCheckMiddleware.js

24 lines
570 B
JavaScript
Raw Normal View History

2018-06-27 23:23:14 +02:00
const logger = require('winston');
2018-06-28 00:01:40 +02:00
function ipIsInTorList (ip) {
return true;
}
const torCheck = ({ ip, headers, body }, res, next) => {
logger.debug(`tor check for:`, {
ip,
headers,
body,
});
// check the tor node list
if (ipIsInTorList(ip)) {
return res.status('400').json({
success: 'false',
2018-06-28 00:11:25 +02:00
message: 'Unfortunately this api route is not currently available for tor users. We are working on a solution that will allow tor users to use this endpoint in the future.',
2018-06-28 00:01:40 +02:00
});
2018-06-28 00:11:25 +02:00
}
2018-06-28 00:01:40 +02:00
return next();
2018-06-27 23:23:14 +02:00
};
module.exports = torCheck;