|
@@ -23,6 +23,13 @@ var ApiController = function(app) {
|
|
req.body.url = 'http://' + req.body.url;
|
|
req.body.url = 'http://' + req.body.url;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Block requests to unwanted websites (=spam)
|
|
|
|
+ if (isBlocked(req.body.url)) {
|
|
|
|
+ console.error('Test blocked for URL: %s', req.body.url);
|
|
|
|
+ res.status(403).send('Forbidden');
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
// Grab the test parameters and generate a random run ID
|
|
// Grab the test parameters and generate a random run ID
|
|
var run = {
|
|
var run = {
|
|
runId: (Date.now()*1000 + Math.round(Math.random()*1000)).toString(36),
|
|
runId: (Date.now()*1000 + Math.round(Math.random()*1000)).toString(36),
|
|
@@ -86,6 +93,7 @@ var ApiController = function(app) {
|
|
return ylt(run.params.url, runOptions);
|
|
return ylt(run.params.url, runOptions);
|
|
|
|
|
|
})
|
|
})
|
|
|
|
+
|
|
// Phantomas completed, let's save the screenshot if any
|
|
// Phantomas completed, let's save the screenshot if any
|
|
.then(function(data) {
|
|
.then(function(data) {
|
|
|
|
|
|
@@ -327,6 +335,15 @@ var ApiController = function(app) {
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ function isBlocked(url) {
|
|
|
|
+ if (!serverSettings.blockedUrls) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return serverSettings.blockedUrls.some(function(blockedUrl) {
|
|
|
|
+ return (url.indexOf(blockedUrl) === 0);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
};
|
|
};
|
|
|
|
|
|
module.exports = ApiController;
|
|
module.exports = ApiController;
|