Added DropAllCira command to server console, #2976

This commit is contained in:
Ylian Saint-Hilaire 2021-07-30 17:09:35 -07:00
parent 40eb8762e2
commit d7e41d8366
2 changed files with 17 additions and 0 deletions

View File

@ -5448,6 +5448,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
'dbcounters': [serverUserCommandDbCounters, ""], 'dbcounters': [serverUserCommandDbCounters, ""],
'dbstats': [serverUserCommandDbStats, ""], 'dbstats': [serverUserCommandDbStats, ""],
'dispatchtable': [serverUserCommandDispatchTable, ""], 'dispatchtable': [serverUserCommandDispatchTable, ""],
'dropallcira': [serverUserCommandDropAllCira, ""],
'dupagents': [serverUserCommandDupAgents, ""], 'dupagents': [serverUserCommandDupAgents, ""],
'email': [serverUserCommandEmail, ""], 'email': [serverUserCommandEmail, ""],
'firebase': [serverUserCommandFirebase, ""], 'firebase': [serverUserCommandFirebase, ""],
@ -5854,6 +5855,12 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
} }
} }
function serverUserCommandDropAllCira(cmdData) {
if (parent.parent.mpsserver == null) { cmdData.result = 'MPS not setup.'; return; }
const dropCount = parent.parent.mpsserver.dropAllConnections();
cmdData.result = 'Dropped ' + dropCount + ' connection(s).';
}
function serverUserCommandDupAgents(cmdData) { function serverUserCommandDupAgents(cmdData) {
for (var i in parent.duplicateAgentsLog) { for (var i in parent.duplicateAgentsLog) {
cmdData.result += JSON.stringify(parent.duplicateAgentsLog[i]) + '\r\n'; cmdData.result += JSON.stringify(parent.duplicateAgentsLog[i]) + '\r\n';

View File

@ -1325,6 +1325,16 @@ module.exports.CreateMpsServer = function (parent, db, args, certificates) {
for (var i in obj.httpResponses) { if ((obj.httpResponses[i].maxtime != null) && (obj.httpResponses[i].maxtime < now)) { delete obj.httpResponses[i]; } } for (var i in obj.httpResponses) { if ((obj.httpResponses[i].maxtime != null) && (obj.httpResponses[i].maxtime < now)) { delete obj.httpResponses[i]; } }
} }
// Drop all CIRA connections
obj.dropAllConnections = function () {
var dropCount = 0;
for (var nodeid in obj.ciraConnections) {
const connections = obj.ciraConnections[nodeid];
for (var i in connections) { if (connections[i].end) { connections[i].end(); dropCount++; } } // This will drop all TCP CIRA connections
}
return dropCount;
}
function guidToStr(g) { return g.substring(6, 8) + g.substring(4, 6) + g.substring(2, 4) + g.substring(0, 2) + "-" + g.substring(10, 12) + g.substring(8, 10) + "-" + g.substring(14, 16) + g.substring(12, 14) + "-" + g.substring(16, 20) + "-" + g.substring(20); } function guidToStr(g) { return g.substring(6, 8) + g.substring(4, 6) + g.substring(2, 4) + g.substring(0, 2) + "-" + g.substring(10, 12) + g.substring(8, 10) + "-" + g.substring(14, 16) + g.substring(12, 14) + "-" + g.substring(16, 20) + "-" + g.substring(20); }
// Clean a IPv6 address that encodes a IPv4 address // Clean a IPv6 address that encodes a IPv4 address