Tor middleware #499

Merged
bones7242 merged 16 commits from tor-middleware into master 2018-06-29 02:59:56 +02:00
3 changed files with 18 additions and 2 deletions
Showing only changes of commit bcca1e1df2 - Show all commits

View file

@ -14,9 +14,9 @@ const torCheck = ({ ip, headers, body }, res, next) => {
neb-b commented 2018-06-28 23:38:26 +02:00 (Migrated from github.com)
Review

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.
bones7242 commented 2018-06-29 02:22:00 +02:00 (Migrated from github.com)
Review

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.
neb-b commented 2018-06-28 23:38:26 +02:00 (Migrated from github.com)
Review

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.
bones7242 commented 2018-06-29 02:22:00 +02:00 (Migrated from github.com)
Review

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.',
neb-b commented 2018-06-28 23:38:26 +02:00 (Migrated from github.com)
Review

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.
bones7242 commented 2018-06-29 02:22:00 +02:00 (Migrated from github.com)
Review

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.',
neb-b commented 2018-06-28 23:38:26 +02:00 (Migrated from github.com)
Review

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.
bones7242 commented 2018-06-29 02:22:00 +02:00 (Migrated from github.com)
Review

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.
});
};
neb-b commented 2018-06-28 23:38:26 +02:00 (Migrated from github.com)
Review

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.
bones7242 commented 2018-06-29 02:22:00 +02:00 (Migrated from github.com)
Review

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.
}
neb-b commented 2018-06-28 23:38:26 +02:00 (Migrated from github.com)
Review

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.
bones7242 commented 2018-06-29 02:22:00 +02:00 (Migrated from github.com)
Review

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();
};

neb-b commented 2018-06-28 23:38:26 +02:00 (Migrated from github.com)
Review

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.
bones7242 commented 2018-06-29 02:22:00 +02:00 (Migrated from github.com)
Review

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.
neb-b commented 2018-06-28 23:38:26 +02:00 (Migrated from github.com)
Review

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.
bones7242 commented 2018-06-29 02:22:00 +02:00 (Migrated from github.com)
Review

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.

View file

@ -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
View file

@ -0,0 +1,14 @@
module.exports = (sequelize, { STRING }) => {
return sequelize.define(
'Tor',
{
ip: {
type : STRING,
allowNull: false,
},
},
{
freezeTableName: true,
}
);
};