Minor bug fixes
Ylian Saint-Hilaire committed
May 2, 2018 at 16:19 UTC
08e6a4302e8410a49900aa47141e779dc2b83aa5
4 files changed
+58
-18
meshcentral.js
+26
-1
@@ -474,10 +474,35 @@ function CreateMeshCentralServer(config, args) {
474
if (restoreFile) {
475
obj.debug(1, 'Server stopped, updating settings: ' + restoreFile);
476
console.log('Updating settings folder...');
477
+ /*
478
var unzip = require('unzip');
479
var rs = obj.fs.createReadStream(restoreFile);
480
rs.on('end', () => { setTimeout(function () { fs.unlinkSync(restoreFile); process.exit(123); }, 500); });
481
rs.pipe(unzip.Extract({ path: obj.datapath }));
482
+ */
483
+
484
+ var yauzl = require("yauzl");
485
+ yauzl.open(restoreFile, { lazyEntries: true }, function (err, zipfile) {
486
+ if (err) throw err;
487
+ zipfile.readEntry();
488
+ zipfile.on("entry", function (entry) {
489
+ if (/\/$/.test(entry.fileName)) {
490
+ // Directory file names end with '/'.
491
+ // Note that entires for directories themselves are optional.
492
+ // An entry's fileName implicitly requires its parent directories to exist.
493
+ zipfile.readEntry();
494
+ } else {
495
+ // file entry
496
+ zipfile.openReadStream(entry, function (err, readStream) {
497
+ if (err) throw err;
498
+ readStream.on("end", function () { zipfile.readEntry(); });
499
+ // console.log('Extracting:', obj.path.join(obj.datapath, entry.fileName));
500
+ readStream.pipe(obj.fs.createWriteStream(obj.path.join(obj.datapath, entry.fileName)));
501
+ });
502
+ }
503
+ });
504
+ zipfile.on("end", function () { setTimeout(function () { fs.unlinkSync(restoreFile); process.exit(123); }); });
505
+ });
506
} else {
507
obj.debug(1, 'Server stopped');
508
process.exit(0);
@@ -1124,7 +1149,7 @@ function mainStart(args) {
1149
if (config == null) { process.exit(); }
1150
1151
// Build the list of required modules
1127
- var modules = ['ws', 'nedb', 'https', 'unzip', 'xmldom', 'express', 'archiver', 'multiparty', 'node-forge', 'express-ws', 'compression', 'body-parser', 'connect-redis', 'express-session', 'express-handlebars'];
1152
+ var modules = ['ws', 'nedb', 'https', 'yauzl', 'xmldom', 'express', 'archiver', 'multiparty', 'node-forge', 'express-ws', 'compression', 'body-parser', 'connect-redis', 'express-session', 'express-handlebars'];
1153
if (require('os').platform() == 'win32') { modules.push('node-sspi'); modules.push('node-windows'); } // Add Windows modules
1154
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
1155
if (config.settings.mongodb != null) { modules.push('mongojs'); } // Add MongoDB
mpsserver.js
+1
-1
@@ -542,7 +542,7 @@ module.exports.CreateMpsServer = function (parent, db, args, certificates) {
542
543
// Disconnect CIRA tunnel
544
obj.close = function (socket) {
545
- try { socket.close(); } catch (e) { }
545
+ try { socket.end(); } catch (e) { }
546
try { delete obj.ciraConnections[socket.tag.nodeid]; } catch (e) { }
547
obj.parent.ClearConnectivityState(socket.tag.meshid, socket.tag.nodeid, 2);
548
}
package.json
+8
-4
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.1.7-c",
3
+ "version": "0.1.7-g",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",
@@ -39,10 +39,14 @@
39
"multiparty": "^4.1.3",
40
"nedb": "^1.8.0",
41
"node-forge": "^0.6.49",
42
- "unzip": "^0.1.11",
42
"ws": "^3.3.3",
44
- "xmldom": "^0.1.27"
43
+ "xmldom": "^0.1.27",
44
+ "yauzl": "^2.9.1"
45
+ },
46
+ "devDependencies": { },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "https://github.com/Ylianst/MeshCentral.git"
50
},
46
- "devDependencies": {},
51
"readme": "readme.txt"
52
}
views/default.handlebars
+23
-12
@@ -1600,7 +1600,7 @@
1600
}
1601
1602
// If there is nothing to display, explain the problem
1603
- if (r == '') {
1603
+ if ((r == '') && (meshcount > 0)) {
1604
if ((Q('SearchInput').value == '') && (sort == 3)) {
1605
r = '<div style="margin:30px">No devices are included in any groups, click on a device\'s \"Groups\" to add to a group.</div>';
1606
} else {
@@ -2114,18 +2114,29 @@
2114
function onConsoleFocus(x) { consoleFocus = x; }
2115
2116
function onSearchInputChanged() {
2117
- var x = Q('SearchInput').value.toLowerCase();
2118
- putstore("search", x);
2119
- if (x == '') { for (var d in nodes) { nodes[d].v = true; } }
2120
- else {
2117
+ var x = Q('SearchInput').value.toLowerCase().trim(); putstore("search", x);
2118
+ if (x == '') {
2119
+ for (var d in nodes) { nodes[d].v = true; }
2120
+ } else {
2121
+ var rs = x.split(/\s+/).join('|'), rx = new RegExp(rs);
2122
for (var d in nodes) {
2122
- nodes[d].v = (nodes[d].name.toLowerCase().indexOf(x) >= 0) || (nodes[d].hostl != null && nodes[d].hostl.toLowerCase().indexOf(x) >= 0);
2123
- 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; } } }
2123
+ nodes[d].v = (rx.test(nodes[d].name.toLowerCase())) || (nodes[d].hostl != null && rx.test(nodes[d].hostl.toLowerCase()));
2124
+ if ((nodes[d].v == false) && nodes[d].tags) {
2125
+ for (var s in nodes[d].tags) {
2126
+ if (rx.test(nodes[d].tags[s].toLowerCase())) {
2127
+ nodes[d].v = true;
2128
+ break;
2129
+ } else {
2130
+ nodes[d].v = false;
2131
+ }
2132
+ }
2133
+ }
2134
}
2135
}
2136
updateDevices();
2137
}
2138
2139
+
2140
var contextelement = null;
2141
function handleContextMenu(event) {
2142
hideContextMenu();
@@ -2477,7 +2488,7 @@
2488
2489
// TODO: Add more connection status types. Currently we only change color if connection status changes
2490
function connStateColor(nodeConn){
2480
- if (nodeConn.conn == 1 || nodeConn.conn == 5) { return '#00ffdd'; } // Green for connected devices
2491
+ if (nodeConn.conn == 1 || nodeConn.conn == 3 || nodeConn.conn == 5) { return '#00ffdd'; } // Green for connected devices
2492
return '#C70039'; // Red if the Agent is not connected
2493
}
2494
@@ -3038,9 +3049,9 @@
3049
3050
// Called when MeshCommander needs new credentials or updated credentials.
3051
function updateAmtCredentials(forceDialog) {
3041
- var node = getNodeFromId(desktopNode._id);
3052
+ var node = getNodeFromId(currentNode._id);
3053
if ((forceDialog == true) || (node.intelamt.user == null) || (node.intelamt.user == '')) {
3043
- editDeviceAmtSettings(desktopNode._id, updateAmtCredentialsEx);
3054
+ editDeviceAmtSettings(currentNode._id, updateAmtCredentialsEx);
3055
} else {
3056
Q('p14iframe').contentWindow.connectButtonfunctionEx();
3057
}
@@ -3364,7 +3375,7 @@
3375
// Show the right buttons
3376
QV('disconnectbutton1span', (deskState != 0));
3377
QV('connectbutton1span', (deskState == 0) && (mesh.mtype == 2));
3367
- QV('connectbutton1hspan', (deskState == 0) && ((currentNode.intelamt != null) && (currentNode.intelamt.state == 2) && ((currentNode.intelamt.ver != null) || (mesh.mtype == 1))));
3378
+ QV('connectbutton1hspan', (deskState == 0) && ((currentNode.intelamt != null) && (mesh.mtype == 1 || currentNode.intelamt.state == 2) && ((currentNode.intelamt.ver != null) || (mesh.mtype == 1))));
3379
3380
// Show the right settings
3381
QV('d7amtkvm', (currentNode.intelamt != null && ((currentNode.intelamt.ver != null) || (mesh.mtype == 1))) && ((deskState == 0) || (desktop.contype == 2)));
@@ -3691,7 +3702,7 @@
3702
// Show the right buttons
3703
QV('disconnectbutton2span', (termState == true));
3704
QV('connectbutton2span', (termState == false) && (mesh.mtype == 2));
3694
- QV('connectbutton2hspan', (termState == false) && ((terminalNode.intelamt != null) && (terminalNode.intelamt.state == 2) && ((terminalNode.intelamt.ver != null) || (mesh.mtype == 1))));
3705
+ QV('connectbutton2hspan', (termState == false) && ((terminalNode.intelamt != null) && (mesh.mtype == 1 || terminalNode.intelamt.state == 2) && ((terminalNode.intelamt.ver != null) || (mesh.mtype == 1))));
3706
3707
// Enable buttons
3708
var online = ((terminalNode.conn & 1) != 0); // If Agent (1) connected, enable Terminal