Added server AgentPing/AgentPong settings.

This commit is contained in:
Ylian Saint-Hilaire 2019-05-28 10:58:46 -07:00
parent 5f12486c13
commit c73fe57974
7 changed files with 22 additions and 4 deletions

View File

@ -623,6 +623,8 @@ function createMeshCore(agent) {
sendConsoleText('getScript: ' + JSON.stringify(data));
break;
}
case 'ping': { mesh.SendCommand('{"action":"pong"}'); break; }
case 'pong': { break; }
default:
// Unknown action, ignore it.
break;

File diff suppressed because one or more lines are too long

View File

@ -89,6 +89,10 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
delete obj.agentUpdate;
}
// Perform timer cleanup
if (obj.pingtimer) { clearInterval(obj.pingtimer); delete obj.pingtimer; }
if (obj.pongtimer) { clearInterval(obj.pongtimer); delete obj.pongtimer; }
// Perform aggressive cleanup
if (obj.nonce) { delete obj.nonce; }
if (obj.nodeid) { delete obj.nodeid; }
@ -531,11 +535,19 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
return mesh;
}
// Send a PING/PONG message
function sendPing() { obj.send('{"action":"ping"}'); }
function sendPong() { obj.send('{"action":"pong"}'); }
// Once we get all the information about an agent, run this to hook everything up to the server
function completeAgentConnection() {
if ((obj.authenticated != 1) || (obj.meshid == null) || obj.pendingCompleteAgentConnection || (obj.agentInfo == null)) { return; }
obj.pendingCompleteAgentConnection = true;
// Setup the agent PING/PONG timers
if ((typeof args.agentping == 'number') && (obj.pingtimer == null)) { obj.pingtimer = setInterval(sendPing, args.agentping * 1000); }
else if ((typeof args.agentpong == 'number') && (obj.pongtimer == null)) { obj.pongtimer = setInterval(sendPong, args.agentpong * 1000); }
// If this is a recovery agent
if (obj.agentInfo.capabilities & 0x40) {
// Inform mesh agent that it's authenticated.
@ -1144,6 +1156,8 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
// Nothing is done right now.
break;
}
case 'ping': { sendPong(); break; }
case 'pong': { break; }
case 'getScript':
{
// Used by the agent to get configuration scripts.

View File

@ -1,6 +1,6 @@
{
"name": "meshcentral",
"version": "0.3.5-h",
"version": "0.3.5-i",
"keywords": [
"Remote Management",
"Intel AMT",

View File

@ -20,6 +20,8 @@
"_WebRTC": false,
"_ClickOnce": false,
"_SelfUpdate": true,
"_AgentPing": 60,
"_AgentPong": 60,
"_AllowHighQualityDesktop": true,
"_UserAllowedIP": "127.0.0.1,192.168.1.0/24",
"_UserBlockedIP": "127.0.0.1,::1,192.168.0.100",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long