mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
in-prod check: sites
This commit is contained in:
parent
4f310d9a07
commit
e6b097af1b
2
gun.js
2
gun.js
@ -1332,7 +1332,6 @@
|
||||
|
||||
//console.log(setTimeout.turn.s.length, 'stacks', parseFloat((-(LT - (LT = +new Date))/1000).toFixed(3)), 'sec', parseFloat(((LT-ST)/1000 / 60).toFixed(1)), 'up', stat.peers||0, 'peers', stat.has||0, 'has', stat.memhused||0, stat.memused||0, stat.memax||0, 'heap mem max');
|
||||
}catch(e){ console.log('DBG err', e) }}*/
|
||||
|
||||
hear.d += raw.length||0 ; ++hear.c } // STATS!
|
||||
var S = peer.SH = +new Date;
|
||||
var tmp = raw[0], msg;
|
||||
@ -1385,6 +1384,7 @@
|
||||
}
|
||||
var S = +new Date;
|
||||
DBG && (DBG.is = S); peer.SI = id;
|
||||
console.log("hear:", ((peer.wire||'').headers||'').origin, msg.put || msg.get);
|
||||
root.on('in', mesh.last = msg);
|
||||
//ECHO = msg.put || ECHO; !(msg.ok !== -3740) && mesh.say({ok: -3740, put: ECHO, '@': msg['#']}, peer);
|
||||
DBG && (DBG.hd = +new Date);
|
||||
|
@ -48,6 +48,7 @@ Gun.on('opt', function(root){
|
||||
stats.node = {};
|
||||
stats.node.count = Object.keys(root.graph||{}).length; // TODO: .keys( is slow
|
||||
stats.all = all;
|
||||
stats.sites = console.STAT.sites;
|
||||
all = {}; // will this cause missing stats?
|
||||
var dam = root.opt.mesh;
|
||||
if(dam){
|
||||
|
@ -67,9 +67,9 @@ Gun.on('opt', function(root){
|
||||
if(!ws.server){ this.to.next(root); return } // ugh, bug fix for @jamierez & unstoppable ryan.
|
||||
}
|
||||
ws.web = ws.web || new opt.WebSocket.Server(ws); // we still need a WS server.
|
||||
ws.web.on('connection', function(wire){ var peer;
|
||||
wire.upgradeReq = wire.upgradeReq || {};
|
||||
wire.url = url.parse(wire.upgradeReq.url||'', true);
|
||||
ws.web.on('connection', function(wire, req){ var peer;
|
||||
wire.headers = wire.headers || (req||'').headers || '';
|
||||
console.STAT && ((console.STAT.sites || (console.STAT.sites = {}))[wire.headers.origin] = 1);
|
||||
opt.mesh.hi(peer = {wire: wire});
|
||||
wire.on('message', function(msg){
|
||||
opt.mesh.hear(msg.data || msg, peer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user