added ip filter

This commit is contained in:
Martin Donnelly 2018-06-13 22:57:24 +01:00
parent a2a71f7812
commit 28bf2f57c5
3 changed files with 674 additions and 438 deletions

1095
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,15 +9,15 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"apicache": "^1.1.0", "apicache": "^1.2.1",
"body-parser": "^1.18.2", "body-parser": "^1.18.3",
"express": "^4.16.1", "express": "^4.16.3",
"express-ipfilter": "^0.3.1", "express-ipfilter": "^0.3.1",
"http": "0.0.0", "http": "0.0.0",
"https": "^1.0.0", "https": "^1.0.0",
"log4js": "^2.3.4", "log4js": "^2.8.0",
"path": "^0.12.7", "path": "^0.12.7",
"request-promise-cache": "^1.0.6", "request-promise-cache": "^2.0.0",
"url": "^0.11.0" "url": "^0.11.0"
} }
} }

View File

@ -17,6 +17,7 @@ const port = process.env.PORT || 8080;
logger.level = 'debug'; logger.level = 'debug';
app.use(ipfilter(ips, { 'mode': 'allow' }));
// app.use(compression()); // app.use(compression());
app.use(bodyParser.json()); app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ 'extended': true })); app.use(bodyParser.urlencoded({ 'extended': true }));
@ -30,6 +31,8 @@ app.use(cache('15 minutes'));
const ips = ['212.71.255.44']; const ips = ['212.71.255.44'];
app.use(ipfilter(ips, { 'mode': 'allow' }));
const bouncer = ['phpmyadmin', const bouncer = ['phpmyadmin',
'phpMyadmin', 'phpMyadmin',
'phpMyAdmin', 'phpMyAdmin',
@ -106,7 +109,7 @@ function getUrl (req, res) {
}; };
// console.log('Options', options); // console.log('Options', options);
logger.info('>> getting url'); logger.info(`>> getting ${theUrl}`);
function urlQuery (callback) { function urlQuery (callback) {
try { try {
let count = 0; let count = 0;
@ -194,7 +197,7 @@ app.get('*', function(req, res, next) {
next(err); next(err);
}); });
app.use(ipfilter(ips, { 'mode': 'allow' }));
const server = app.listen(port, () => { const server = app.listen(port, () => {
logger.info(`Server listening on port ${port}`); logger.info(`Server listening on port ${port}`);