Merge pull request #20 from cubedro/develop

API authentication
pull/5/head
Marian OANCΞA 10 years ago
commit 7ff504602b
  1. 9
      app.js
  2. 5
      public/js/lib/jquery.sparkline.min.js

@ -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;

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save