mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-02-12 11:01:52 +00:00
Added AgentPing/Pong feature in relay.
This commit is contained in:
parent
882c79ce16
commit
50e0bad1cb
3 changed files with 21 additions and 2 deletions
18
meshrelay.js
18
meshrelay.js
|
@ -116,6 +116,16 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Send a PING/PONG message
|
||||||
|
function sendPing() {
|
||||||
|
try { obj.ws.send('{"ctrlChannel":"102938","type":"ping"}'); } catch (ex) { }
|
||||||
|
try { if (obj.peer != null) { obj.peer.ws.send('{"ctrlChannel":"102938","type":"ping"}'); } } catch (ex) { }
|
||||||
|
}
|
||||||
|
function sendPong() {
|
||||||
|
try { obj.ws.send('{"ctrlChannel":"102938","type":"pong"}'); } catch (ex) { }
|
||||||
|
try { if (obj.peer != null) { obj.peer.ws.send('{"ctrlChannel":"102938","type":"pong"}'); } } catch (ex) { }
|
||||||
|
}
|
||||||
|
|
||||||
function performRelay() {
|
function performRelay() {
|
||||||
if (obj.id == null) { try { obj.close(); } catch (e) { } return null; } // Attempt to connect without id, drop this.
|
if (obj.id == null) { try { obj.close(); } catch (e) { } return null; } // Attempt to connect without id, drop this.
|
||||||
ws._socket.setKeepAlive(true, 240000); // Set TCP keep alive
|
ws._socket.setKeepAlive(true, 240000); // Set TCP keep alive
|
||||||
|
@ -195,6 +205,10 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
|
||||||
// Remove the timeout
|
// Remove the timeout
|
||||||
if (relayinfo.timeout) { clearTimeout(relayinfo.timeout); delete relayinfo.timeout; }
|
if (relayinfo.timeout) { clearTimeout(relayinfo.timeout); delete relayinfo.timeout; }
|
||||||
|
|
||||||
|
// Setup the agent PING/PONG timers
|
||||||
|
if ((typeof parent.parent.args.agentping == 'number') && (obj.pingtimer == null)) { obj.pingtimer = setInterval(sendPing, parent.parent.args.agentping * 1000); }
|
||||||
|
else if ((typeof parent.parent.args.agentpong == 'number') && (obj.pongtimer == null)) { obj.pongtimer = setInterval(sendPong, parent.parent.args.agentpong * 1000); }
|
||||||
|
|
||||||
// Setup session recording
|
// Setup session recording
|
||||||
var sessionUser = obj.user;
|
var sessionUser = obj.user;
|
||||||
if (sessionUser == null) { sessionUser = obj.peer.user; }
|
if (sessionUser == null) { sessionUser = obj.peer.user; }
|
||||||
|
@ -355,6 +369,8 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
|
||||||
delete peer.id;
|
delete peer.id;
|
||||||
delete peer.ws;
|
delete peer.ws;
|
||||||
delete peer.peer;
|
delete peer.peer;
|
||||||
|
if (peer.pingtimer != null) { clearInterval(peer.pingtimer); delete peer.pingtimer; }
|
||||||
|
if (peer.pongtimer != null) { clearInterval(peer.pongtimer); delete peer.pongtimer; }
|
||||||
} else {
|
} else {
|
||||||
parent.parent.debug('relay', 'Relay disconnect: ' + obj.id + ' (' + cleanRemoteAddr(obj.req.ip) + ')');
|
parent.parent.debug('relay', 'Relay disconnect: ' + obj.id + ' (' + cleanRemoteAddr(obj.req.ip) + ')');
|
||||||
}
|
}
|
||||||
|
@ -380,6 +396,8 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
|
||||||
delete obj.id;
|
delete obj.id;
|
||||||
delete obj.ws;
|
delete obj.ws;
|
||||||
delete obj.peer;
|
delete obj.peer;
|
||||||
|
if (obj.pingtimer != null) { clearInterval(obj.pingtimer); delete obj.pingtimer; }
|
||||||
|
if (obj.pongtimer != null) { clearInterval(obj.pongtimer); delete obj.pongtimer; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record a new entry in a recording log
|
// Record a new entry in a recording log
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "meshcentral",
|
"name": "meshcentral",
|
||||||
"version": "0.5.1-y",
|
"version": "0.5.1-z",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Remote Management",
|
"Remote Management",
|
||||||
"Intel AMT",
|
"Intel AMT",
|
||||||
|
|
|
@ -11204,6 +11204,7 @@
|
||||||
type: 'line',
|
type: 'line',
|
||||||
data: { labels: [], datasets: [{ label: '', backgroundColor: 'rgba(255, 99, 132, .5)', borderColor: 'rgb(255, 99, 132)', data: [], fill: true }] },
|
data: { labels: [], datasets: [{ label: '', backgroundColor: 'rgba(255, 99, 132, .5)', borderColor: 'rgb(255, 99, 132)', data: [], fill: true }] },
|
||||||
options: {
|
options: {
|
||||||
|
animation: false,
|
||||||
responsive: true,
|
responsive: true,
|
||||||
maintainAspectRatio: false,
|
maintainAspectRatio: false,
|
||||||
elements: { line: { cubicInterpolationMode: 'monotone' } },
|
elements: { line: { cubicInterpolationMode: 'monotone' } },
|
||||||
|
|
Loading…
Reference in a new issue