Added AgentPing/Pong feature in relay.
This commit is contained in:
parent
882c79ce16
commit
50e0bad1cb
18
meshrelay.js
18
meshrelay.js
|
@ -116,6 +116,16 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
|
|||
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() {
|
||||
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
|
||||
|
@ -195,6 +205,10 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
|
|||
// Remove the 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
|
||||
var sessionUser = obj.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.ws;
|
||||
delete peer.peer;
|
||||
if (peer.pingtimer != null) { clearInterval(peer.pingtimer); delete peer.pingtimer; }
|
||||
if (peer.pongtimer != null) { clearInterval(peer.pongtimer); delete peer.pongtimer; }
|
||||
} else {
|
||||
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.ws;
|
||||
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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "meshcentral",
|
||||
"version": "0.5.1-y",
|
||||
"version": "0.5.1-z",
|
||||
"keywords": [
|
||||
"Remote Management",
|
||||
"Intel AMT",
|
||||
|
|
|
@ -11204,6 +11204,7 @@
|
|||
type: 'line',
|
||||
data: { labels: [], datasets: [{ label: '', backgroundColor: 'rgba(255, 99, 132, .5)', borderColor: 'rgb(255, 99, 132)', data: [], fill: true }] },
|
||||
options: {
|
||||
animation: false,
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
elements: { line: { cubicInterpolationMode: 'monotone' } },
|
||||
|
|
Loading…
Reference in New Issue