Minor bug fixes

This commit is contained in:
Ylian Saint-Hilaire 2018-05-02 16:19:45 -07:00
parent 6c593da7ff
commit 08e6a4302e
4 changed files with 58 additions and 18 deletions

View File

@ -474,10 +474,35 @@ function CreateMeshCentralServer(config, args) {
if (restoreFile) {
obj.debug(1, 'Server stopped, updating settings: ' + restoreFile);
console.log('Updating settings folder...');
/*
var unzip = require('unzip');
var rs = obj.fs.createReadStream(restoreFile);
rs.on('end', () => { setTimeout(function () { fs.unlinkSync(restoreFile); process.exit(123); }, 500); });
rs.pipe(unzip.Extract({ path: obj.datapath }));
*/
var yauzl = require("yauzl");
yauzl.open(restoreFile, { lazyEntries: true }, function (err, zipfile) {
if (err) throw err;
zipfile.readEntry();
zipfile.on("entry", function (entry) {
if (/\/$/.test(entry.fileName)) {
// Directory file names end with '/'.
// Note that entires for directories themselves are optional.
// An entry's fileName implicitly requires its parent directories to exist.
zipfile.readEntry();
} else {
// file entry
zipfile.openReadStream(entry, function (err, readStream) {
if (err) throw err;
readStream.on("end", function () { zipfile.readEntry(); });
// console.log('Extracting:', obj.path.join(obj.datapath, entry.fileName));
readStream.pipe(obj.fs.createWriteStream(obj.path.join(obj.datapath, entry.fileName)));
});
}
});
zipfile.on("end", function () { setTimeout(function () { fs.unlinkSync(restoreFile); process.exit(123); }); });
});
} else {
obj.debug(1, 'Server stopped');
process.exit(0);
@ -1124,7 +1149,7 @@ function mainStart(args) {
if (config == null) { process.exit(); }
// Build the list of required modules
var modules = ['ws', 'nedb', 'https', 'unzip', 'xmldom', 'express', 'archiver', 'multiparty', 'node-forge', 'express-ws', 'compression', 'body-parser', 'connect-redis', 'express-session', 'express-handlebars'];
var modules = ['ws', 'nedb', 'https', 'yauzl', 'xmldom', 'express', 'archiver', 'multiparty', 'node-forge', 'express-ws', 'compression', 'body-parser', 'connect-redis', 'express-session', 'express-handlebars'];
if (require('os').platform() == 'win32') { modules.push('node-sspi'); modules.push('node-windows'); } // Add Windows modules
if (config.letsencrypt != null) { modules.push('greenlock'); modules.push('le-store-certbot'); modules.push('le-challenge-fs'); modules.push('le-acme-core'); } // Add Greenlock Modules
if (config.settings.mongodb != null) { modules.push('mongojs'); } // Add MongoDB

View File

@ -542,7 +542,7 @@ module.exports.CreateMpsServer = function (parent, db, args, certificates) {
// Disconnect CIRA tunnel
obj.close = function (socket) {
try { socket.close(); } catch (e) { }
try { socket.end(); } catch (e) { }
try { delete obj.ciraConnections[socket.tag.nodeid]; } catch (e) { }
obj.parent.ClearConnectivityState(socket.tag.meshid, socket.tag.nodeid, 2);
}

View File

@ -1,6 +1,6 @@
{
"name": "meshcentral",
"version": "0.1.7-c",
"version": "0.1.7-g",
"keywords": [
"Remote Management",
"Intel AMT",
@ -39,10 +39,14 @@
"multiparty": "^4.1.3",
"nedb": "^1.8.0",
"node-forge": "^0.6.49",
"unzip": "^0.1.11",
"ws": "^3.3.3",
"xmldom": "^0.1.27"
"xmldom": "^0.1.27",
"yauzl": "^2.9.1"
},
"devDependencies": { },
"repository": {
"type": "git",
"url": "https://github.com/Ylianst/MeshCentral.git"
},
"devDependencies": {},
"readme": "readme.txt"
}

View File

@ -1600,7 +1600,7 @@
}
// If there is nothing to display, explain the problem
if (r == '') {
if ((r == '') && (meshcount > 0)) {
if ((Q('SearchInput').value == '') && (sort == 3)) {
r = '<div style="margin:30px">No devices are included in any groups, click on a device\'s \"Groups\" to add to a group.</div>';
} else {
@ -2114,18 +2114,29 @@
function onConsoleFocus(x) { consoleFocus = x; }
function onSearchInputChanged() {
var x = Q('SearchInput').value.toLowerCase();
putstore("search", x);
if (x == '') { for (var d in nodes) { nodes[d].v = true; } }
else {
var x = Q('SearchInput').value.toLowerCase().trim(); putstore("search", x);
if (x == '') {
for (var d in nodes) { nodes[d].v = true; }
} else {
var rs = x.split(/\s+/).join('|'), rx = new RegExp(rs);
for (var d in nodes) {
nodes[d].v = (nodes[d].name.toLowerCase().indexOf(x) >= 0) || (nodes[d].hostl != null && nodes[d].hostl.toLowerCase().indexOf(x) >= 0);
if (nodes[d].tags) { for (var s in nodes[d].tags) { if (nodes[d].tags[s].toLowerCase().indexOf(x) >= 0) { nodes[d].v = true; break; } } }
nodes[d].v = (rx.test(nodes[d].name.toLowerCase())) || (nodes[d].hostl != null && rx.test(nodes[d].hostl.toLowerCase()));
if ((nodes[d].v == false) && nodes[d].tags) {
for (var s in nodes[d].tags) {
if (rx.test(nodes[d].tags[s].toLowerCase())) {
nodes[d].v = true;
break;
} else {
nodes[d].v = false;
}
}
}
}
}
updateDevices();
}
var contextelement = null;
function handleContextMenu(event) {
hideContextMenu();
@ -2477,7 +2488,7 @@
// TODO: Add more connection status types. Currently we only change color if connection status changes
function connStateColor(nodeConn){
if (nodeConn.conn == 1 || nodeConn.conn == 5) { return '#00ffdd'; } // Green for connected devices
if (nodeConn.conn == 1 || nodeConn.conn == 3 || nodeConn.conn == 5) { return '#00ffdd'; } // Green for connected devices
return '#C70039'; // Red if the Agent is not connected
}
@ -3038,9 +3049,9 @@
// Called when MeshCommander needs new credentials or updated credentials.
function updateAmtCredentials(forceDialog) {
var node = getNodeFromId(desktopNode._id);
var node = getNodeFromId(currentNode._id);
if ((forceDialog == true) || (node.intelamt.user == null) || (node.intelamt.user == '')) {
editDeviceAmtSettings(desktopNode._id, updateAmtCredentialsEx);
editDeviceAmtSettings(currentNode._id, updateAmtCredentialsEx);
} else {
Q('p14iframe').contentWindow.connectButtonfunctionEx();
}
@ -3364,7 +3375,7 @@
// Show the right buttons
QV('disconnectbutton1span', (deskState != 0));
QV('connectbutton1span', (deskState == 0) && (mesh.mtype == 2));
QV('connectbutton1hspan', (deskState == 0) && ((currentNode.intelamt != null) && (currentNode.intelamt.state == 2) && ((currentNode.intelamt.ver != null) || (mesh.mtype == 1))));
QV('connectbutton1hspan', (deskState == 0) && ((currentNode.intelamt != null) && (mesh.mtype == 1 || currentNode.intelamt.state == 2) && ((currentNode.intelamt.ver != null) || (mesh.mtype == 1))));
// Show the right settings
QV('d7amtkvm', (currentNode.intelamt != null && ((currentNode.intelamt.ver != null) || (mesh.mtype == 1))) && ((deskState == 0) || (desktop.contype == 2)));
@ -3691,7 +3702,7 @@
// Show the right buttons
QV('disconnectbutton2span', (termState == true));
QV('connectbutton2span', (termState == false) && (mesh.mtype == 2));
QV('connectbutton2hspan', (termState == false) && ((terminalNode.intelamt != null) && (terminalNode.intelamt.state == 2) && ((terminalNode.intelamt.ver != null) || (mesh.mtype == 1))));
QV('connectbutton2hspan', (termState == false) && ((terminalNode.intelamt != null) && (mesh.mtype == 1 || terminalNode.intelamt.state == 2) && ((terminalNode.intelamt.ver != null) || (mesh.mtype == 1))));
// Enable buttons
var online = ((terminalNode.conn & 1) != 0); // If Agent (1) connected, enable Terminal