diff --git a/app.js b/app.js index e48168b..6c26222 100644 --- a/app.js +++ b/app.js @@ -4,7 +4,7 @@ var chalk = require('chalk'); var http = require('http'); var WS_SECRET = process.env.WS_SECRET || "eth-net-stats-has-a-secret"; - +var banned = require('./lib/utils/config').banned; // Init http server if( process.env.NODE_ENV !== 'production' ) @@ -81,7 +81,7 @@ api.on('connection', function (spark) { console.info('API', 'CON', 'Hello', data['id']); - if( _.isUndefined(data.secret) || data.secret !== WS_SECRET ) + if( _.isUndefined(data.secret) || data.secret !== WS_SECRET || banned.indexOf(spark.address.ip) >= 0 ) { spark.end(undefined, { reconnect: false }); console.error('API', 'CON', 'Closed - wrong auth', data); diff --git a/lib/node.js b/lib/node.js index 46a09e5..3175bc2 100644 --- a/lib/node.js +++ b/lib/node.js @@ -1,6 +1,6 @@ var geoip = require('geoip-lite'); var _ = require('lodash'); -var trusted = require('./utils/config'); +var trusted = require('./utils/config').trusted; var MAX_HISTORY = 40; var MAX_INACTIVE_TIME = 1000*60*60*4; diff --git a/lib/utils/config.js b/lib/utils/config.js index 2b9c5d7..54d19ce 100644 --- a/lib/utils/config.js +++ b/lib/utils/config.js @@ -18,4 +18,11 @@ var trusted = [ '::ffff:127.0.0.1', ]; -module.exports = trusted; \ No newline at end of file +var banned = [ + '198.48.150.206' +]; + +module.exports = { + trusted: trusted, + banned: banned +}; \ No newline at end of file