Merge branch 'master' into refresh-blocked-list-on-start
This commit is contained in:
commit
9a1c319f82
4 changed files with 32 additions and 31 deletions
|
@ -26,6 +26,7 @@ const claimPublish = ({ body, files, headers, ip, originalUrl, user, tor }, res)
|
||||||
logger.info('Publish request:', {
|
logger.info('Publish request:', {
|
||||||
ip,
|
ip,
|
||||||
headers,
|
headers,
|
||||||
|
body,
|
||||||
});
|
});
|
||||||
// check for disabled publishing
|
// check for disabled publishing
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
|
@ -34,17 +35,6 @@ const claimPublish = ({ body, files, headers, ip, originalUrl, user, tor }, res)
|
||||||
message: disabledMessage
|
message: disabledMessage
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// check for tor
|
|
||||||
logger.debug('tor:', tor);
|
|
||||||
if (tor) {
|
|
||||||
logger.info('Tor publish request blocked:', ip);
|
|
||||||
const failureResponse = {
|
|
||||||
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 use this endpoint in the future.',
|
|
||||||
};
|
|
||||||
return res.status(403).json(failureResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
// define variables
|
// define variables
|
||||||
let channelName, channelId, channelPassword, description, fileName, filePath, fileType, gaStartTime, license, name, nsfw, thumbnail, thumbnailFileName, thumbnailFilePath, thumbnailFileType, title;
|
let channelName, channelId, channelPassword, description, fileName, filePath, fileType, gaStartTime, license, name, nsfw, thumbnail, thumbnailFileName, thumbnailFilePath, thumbnailFileType, title;
|
||||||
// record the start time of the request
|
// record the start time of the request
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const { apiHost, apiPort } = require('@config/lbryConfig');
|
const { apiHost, apiPort, getTimeout } = require('@config/lbryConfig');
|
||||||
const lbrynetUri = 'http://' + apiHost + ':' + apiPort;
|
const lbrynetUri = 'http://' + apiHost + ':' + apiPort;
|
||||||
const { chooseGaLbrynetPublishLabel, sendGATimingEvent } = require('../utils/googleAnalytics.js');
|
const { chooseGaLbrynetPublishLabel, sendGATimingEvent } = require('../utils/googleAnalytics.js');
|
||||||
const handleLbrynetResponse = require('./utils/handleLbrynetResponse.js');
|
const handleLbrynetResponse = require('./utils/handleLbrynetResponse.js');
|
||||||
|
@ -31,7 +31,10 @@ module.exports = {
|
||||||
axios
|
axios
|
||||||
.post(lbrynetUri, {
|
.post(lbrynetUri, {
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: { uri, timeout: 20 },
|
params: {
|
||||||
|
uri,
|
||||||
|
timeout: getTimeout || 30,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
sendGATimingEvent('lbrynet', 'getClaim', 'GET', gaStartTime, Date.now());
|
sendGATimingEvent('lbrynet', 'getClaim', 'GET', gaStartTime, Date.now());
|
||||||
|
|
|
@ -13,8 +13,16 @@ const torCheck = (req, res, next) => {
|
||||||
})
|
})
|
||||||
.then(result => {
|
.then(result => {
|
||||||
logger.debug('tor check results:', result);
|
logger.debug('tor check results:', result);
|
||||||
req['tor'] = (result.length >= 1); // add this to the req object
|
if (result.length >= 1) {
|
||||||
next();
|
logger.info('Tor request blocked:', ip);
|
||||||
|
const failureResponse = {
|
||||||
|
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 use this endpoint in the future.',
|
||||||
|
};
|
||||||
|
res.status(403).json(failureResponse);
|
||||||
|
} else {
|
||||||
|
next();
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
|
|
|
@ -23,27 +23,27 @@ const getBlockedList = require('../../controllers/api/blocked');
|
||||||
|
|
||||||
module.exports = (app) => {
|
module.exports = (app) => {
|
||||||
// channel routes
|
// channel routes
|
||||||
app.get('/api/channel/availability/:name', channelAvailability);
|
app.get('/api/channel/availability/:name', torCheckMiddleware, channelAvailability);
|
||||||
app.get('/api/channel/short-id/:longId/:name', channelShortId);
|
app.get('/api/channel/short-id/:longId/:name', torCheckMiddleware, channelShortId);
|
||||||
app.get('/api/channel/data/:channelName/:channelClaimId', channelData);
|
app.get('/api/channel/data/:channelName/:channelClaimId', torCheckMiddleware, channelData);
|
||||||
app.get('/api/channel/claims/:channelName/:channelClaimId/:page', channelClaims);
|
app.get('/api/channel/claims/:channelName/:channelClaimId/:page', torCheckMiddleware, channelClaims);
|
||||||
// claim routes
|
// claim routes
|
||||||
app.get('/api/claim/availability/:name', claimAvailability);
|
app.get('/api/claim/availability/:name', torCheckMiddleware, claimAvailability);
|
||||||
app.get('/api/claim/data/:claimName/:claimId', claimData);
|
app.get('/api/claim/data/:claimName/:claimId', torCheckMiddleware, claimData);
|
||||||
app.get('/api/claim/get/:name/:claimId', claimGet);
|
app.get('/api/claim/get/:name/:claimId', torCheckMiddleware, claimGet);
|
||||||
app.get('/api/claim/list/:name', claimList);
|
app.get('/api/claim/list/:name', torCheckMiddleware, claimList);
|
||||||
app.post('/api/claim/long-id', claimLongId); // should be a get
|
app.post('/api/claim/long-id', torCheckMiddleware, claimLongId); // note: should be a 'get'
|
||||||
app.post('/api/claim/publish', torCheckMiddleware, multipartMiddleware, claimPublish);
|
app.post('/api/claim/publish', torCheckMiddleware, multipartMiddleware, claimPublish);
|
||||||
app.get('/api/claim/resolve/:name/:claimId', claimResolve);
|
app.get('/api/claim/resolve/:name/:claimId', torCheckMiddleware, claimResolve);
|
||||||
app.get('/api/claim/short-id/:longId/:name', claimShortId);
|
app.get('/api/claim/short-id/:longId/:name', torCheckMiddleware, claimShortId);
|
||||||
// file routes
|
// file routes
|
||||||
app.get('/api/file/availability/:name/:claimId', fileAvailability);
|
app.get('/api/file/availability/:name/:claimId', torCheckMiddleware, fileAvailability);
|
||||||
// user routes
|
// user routes
|
||||||
app.put('/api/user/password/', userPassword);
|
app.put('/api/user/password/', torCheckMiddleware, userPassword);
|
||||||
// configs
|
// configs
|
||||||
app.get('/api/config/site/publishing', publishingConfig);
|
app.get('/api/config/site/publishing', torCheckMiddleware, publishingConfig);
|
||||||
// tor
|
// tor
|
||||||
app.get('/api/tor', getTorList);
|
app.get('/api/tor', torCheckMiddleware, getTorList);
|
||||||
// blocked
|
// blocked
|
||||||
app.get('/api/blocked', getBlockedList);
|
app.get('/api/blocked', torCheckMiddleware, getBlockedList);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue