Tor middleware #499
|
@ -14,9 +14,9 @@ const torCheck = ({ ip, headers, body }, res, next) => {
|
|||
Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes. Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.
Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine. Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.
Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes. Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.
|
||||
if (ipIsInTorList(ip)) {
|
||||
return res.status('400').json({
|
||||
success: 'false',
|
||||
message: 'Unfortunately this api route is not currently available for tor users. We are working on a solution that will allow tor users to publish in the future.',
|
||||
Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine. Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.
Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes. Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.
|
||||
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.',
|
||||
Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine. Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.
Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes. Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.
|
||||
});
|
||||
};
|
||||
Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine. Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.
Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes. Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.
|
||||
}
|
||||
Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine. Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.
Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes. Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.
|
||||
return next();
|
||||
};
|
||||
|
||||
|
|
|||
Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine. Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.
Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes. Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.
Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine. Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.
Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes. Yeah, I think that would be the better way to handle it. That way the middleware can be placed on any route and response is handled from the middleware, rather than having to handle in all the routes.
|
|
@ -8,6 +8,7 @@ const File = require('./file.js');
|
|||
const Request = require('./request.js');
|
||||
const User = require('./user.js');
|
||||
const Blocked = require('./blocked.js');
|
||||
const Tor = require('./tor.js');
|
||||
|
||||
const {database, username, password} = require('@config/mysqlConfig');
|
||||
if (!database || !username || !password) {
|
||||
|
@ -50,6 +51,7 @@ db['File'] = sequelize.import('File', File);
|
|||
db['Request'] = sequelize.import('Request', Request);
|
||||
db['User'] = sequelize.import('User', User);
|
||||
db['Blocked'] = sequelize.import('Blocked', Blocked);
|
||||
db['Tor'] = sequelize.import('Tor', Tor);
|
||||
|
||||
// run model.association for each model in the db object that has an association
|
||||
logger.info('associating db models...');
|
||||
|
|
14
server/models/tor.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
module.exports = (sequelize, { STRING }) => {
|
||||
return sequelize.define(
|
||||
'Tor',
|
||||
{
|
||||
ip: {
|
||||
type : STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
freezeTableName: true,
|
||||
}
|
||||
);
|
||||
};
|
Maybe you should just stop the request here? Not sure, if there are other routes in that may be blocked in the future it will be simpler to add. If it's gonna be only the /publish route then this is probably fine.