changed social bot list to array
This commit is contained in:
parent
d2c6acaed5
commit
6d071ae034
2 changed files with 14 additions and 9 deletions
|
@ -3,26 +3,32 @@ const { EMBED, BROWSER, SOCIAL } = require('../constants/request_types.js');
|
|||
|
||||
function headersMatchesSocialBotList (headers) {
|
||||
const userAgent = headers['user-agent'];
|
||||
const socialBotList = {
|
||||
'facebookexternalhit': 1,
|
||||
'Twitterbot' : 1,
|
||||
};
|
||||
return socialBotList[userAgent];
|
||||
const socialBotList = [
|
||||
'facebookexternalhit',
|
||||
'Twitterbot',
|
||||
];
|
||||
for (let i = 0; i < socialBotList.length; i++) {
|
||||
if (userAgent.indexOf(socialBotList[i]) >= 0) {
|
||||
logger.debug('request is from social bot:', socialBotList[i]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function clientAcceptsHtml ({accept}) {
|
||||
return accept && accept.match(/text\/html/);
|
||||
};
|
||||
}
|
||||
|
||||
function requestIsFromBrowser (headers) {
|
||||
return headers['user-agent'] && headers['user-agent'].match(/Mozilla/);
|
||||
};
|
||||
}
|
||||
|
||||
function clientWantsAsset ({accept, range}) {
|
||||
const imageIsWanted = accept && accept.match(/image\/.*/) && !accept.match(/text\/html/) && !accept.match(/text\/\*/);
|
||||
const videoIsWanted = accept && range;
|
||||
return imageIsWanted || videoIsWanted;
|
||||
};
|
||||
}
|
||||
|
||||
const determineRequestType = (hasFileExtension, headers) => {
|
||||
let responseType;
|
||||
|
|
|
@ -12,7 +12,6 @@ const torCheck = (req, res, next) => {
|
|||
raw: true,
|
||||
})
|
||||
.then(result => {
|
||||
logger.debug('tor check results:', result);
|
||||
if (result.length >= 1) {
|
||||
logger.info('Tor request blocked:', ip);
|
||||
const failureResponse = {
|
||||
|
|
Loading…
Reference in a new issue