From 2e72a285ac4a6b3e23209fe153e30d1f3f2592bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Tue, 12 Sep 2017 11:29:03 +0300 Subject: [PATCH] Introduce an ID reservation list. --- app.js | 5 +++-- lib/utils/config.js | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index 150d77a..0e0cdd0 100644 --- a/app.js +++ b/app.js @@ -29,7 +29,8 @@ else } } -var banned = require('./lib/utils/config').banned; +var banned = require('./lib/utils/config').banned; +var reserved = require('./lib/utils/config').reserved; // Init http server if( process.env.NODE_ENV !== 'production' ) @@ -106,7 +107,7 @@ api.on('connection', function (spark) { console.info('API', 'CON', 'Hello', data['id']); - if( _.isUndefined(data.secret) || WS_SECRET.indexOf(data.secret) === -1 || banned.indexOf(spark.address.ip) >= 0 ) + if( _.isUndefined(data.secret) || WS_SECRET.indexOf(data.secret) === -1 || banned.indexOf(spark.address.ip) >= 0 || _.isUndefined(data.id) || reserved.indexOf(data.id) >= 0 ) { spark.end(undefined, { reconnect: false }); console.error('API', 'CON', 'Closed - wrong auth', data); diff --git a/lib/utils/config.js b/lib/utils/config.js index 8222c64..88768f9 100644 --- a/lib/utils/config.js +++ b/lib/utils/config.js @@ -26,6 +26,7 @@ var banned = [ ]; module.exports = { - trusted: trusted, - banned: banned -}; \ No newline at end of file + trusted: trusted, + banned: banned, + reserved: [] +};