Merge pull request #20 from cubedro/develop

API authentication
This commit is contained in:
Marian OANCΞA 2015-03-04 23:30:35 +02:00
commit 7ff504602b
2 changed files with 14 additions and 0 deletions

9
app.js
View File

@ -8,6 +8,8 @@ var Primus = require('primus'),
api,
client;
var WS_SECRET = process.env.WS_SECRET || "eth-net-stats-has-a-secret";
var Collection = require('./models/collection');
var Nodes = new Collection();
@ -42,6 +44,13 @@ api.on('connection', function(spark) {
console.log('got hello data from ', spark.id);
console.log(data);
if(typeof data.secret === 'undefined' || data.secret !== WS_SECRET)
{
spark.end(undefined, { reconnect: false });
return false;
}
if(typeof data.id !== 'undefined' && typeof data.info !== 'undefined')
{
data.ip = spark.address.ip;

5
public/js/lib/jquery.sparkline.min.js vendored Normal file

File diff suppressed because one or more lines are too long