Updated to v0.5.16
Ylian Saint-Hilaire committed
Apr 28, 2020 at 13:57 UTC
f1e18ee74341d17be86286e51727c607ee406219
2 files changed
+36
-12
meshrelay.js
+35
-11
@@ -34,6 +34,13 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
34
obj.relaySessionCounted = true;
35
parent.relaySessionCount++;
36
37
+ // Setup slow relay is requested. This will show down sending any data to this peer.
38
+ if ((req.query.slowrelay != null)) {
39
+ var sr = null;
40
+ try { sr = parseInt(req.query.slowrelay); } catch (ex) { }
41
+ if ((typeof sr == 'number') && (sr > 0) && (sr < 1000)) { obj.ws.slowRelay = sr; }
42
+ }
43
+
44
// Mesh Rights
45
const MESHRIGHT_EDITMESH = 1;
46
const MESHRIGHT_MANAGEUSERS = 2;
@@ -308,17 +315,34 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
315
//console.log(typeof data, data.length);
316
if (this.peer != null) {
317
//if (typeof data == 'string') { console.log('Relay: ' + data); } else { console.log('Relay:' + data.length + ' byte(s)'); }
311
- try {
312
- this._socket.pause();
313
- if (this.logfile != null) {
314
- // Write data to log file then perform relay
315
- var xthis = this;
316
- recordingEntry(this.logfile.fd, 2, ((obj.req.query.browser) ? 2 : 0), data, function () { xthis.peer.send(data, ws.flushSink); });
317
- } else {
318
- // Perform relay
319
- this.peer.send(data, ws.flushSink);
320
- }
321
- } catch (ex) { console.log(ex); }
318
+ if (this.peer.slowRelay == null) {
319
+ try {
320
+ this._socket.pause();
321
+ if (this.logfile != null) {
322
+ // Write data to log file then perform relay
323
+ var xthis = this;
324
+ recordingEntry(this.logfile.fd, 2, ((obj.req.query.browser) ? 2 : 0), data, function () { xthis.peer.send(data, ws.flushSink); });
325
+ } else {
326
+ // Perform relay
327
+ this.peer.send(data, ws.flushSink);
328
+ }
329
+ } catch (ex) { console.log(ex); }
330
+ } else {
331
+ try {
332
+ this._socket.pause();
333
+ if (this.logfile != null) {
334
+ // Write data to log file then perform slow relay
335
+ var xthis = this;
336
+ recordingEntry(this.logfile.fd, 2, ((obj.req.query.browser) ? 2 : 0), data, function () {
337
+ setTimeout(function () { xthis.peer.send(data, ws.flushSink); }, xthis.peer.slowRelay);
338
+ });
339
+ } else {
340
+ // Perform slow relay
341
+ var xthis = this;
342
+ setTimeout(function () { xthis.peer.send(data, ws.flushSink); }, xthis.peer.slowRelay);
343
+ }
344
+ } catch (ex) { console.log(ex); }
345
+ }
346
}
347
});
348
package.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.5.15",
3
+ "version": "0.5.16",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",