fix local amt with sqlite/mysql/postgres #6321

Signed-off-by: Simon Smith <simonsmith5521@gmail.com>

Simon Smith committed Aug 13, 2024 at 17:46 UTC 77f44fc308c41647b911453aa8bda62b68c6f1e5
3 files changed +6 -6
db.js
+3 -3
@@ -1535,7 +1535,7 @@ module.exports.CreateDB = function (parent, func) {
1535 obj.SetUser = function (user) { if (user == null) return; if (user.subscriptions != null) { var u = Clone(user); if (u.subscriptions) { delete u.subscriptions; } obj.Set(u); } else { obj.Set(user); } };
1536 obj.dispose = function () { for (var x in obj) { if (obj[x].close) { obj[x].close(); } delete obj[x]; } };
1537 obj.getLocalAmtNodes = function (func) {
1538 - sqlDbQuery('SELECT doc FROM main WHERE (type = \'node\') AND (extraex IS NOT NULL)', null, function (err, docs) {
1538 + sqlDbQuery('SELECT doc FROM main WHERE (type = \'node\') AND (extraex IS NULL)', null, function (err, docs) {
1539 if (docs != null) { for (var i in docs) { if (docs[i].links != null) { docs[i] = common.unEscapeLinksFieldName(docs[i]); } } }
1540 var r = []; if (err == null) { for (var i in docs) { if (docs[i].host != null) { r.push(docs[i]); } } } func(err, r);
1541 });
@@ -2091,7 +2091,7 @@ module.exports.CreateDB = function (parent, func) {
2091 obj.DeleteDomain = function (domain, func) { sqlDbQuery('DELETE FROM main WHERE domain = $1', [domain], func); };
2092 obj.SetUser = function (user) { if (user == null) return; if (user.subscriptions != null) { var u = Clone(user); if (u.subscriptions) { delete u.subscriptions; } obj.Set(u); } else { obj.Set(user); } };
2093 obj.dispose = function () { for (var x in obj) { if (obj[x].close) { obj[x].close(); } delete obj[x]; } };
2094 - obj.getLocalAmtNodes = function (func) { sqlDbQuery('SELECT doc FROM main WHERE (type = \'node\') AND (extraex IS NOT NULL)', null, function (err, docs) { var r = []; if (err == null) { for (var i in docs) { if (docs[i].host != null) { r.push(docs[i]); } } } func(err, r); }); };
2094 + obj.getLocalAmtNodes = function (func) { sqlDbQuery('SELECT doc FROM main WHERE (type = \'node\') AND (extraex IS NULL)', null, function (err, docs) { var r = []; if (err == null) { for (var i in docs) { if (docs[i].host != null) { r.push(docs[i]); } } } func(err, r); }); };
2095 obj.getAmtUuidMeshNode = function (domainid, mtype, uuid, func) { sqlDbQuery('SELECT doc FROM main WHERE domain = $1 AND extraex = $2', [domainid, 'uuid/' + uuid], func); };
2096 obj.isMaxType = function (max, type, domainid, func) { if (max == null) { func(false); } else { sqlDbExec('SELECT COUNT(id) FROM main WHERE domain = $1 AND type = $2', [domainid, type], function (err, response) { func((response['COUNT(id)'] == null) || (response['COUNT(id)'] > max), response['COUNT(id)']) }); } }
2097
@@ -2351,7 +2351,7 @@ module.exports.CreateDB = function (parent, func) {
2351 obj.DeleteDomain = function (domain, func) { sqlDbQuery('DELETE FROM main WHERE domain = ?', [domain], func); };
2352 obj.SetUser = function (user) { if (user == null) return; if (user.subscriptions != null) { var u = Clone(user); if (u.subscriptions) { delete u.subscriptions; } obj.Set(u); } else { obj.Set(user); } };
2353 obj.dispose = function () { for (var x in obj) { if (obj[x].close) { obj[x].close(); } delete obj[x]; } };
2354 - obj.getLocalAmtNodes = function (func) { sqlDbQuery('SELECT doc FROM main WHERE (type = "node") AND (extraex IS NOT NULL)', null, function (err, docs) { var r = []; if (err == null) { for (var i in docs) { if (docs[i].host != null) { r.push(docs[i]); } } } func(err, r); }); };
2354 + obj.getLocalAmtNodes = function (func) { sqlDbQuery('SELECT doc FROM main WHERE (type = "node") AND (extraex IS NULL)', null, function (err, docs) { var r = []; if (err == null) { for (var i in docs) { if (docs[i].host != null) { r.push(docs[i]); } } } func(err, r); }); };
2355 obj.getAmtUuidMeshNode = function (domainid, mtype, uuid, func) { sqlDbQuery('SELECT doc FROM main WHERE domain = ? AND extraex = ?', [domainid, 'uuid/' + uuid], func); };
2356 obj.isMaxType = function (max, type, domainid, func) { if (max == null) { func(false); } else { sqlDbExec('SELECT COUNT(id) FROM main WHERE domain = ? AND type = ?', [domainid, type], function (err, response) { func((response['COUNT(id)'] == null) || (response['COUNT(id)'] > max), response['COUNT(id)']) }); } }
2357
meshcentral-config-schema.json
+2 -2
@@ -2225,12 +2225,12 @@
2225 "TlsConnections": {
2226 "type": "boolean",
2227 "default": true,
2228 - "description": "When set to false, MeshCentral will use TLS to connect to Intel AMT, this is not recommended."
2228 + "description": "When set to false, MeshCentral will NOT use TLS to connect to Intel AMT, this is not recommended."
2229 },
2230 "TlsAcmActivation": {
2231 "type": "boolean",
2232 "default": false,
2233 - "description": "When set to false, MeshCentral will not attempt a TLS ACM activation on Intel AMT v14+"
2233 + "description": "When set to true, MeshCentral will attempt a TLS ACM activation on Intel AMT v14+"
2234 },
2235 "AdminAccounts": {
2236 "description": "List of username and passwords to try when connecting to Intel AMT.",
views/default.handlebars
+1 -1
@@ -13700,7 +13700,7 @@
13700 p20editMeshAmtChange();
13701
13702 // Set the current Intel AMT policy
13703 - if (currentMesh.amt && (currentMesh.amt.type == 2) || (currentMesh.amt.type == 3)) {
13703 + if (currentMesh.amt && ((currentMesh.amt.type == 2) || (currentMesh.amt.type == 3))) {
13704 Q('dp20amtpolicypass').value = currentMesh.amt.password;
13705 if ((currentMesh.amt.type == 2) || (currentMesh.amt.type == 3)) {
13706 if (currentMesh.amt.badpass != null) { Q('dp20amtbadpass').value = currentMesh.amt.badpass; }