diff --git a/meshagent.js b/meshagent.js
index 8ff51653..a5d493e6 100644
--- a/meshagent.js
+++ b/meshagent.js
@@ -29,7 +29,8 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
obj.remoteaddr = (req.ip.startsWith('::ffff:')) ? (req.ip.substring(7)) : req.ip;
obj.remoteaddrport = obj.remoteaddr + ':' + ws._socket.remotePort;
obj.nonce = parent.crypto.randomBytes(48).toString('binary');
- ws._socket.setKeepAlive(true, 240000); // Set TCP keep alive, 4 minutes
+ //ws._socket.setKeepAlive(true, 240000); // Set TCP keep alive, 4 minutes
+ if (args.agentidletimeout != 0) { ws._socket.setTimeout(args.agentidletimeout, function () { obj.close(1); }); } // Inactivity timeout of 2:30 minutes, by default agent will WebSocket ping every 2 minutes and server will pong back.
//obj.nodeid = null;
//obj.meshid = null;
//obj.dbNodeKey = null;
@@ -795,8 +796,13 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
// Check if we need to make an native update check
obj.agentExeInfo = parent.parent.meshAgentBinaries[obj.agentInfo.agentId];
- const corename = parent.parent.meshAgentsArchitectureNumbers[obj.agentInfo.agentId].core;
- if (corename == null) { obj.send(common.ShortToStr(10) + common.ShortToStr(0)); } // MeshCommand_CoreModule, ask mesh agent to clear the core
+ var corename = null;
+ if (parent.parent.meshAgentsArchitectureNumbers[obj.agentInfo.agentId] != null) {
+ corename = parent.parent.meshAgentsArchitectureNumbers[obj.agentInfo.agentId].core;
+ } else {
+ // MeshCommand_CoreModule, ask mesh agent to clear the core
+ obj.send(common.ShortToStr(10) + common.ShortToStr(0));
+ }
if ((obj.agentExeInfo != null) && (obj.agentExeInfo.update == true)) {
// Ask the agent for it's executable binary hash
diff --git a/meshcentral.js b/meshcentral.js
index f751d54c..8b8df868 100644
--- a/meshcentral.js
+++ b/meshcentral.js
@@ -604,6 +604,7 @@ function CreateMeshCentralServer(config, args) {
if (obj.args.mpsaliasport != null && (typeof obj.args.mpsaliasport != 'number')) obj.args.mpsaliasport = null;
if (obj.args.notls == null && obj.args.redirport == null) obj.args.redirport = 80;
if (obj.args.minifycore === 0) obj.args.minifycore = false;
+ if (typeof args.agentidletimeout != 'number') { args.agentidletimeout = 150000; } else { args.agentidletimeout *= 1000 } // Default agent idle timeout is 2m, 30sec.
// Setup a site administrator
if ((obj.args.admin) && (typeof obj.args.admin == 'string')) {
diff --git a/package.json b/package.json
index cfc9fb5d..d376479a 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "meshcentral",
- "version": "0.3.6-n",
+ "version": "0.3.6-o",
"keywords": [
"Remote Management",
"Intel AMT",
diff --git a/sample-config.json b/sample-config.json
index 4d15a9dd..41261d29 100644
--- a/sample-config.json
+++ b/sample-config.json
@@ -23,6 +23,7 @@
"_SelfUpdate": true,
"_AgentPing": 60,
"_AgentPong": 60,
+ "_AgentIdleTimeout": 150,
"_AllowHighQualityDesktop": true,
"_UserAllowedIP": "127.0.0.1,192.168.1.0/24",
"_UserBlockedIP": "127.0.0.1,::1,192.168.0.100",
diff --git a/views/default-min.handlebars b/views/default-min.handlebars
index df77e03c..2cacedff 100644
--- a/views/default-min.handlebars
+++ b/views/default-min.handlebars
@@ -8909,16 +8909,23 @@ var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this
flag = Q('aginsSelect').value;
if (parseInt(flag) >= 5) { name = name.toLowerCase(); } else { name += '.exe'; }
}
- try { xdr = new XDomainRequest(); } catch (e) { }
- if (!xdr) xdr = new XMLHttpRequest();
- xdr.open("GET", window.location.href + path + flag);
- xdr.timeout = 15000;
- xdr.responseType = "blob";
- xdr.onprogress = function (x) { /*console.log(x);*/ };
- xdr.onload = function (e) { saveAs(new Blob([e.target.response], { type: "application/octet-stream" }), name); if (xxdialogTag == 'fileDownload') { setDialogMode(0); } };
- xdr.onerror = function () { if (xxdialogTag == 'fileDownload') { setDialogMode(0); } alert('Agent downloads timeout.'); };
- xdr.ontimeout = function () { if (xxdialogTag == 'fileDownload') { setDialogMode(0); } alert('Unable to download agent.'); };
- xdr.send();
+
+ if (args.filedownloadtab == 1) {
+ // Open a new tab with download
+ window.open(window.location.origin + '/' + path + flag, '_blank');
+ } else {
+ // Background download & save
+ try { xdr = new XDomainRequest(); } catch (e) { }
+ if (!xdr) xdr = new XMLHttpRequest();
+ xdr.open("GET", window.location.origin + '/' + path + flag);
+ xdr.timeout = 15000;
+ xdr.responseType = "blob";
+ xdr.onprogress = function (x) { /*console.log(x);*/ };
+ xdr.onload = function (e) { saveAs(new Blob([e.target.response], { type: "application/octet-stream" }), name); if (xxdialogTag == 'fileDownload') { setDialogMode(0); } };
+ xdr.onerror = function () { if (xxdialogTag == 'fileDownload') { setDialogMode(0); } alert('Agent downloads timeout.'); };
+ xdr.ontimeout = function () { if (xxdialogTag == 'fileDownload') { setDialogMode(0); } alert('Unable to download agent.'); };
+ xdr.send();
+ }
}
function addAgentToMeshClick() {
@@ -10047,6 +10054,11 @@ var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this
// Update the web page title
if ((currentNode) && (xxcurrentView >= 10) && (xxcurrentView < 20)) { document.title = decodeURIComponent("{{{extitle}}}") + ' - ' + currentNode.name; } else { document.title = decodeURIComponent("{{{extitle}}}"); }
+
+ // Clear user consent status if present
+ p11clearConsoleMsg();
+ p12clearConsoleMsg();
+ p13clearConsoleMsg();
}
setupDesktop(); // Always refresh the desktop, even if we are on the same device, we need to do some canvas switching.
if (!panel) panel = 10;
@@ -10529,6 +10541,7 @@ var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this
function autoConnectDesktop(e) { if (autoConnectDesktopTimer == null) { autoConnectDesktopTimer = setInterval(connectDesktop, 100); } else { clearInterval(autoConnectDesktopTimer); autoConnectDesktopTimer = null; } }
function connectDesktop(e, contype) {
+ p11clearConsoleMsg();
if (desktop == null) {
desktopNode = currentNode;
if (contype == 2) {
@@ -11122,6 +11135,7 @@ var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this
function autoConnectTerminal(e) { if (autoConnectTerminalTimer == null) { autoConnectTerminalTimer = setInterval(connectTerminal, 100); } else { clearInterval(autoConnectTerminalTimer); autoConnectTerminalTimer = null; } }
function connectTerminal(e, contype) {
+ p12clearConsoleMsg();
if (!terminal) {
if (contype == 2) {
// Setup the Intel AMT terminal
@@ -11156,7 +11170,6 @@ var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this
terminal.attemptWebRTC = attemptWebRTC;
terminal.onStateChanged = onTerminalStateChange;
terminal.onConsoleMessageChange = function () {
- console.log('terminal.consoleMessage', terminal.consoleMessage);
p12clearConsoleMsg();
if (terminal.consoleMessage) {
QH('p12TermConsoleMsg', EscapeHtml(terminal.consoleMessage).split('\n').join('
'));
@@ -11278,6 +11291,7 @@ var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this
function autoConnectFiles(e) { if (autoConnectFilesTimer == null) { autoConnectFilesTimer = setInterval(connectFiles, 100); } else { clearInterval(autoConnectFilesTimer); autoConnectFilesTimer = null; } }
function connectFiles(e) {
+ p13clearConsoleMsg();
if (!files) {
// Setup a mesh agent files
files = CreateAgentRedirect(meshserver, CreateRemoteFiles(p13gotFiles), serverPublicNamePort, authCookie, domainUrl);
diff --git a/views/default.handlebars b/views/default.handlebars
index fe486145..263c7bf7 100644
--- a/views/default.handlebars
+++ b/views/default.handlebars
@@ -2861,16 +2861,23 @@
flag = Q('aginsSelect').value;
if (parseInt(flag) >= 5) { name = name.toLowerCase(); } else { name += '.exe'; }
}
- try { xdr = new XDomainRequest(); } catch (e) { }
- if (!xdr) xdr = new XMLHttpRequest();
- xdr.open("GET", window.location.href + path + flag);
- xdr.timeout = 15000;
- xdr.responseType = "blob";
- xdr.onprogress = function (x) { /*console.log(x);*/ };
- xdr.onload = function (e) { saveAs(new Blob([e.target.response], { type: "application/octet-stream" }), name); if (xxdialogTag == 'fileDownload') { setDialogMode(0); } };
- xdr.onerror = function () { if (xxdialogTag == 'fileDownload') { setDialogMode(0); } alert('Agent downloads timeout.'); };
- xdr.ontimeout = function () { if (xxdialogTag == 'fileDownload') { setDialogMode(0); } alert('Unable to download agent.'); };
- xdr.send();
+
+ if (args.filedownloadtab == 1) {
+ // Open a new tab with download
+ window.open(window.location.origin + '/' + path + flag, '_blank');
+ } else {
+ // Background download & save
+ try { xdr = new XDomainRequest(); } catch (e) { }
+ if (!xdr) xdr = new XMLHttpRequest();
+ xdr.open("GET", window.location.origin + '/' + path + flag);
+ xdr.timeout = 15000;
+ xdr.responseType = "blob";
+ xdr.onprogress = function (x) { /*console.log(x);*/ };
+ xdr.onload = function (e) { saveAs(new Blob([e.target.response], { type: "application/octet-stream" }), name); if (xxdialogTag == 'fileDownload') { setDialogMode(0); } };
+ xdr.onerror = function () { if (xxdialogTag == 'fileDownload') { setDialogMode(0); } alert('Agent downloads timeout.'); };
+ xdr.ontimeout = function () { if (xxdialogTag == 'fileDownload') { setDialogMode(0); } alert('Unable to download agent.'); };
+ xdr.send();
+ }
}
function addAgentToMeshClick() {
@@ -3999,6 +4006,11 @@
// Update the web page title
if ((currentNode) && (xxcurrentView >= 10) && (xxcurrentView < 20)) { document.title = decodeURIComponent("{{{extitle}}}") + ' - ' + currentNode.name; } else { document.title = decodeURIComponent("{{{extitle}}}"); }
+
+ // Clear user consent status if present
+ p11clearConsoleMsg();
+ p12clearConsoleMsg();
+ p13clearConsoleMsg();
}
setupDesktop(); // Always refresh the desktop, even if we are on the same device, we need to do some canvas switching.
if (!panel) panel = 10;
@@ -4481,6 +4493,7 @@
function autoConnectDesktop(e) { if (autoConnectDesktopTimer == null) { autoConnectDesktopTimer = setInterval(connectDesktop, 100); } else { clearInterval(autoConnectDesktopTimer); autoConnectDesktopTimer = null; } }
function connectDesktop(e, contype) {
+ p11clearConsoleMsg();
if (desktop == null) {
desktopNode = currentNode;
if (contype == 2) {
@@ -5074,6 +5087,7 @@
function autoConnectTerminal(e) { if (autoConnectTerminalTimer == null) { autoConnectTerminalTimer = setInterval(connectTerminal, 100); } else { clearInterval(autoConnectTerminalTimer); autoConnectTerminalTimer = null; } }
function connectTerminal(e, contype) {
+ p12clearConsoleMsg();
if (!terminal) {
if (contype == 2) {
// Setup the Intel AMT terminal
@@ -5108,7 +5122,6 @@
terminal.attemptWebRTC = attemptWebRTC;
terminal.onStateChanged = onTerminalStateChange;
terminal.onConsoleMessageChange = function () {
- console.log('terminal.consoleMessage', terminal.consoleMessage);
p12clearConsoleMsg();
if (terminal.consoleMessage) {
QH('p12TermConsoleMsg', EscapeHtml(terminal.consoleMessage).split('\n').join('
'));
@@ -5230,6 +5243,7 @@
function autoConnectFiles(e) { if (autoConnectFilesTimer == null) { autoConnectFilesTimer = setInterval(connectFiles, 100); } else { clearInterval(autoConnectFilesTimer); autoConnectFilesTimer = null; } }
function connectFiles(e) {
+ p13clearConsoleMsg();
if (!files) {
// Setup a mesh agent files
files = CreateAgentRedirect(meshserver, CreateRemoteFiles(p13gotFiles), serverPublicNamePort, authCookie, domainUrl);