Updated to v0.5.16

This commit is contained in:
Ylian Saint-Hilaire 2020-04-28 13:57:08 -07:00
parent 667b907f1c
commit 6bd793d304
2 changed files with 36 additions and 12 deletions

View File

@ -34,6 +34,13 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
obj.relaySessionCounted = true; obj.relaySessionCounted = true;
parent.relaySessionCount++; parent.relaySessionCount++;
// Setup slow relay is requested. This will show down sending any data to this peer.
if ((req.query.slowrelay != null)) {
var sr = null;
try { sr = parseInt(req.query.slowrelay); } catch (ex) { }
if ((typeof sr == 'number') && (sr > 0) && (sr < 1000)) { obj.ws.slowRelay = sr; }
}
// Mesh Rights // Mesh Rights
const MESHRIGHT_EDITMESH = 1; const MESHRIGHT_EDITMESH = 1;
const MESHRIGHT_MANAGEUSERS = 2; const MESHRIGHT_MANAGEUSERS = 2;
@ -308,17 +315,34 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
//console.log(typeof data, data.length); //console.log(typeof data, data.length);
if (this.peer != null) { if (this.peer != null) {
//if (typeof data == 'string') { console.log('Relay: ' + data); } else { console.log('Relay:' + data.length + ' byte(s)'); } //if (typeof data == 'string') { console.log('Relay: ' + data); } else { console.log('Relay:' + data.length + ' byte(s)'); }
try { if (this.peer.slowRelay == null) {
this._socket.pause(); try {
if (this.logfile != null) { this._socket.pause();
// Write data to log file then perform relay if (this.logfile != null) {
var xthis = this; // Write data to log file then perform relay
recordingEntry(this.logfile.fd, 2, ((obj.req.query.browser) ? 2 : 0), data, function () { xthis.peer.send(data, ws.flushSink); }); var xthis = this;
} else { recordingEntry(this.logfile.fd, 2, ((obj.req.query.browser) ? 2 : 0), data, function () { xthis.peer.send(data, ws.flushSink); });
// Perform relay } else {
this.peer.send(data, ws.flushSink); // Perform relay
} this.peer.send(data, ws.flushSink);
} catch (ex) { console.log(ex); } }
} catch (ex) { console.log(ex); }
} else {
try {
this._socket.pause();
if (this.logfile != null) {
// Write data to log file then perform slow relay
var xthis = this;
recordingEntry(this.logfile.fd, 2, ((obj.req.query.browser) ? 2 : 0), data, function () {
setTimeout(function () { xthis.peer.send(data, ws.flushSink); }, xthis.peer.slowRelay);
});
} else {
// Perform slow relay
var xthis = this;
setTimeout(function () { xthis.peer.send(data, ws.flushSink); }, xthis.peer.slowRelay);
}
} catch (ex) { console.log(ex); }
}
} }
}); });

View File

@ -1,6 +1,6 @@
{ {
"name": "meshcentral", "name": "meshcentral",
"version": "0.5.15", "version": "0.5.16",
"keywords": [ "keywords": [
"Remote Management", "Remote Management",
"Intel AMT", "Intel AMT",