Server fixes.

This commit is contained in:
Ylian Saint-Hilaire 2019-06-17 15:20:47 -07:00
parent d8ba9159ba
commit c3fc3a0d2a
6 changed files with 62 additions and 26 deletions

View File

@ -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.remoteaddr = (req.ip.startsWith('::ffff:')) ? (req.ip.substring(7)) : req.ip;
obj.remoteaddrport = obj.remoteaddr + ':' + ws._socket.remotePort; obj.remoteaddrport = obj.remoteaddr + ':' + ws._socket.remotePort;
obj.nonce = parent.crypto.randomBytes(48).toString('binary'); 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.nodeid = null;
//obj.meshid = null; //obj.meshid = null;
//obj.dbNodeKey = 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 // Check if we need to make an native update check
obj.agentExeInfo = parent.parent.meshAgentBinaries[obj.agentInfo.agentId]; obj.agentExeInfo = parent.parent.meshAgentBinaries[obj.agentInfo.agentId];
const corename = parent.parent.meshAgentsArchitectureNumbers[obj.agentInfo.agentId].core; var corename = null;
if (corename == null) { obj.send(common.ShortToStr(10) + common.ShortToStr(0)); } // MeshCommand_CoreModule, ask mesh agent to clear the core 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)) { if ((obj.agentExeInfo != null) && (obj.agentExeInfo.update == true)) {
// Ask the agent for it's executable binary hash // Ask the agent for it's executable binary hash

View File

