Added Intel AMT device import to AMT-only device group.

This commit is contained in:
Ylian Saint-Hilaire 2021-07-02 16:36:02 -07:00
parent b949fb6346
commit 148fe804bb
4 changed files with 952 additions and 882 deletions

View File

@ -3737,6 +3737,14 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Create the new node
nodeid = 'node/' + domain.id + '/' + buf.toString('base64').replace(/\+/g, '@').replace(/\//g, '$');
var device = { type: 'node', _id: nodeid, meshid: command.meshid, mtype: 1, icon: 1, name: command.devicename, host: command.hostname, domain: domain.id, intelamt: { user: command.amtusername, pass: command.amtpassword, tls: command.amttls } };
// Add optional feilds
if (common.validateInt(command.state, 0, 3)) { device.intelamt.state = command.state; }
if (common.validateString(command.ver, 1, 16)) { device.intelamt.ver = command.ver; }
if (common.validateString(command.hash, 1, 256)) { device.intelamt.hash = command.hash; }
if (common.validateString(command.realm, 1, 256)) { device.intelamt.realm = command.realm; }
// Save the device to the database
db.Set(device);
// Event the new node

View File

@ -36,8 +36,6 @@
"sample-config-advanced.json"
],
"dependencies": {
"archiver": "^4.0.2",
"archiver-zip-encrypted": "^1.0.10",
"body-parser": "^1.19.0",
"cbor": "~5.2.0",
"compression": "^1.7.4",
@ -45,25 +43,17 @@
"express": "^4.17.0",
"express-handlebars": "^3.1.0",
"express-ws": "^4.0.0",
"image-size": "^1.0.0",
"html-minifier": "^4.0.0",
"ipcheck": "^0.1.0",
"loadavg-windows": "^1.1.1",
"jsdom": "^16.6.0",
"minify-js": "0.0.4",
"minimist": "^1.2.0",
"mongodb": "^3.6.9",
"multiparty": "^4.2.1",
"nedb": "^1.8.0",
"node-forge": "^0.10.0",
"node-rdpjs-2": "^0.3.5",
"node-windows": "^1.0.0-beta.5",
"nodemailer": "^6.6.2",
"otplib": "^10.2.3",
"saslprep": "^1.0.3",
"ssh2": "^1.1.0",
"web-push": "^3.4.5",
"ws": "^5.2.0",
"xmldom": "^0.5.0",
"yauzl": "^2.10.0",
"yubikeyotp": "^0.2.0"
"yauzl": "^2.10.0"
},
"repository": {
"type": "git",

File diff suppressed because it is too large Load Diff

View File

@ -11121,7 +11121,7 @@
// Display list of devices in this device group
count = 0;
nodes.sort(deviceSort);
var dllist = (currentMesh.mtype == 1)?'<a onclick=meshDownloadDeviceList()><img title="' + "Download device list" + '" src="images/link4.png" /></a>':'';
var dllist = (currentMesh.mtype == 1)?'<a onclick=meshDownloadDeviceList()><img title="' + "Download device list" + '" src="images/link4.png" /></a> <a onclick=meshImportDeviceList()><img title="' + "Import device list" + '" src="images/link6.png" /></a>':'';
var y = '<table style="color:black;background-color:#EEE;border-color:#AAA;border-width:1px;border-style:solid;border-collapse:collapse" border=0 cellpadding=2 cellspacing=0 width=100%><tbody><tr style=background-color:#AAAAAA;font-weight:bold><th scope=col style=text-align:left;width:430px>' + "Devices" + '</th><th scope=col style=text-align:right>' + dllist + '</th></tr>';
for (var i in nodes) {
var node = nodes[i], gray = ((node.conn > 0)?'':' gray');
@ -11129,8 +11129,8 @@
y += '<tr style=' + (((count % 2) == 0) ? ';background-color:#DDD' : '') + '><td style=width:30%><div onclick=\'gotoDevice("' + node._id + '",10);haltEvent(event);\' style=float:left class="j' + node.icon + gray + '"></div>&nbsp;<a onclick=\'gotoDevice("' + node._id + '",10);haltEvent(event);\'>' + EscapeHtml(node.name) + '</a></div></div></td><td style=width:70%><div style=float:right>' + PowerStateStr(node.pwr) + '&nbsp;</div><div>' + (node.osdesc ? EscapeHtml(node.osdesc) : '') + '</div></td></tr>';
++count;
}
if (count == 0) { y += '<tr><td><i>' + "None " + '</i></td></tr>'; }
y += '</tbody></table>';
if (count == 0) { y = ''; }
// If we are full administrator on this mesh, allow deletion of the mesh
if (meshrights == 0xFFFFFFFF) {
@ -11169,6 +11169,43 @@
saveAs(stringToUtf8BlobNoHeader(JSON.stringify(r, null, 2)), currentMesh.name + ".json");
}
// Import a list of devices into the Intel AMT only device group
function meshImportDeviceList() {
if (xxdialogMode) return;
var x = "Import a list of local Intel&reg; AMT devices in MeshCommander JSON format." + '<br /><br /><input style=width:370px type=file id=d4importFile accept=".json" onchange=meshImportDeviceListValidate() />';
setDialogMode(2, "Import Intel&reg; AMT Devices", 3, meshImportDeviceListEx, x);
QE('idx_dlgOkButton', false);
}
function meshImportDeviceListValidate() {
QE('idx_dlgOkButton', Q('d4importFile').value != null);
}
function meshImportDeviceListEx() {
var fr = new FileReader();
fr.onload = function (r) {
var j = null;
try { j = JSON.parse(r.target.result); } catch (ex) { setDialogMode(2, "Import Intel&reg; AMT Devices", 1, null, format("Invalid JSON file: {0}.", ex)); return; }
if ((typeof j == 'object') && (typeof j.webappversion == 'string') && (typeof j.computers == 'object') && (Array.isArray(j.computers))) {
var ok = 0;
for (var k in j.computers) {
var computer = j.computers[k];
if ((typeof computer.name == 'string') && (typeof computer.host == 'string') && (typeof computer.user == 'string') && (typeof computer.pass == 'string')) {
var cmd = { action: 'addamtdevice', meshid: currentMesh._id, devicename: computer.name, hostname: computer.host, amtusername: computer.user, amtpassword: computer.pass, amttls: (computer.tls == 1)?1:0 };
if (typeof computer.ver == 'string') { cmd.ver = computer.ver; }
if (typeof computer.pstate == 'number') { cmd.state = computer.pstate; }
if (typeof computer.digestrealm == 'string') { cmd.realm = computer.digestrealm; }
if (typeof computer.tlscerthash == 'string') { cmd.hash = computer.tlscerthash; }
meshserver.send(cmd);
ok++;
}
}
if (ok == 0) { setDialogMode(2, "User Account Import", 1, null, "Unable to import any device."); }
} else { setDialogMode(2, "Import Intel&reg; AMT Devices", 1, null, "Invalid JSON file format."); }
};
fr.readAsText(Q('d4importFile').files[0]);
}
function p20editMeshAmt() {
if (xxdialogMode) return;
var x = '', acmoption = '';