@ -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.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.notls == null && obj.args.redirport == null) obj.args.redirport = 80;
if (obj.args.minifycore === 0) obj.args.minifycore = false; 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 // Setup a site administrator
if ((obj.args.admin) && (typeof obj.args.admin == 'string')) { if ((obj.args.admin) && (typeof obj.args.admin == 'string')) {

View File

@ -1,6 +1,6 @@
{ {
"name": "meshcentral", "name": "meshcentral",
"version": "0.3.6-n", "version": "0.3.6-o",
"keywords": [ "keywords": [
"Remote Management", "Remote Management",
"Intel AMT", "Intel AMT",

View File

@ -23,6 +23,7 @@
"_SelfUpdate": true, "_SelfUpdate": true,
"_AgentPing": 60, "_AgentPing": 60,
"_AgentPong": 60, "_AgentPong": 60,
"_AgentIdleTimeout": 150,
"_AllowHighQualityDesktop": true, "_AllowHighQualityDesktop": true,
"_UserAllowedIP": "127.0.0.1,192.168.1.0/24", "_UserAllowedIP": "127.0.0.1,192.168.1.0/24",
"_UserBlockedIP": "127.0.0.1,::1,192.168.0.100", "_UserBlockedIP": "127.0.0.1,::1,192.168.0.100",

View File

@ -8909,9 +8909,15 @@ var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this
flag = Q('aginsSelect').value; flag = Q('aginsSelect').value;
if (parseInt(flag) >= 5) { name = name.toLowerCase(); } else { name += '.exe'; } if (parseInt(flag) >= 5) { name = name.toLowerCase(); } else { name += '.exe'; }
} }
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) { } try { xdr = new XDomainRequest(); } catch (e) { }
if (!xdr) xdr = new XMLHttpRequest(); if (!xdr) xdr = new XMLHttpRequest();
xdr.open("GET", window.location.href + path + flag); xdr.open("GET", window.location.origin + '/' + path + flag);
xdr.timeout = 15000; xdr.timeout = 15000;
xdr.responseType = "blob"; xdr.responseType = "blob";
xdr.onprogress = function (x) { /*console.log(x);*/ }; xdr.onprogress = function (x) { /*console.log(x);*/ };
@ -8920,6 +8926,7 @@ var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this
xdr.ontimeout = function () { if (xxdialogTag == 'fileDownload') { setDialogMode(0); } alert('Unable to download agent.'); }; xdr.ontimeout = function () { if (xxdialogTag == 'fileDownload') { setDialogMode(0); } alert('Unable to download agent.'); };
xdr.send(); xdr.send();
} }
}
function addAgentToMeshClick() { function addAgentToMeshClick() {
var v = Q('aginsSelect').value; var v = Q('aginsSelect').value;
@ -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 // Update the web page title
if ((currentNode) && (xxcurrentView >= 10) && (xxcurrentView < 20)) { document.title = decodeURIComponent("{{{extitle}}}") + ' - ' + currentNode.name; } else { document.title = decodeURIComponent("{{{extitle}}}"); } 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. setupDesktop(); // Always refresh the desktop, even if we are on the same device, we need to do some canvas switching.
if (!panel) panel = 10; 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 autoConnectDesktop(e) { if (autoConnectDesktopTimer == null) { autoConnectDesktopTimer = setInterval(connectDesktop, 100); } else { clearInterval(autoConnectDesktopTimer); autoConnectDesktopTimer = null; } }
function connectDesktop(e, contype) { function connectDesktop(e, contype) {
p11clearConsoleMsg();
if (desktop == null) { if (desktop == null) {
desktopNode = currentNode; desktopNode = currentNode;
if (contype == 2) { 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 autoConnectTerminal(e) { if (autoConnectTerminalTimer == null) { autoConnectTerminalTimer = setInterval(connectTerminal, 100); } else { clearInterval(autoConnectTerminalTimer); autoConnectTerminalTimer = null; } }
function connectTerminal(e, contype) { function connectTerminal(e, contype) {
p12clearConsoleMsg();
if (!terminal) { if (!terminal) {
if (contype == 2) { if (contype == 2) {
// Setup the Intel AMT terminal // 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.attemptWebRTC = attemptWebRTC;
terminal.onStateChanged = onTerminalStateChange; terminal.onStateChanged = onTerminalStateChange;
terminal.onConsoleMessageChange = function () { terminal.onConsoleMessageChange = function () {
console.log('terminal.consoleMessage', terminal.consoleMessage);
p12clearConsoleMsg(); p12clearConsoleMsg();
if (terminal.consoleMessage) { if (terminal.consoleMessage) {
QH('p12TermConsoleMsg', EscapeHtml(terminal.consoleMessage).split('\n').join('<br />')); QH('p12TermConsoleMsg', EscapeHtml(terminal.consoleMessage).split('\n').join('<br />'));
@ -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 autoConnectFiles(e) { if (autoConnectFilesTimer == null) { autoConnectFilesTimer = setInterval(connectFiles, 100); } else { clearInterval(autoConnectFilesTimer); autoConnectFilesTimer = null; } }
function connectFiles(e) { function connectFiles(e) {
p13clearConsoleMsg();
if (!files) { if (!files) {
// Setup a mesh agent files // Setup a mesh agent files
files = CreateAgentRedirect(meshserver, CreateRemoteFiles(p13gotFiles), serverPublicNamePort, authCookie, domainUrl); files = CreateAgentRedirect(meshserver, CreateRemoteFiles(p13gotFiles), serverPublicNamePort, authCookie, domainUrl);

View File

@ -2861,9 +2861,15 @@
flag = Q('aginsSelect').value; flag = Q('aginsSelect').value;
if (parseInt(flag) >= 5) { name = name.toLowerCase(); } else { name += '.exe'; } if (parseInt(flag) >= 5) { name = name.toLowerCase(); } else { name += '.exe'; }
} }
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) { } try { xdr = new XDomainRequest(); } catch (e) { }
if (!xdr) xdr = new XMLHttpRequest(); if (!xdr) xdr = new XMLHttpRequest();
xdr.open("GET", window.location.href + path + flag); xdr.open("GET", window.location.origin + '/' + path + flag);
xdr.timeout = 15000; xdr.timeout = 15000;
xdr.responseType = "blob"; xdr.responseType = "blob";
xdr.onprogress = function (x) { /*console.log(x);*/ }; xdr.onprogress = function (x) { /*console.log(x);*/ };
@ -2872,6 +2878,7 @@
xdr.ontimeout = function () { if (xxdialogTag == 'fileDownload') { setDialogMode(0); } alert('Unable to download agent.'); }; xdr.ontimeout = function () { if (xxdialogTag == 'fileDownload') { setDialogMode(0); } alert('Unable to download agent.'); };
xdr.send(); xdr.send();
} }
}
function addAgentToMeshClick() { function addAgentToMeshClick() {
var v = Q('aginsSelect').value; var v = Q('aginsSelect').value;
@ -3999,6 +4006,11 @@
// Update the web page title // Update the web page title
if ((currentNode) && (xxcurrentView >= 10) && (xxcurrentView < 20)) { document.title = decodeURIComponent("{{{extitle}}}") + ' - ' + currentNode.name; } else { document.title = decodeURIComponent("{{{extitle}}}"); } 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. setupDesktop(); // Always refresh the desktop, even if we are on the same device, we need to do some canvas switching.
if (!panel) panel = 10; if (!panel) panel = 10;
@ -4481,6 +4493,7 @@
function autoConnectDesktop(e) { if (autoConnectDesktopTimer == null) { autoConnectDesktopTimer = setInterval(connectDesktop, 100); } else { clearInterval(autoConnectDesktopTimer); autoConnectDesktopTimer = null; } } function autoConnectDesktop(e) { if (autoConnectDesktopTimer == null) { autoConnectDesktopTimer = setInterval(connectDesktop, 100); } else { clearInterval(autoConnectDesktopTimer); autoConnectDesktopTimer = null; } }
function connectDesktop(e, contype) { function connectDesktop(e, contype) {
p11clearConsoleMsg();
if (desktop == null) { if (desktop == null) {
desktopNode = currentNode; desktopNode = currentNode;
if (contype == 2) { if (contype == 2) {
@ -5074,6 +5087,7 @@
function autoConnectTerminal(e) { if (autoConnectTerminalTimer == null) { autoConnectTerminalTimer = setInterval(connectTerminal, 100); } else { clearInterval(autoConnectTerminalTimer); autoConnectTerminalTimer = null; } } function autoConnectTerminal(e) { if (autoConnectTerminalTimer == null) { autoConnectTerminalTimer = setInterval(connectTerminal, 100); } else { clearInterval(autoConnectTerminalTimer); autoConnectTerminalTimer = null; } }
function connectTerminal(e, contype) { function connectTerminal(e, contype) {
p12clearConsoleMsg();
if (!terminal) { if (!terminal) {
if (contype == 2) { if (contype == 2) {
// Setup the Intel AMT terminal // Setup the Intel AMT terminal
@ -5108,7 +5122,6 @@
terminal.attemptWebRTC = attemptWebRTC; terminal.attemptWebRTC = attemptWebRTC;
terminal.onStateChanged = onTerminalStateChange; terminal.onStateChanged = onTerminalStateChange;
terminal.onConsoleMessageChange = function () { terminal.onConsoleMessageChange = function () {
console.log('terminal.consoleMessage', terminal.consoleMessage);
p12clearConsoleMsg(); p12clearConsoleMsg();
if (terminal.consoleMessage) { if (terminal.consoleMessage) {
QH('p12TermConsoleMsg', EscapeHtml(terminal.consoleMessage).split('\n').join('<br />')); QH('p12TermConsoleMsg', EscapeHtml(terminal.consoleMessage).split('\n').join('<br />'));
@ -5230,6 +5243,7 @@
function autoConnectFiles(e) { if (autoConnectFilesTimer == null) { autoConnectFilesTimer = setInterval(connectFiles, 100); } else { clearInterval(autoConnectFilesTimer); autoConnectFilesTimer = null; } } function autoConnectFiles(e) { if (autoConnectFilesTimer == null) { autoConnectFilesTimer = setInterval(connectFiles, 100); } else { clearInterval(autoConnectFilesTimer); autoConnectFilesTimer = null; } }
function connectFiles(e) { function connectFiles(e) {
p13clearConsoleMsg();
if (!files) { if (!files) {
// Setup a mesh agent files // Setup a mesh agent files
files = CreateAgentRedirect(meshserver, CreateRemoteFiles(p13gotFiles), serverPublicNamePort, authCookie, domainUrl); files = CreateAgentRedirect(meshserver, CreateRemoteFiles(p13gotFiles), serverPublicNamePort, authCookie, domainUrl);