Fixed MongoDB connection string

This commit is contained in:
Ylian Saint-Hilaire 2019-07-29 18:21:52 -07:00
parent ec0047369b
commit d0737562aa
6 changed files with 7 additions and 9 deletions

3
db.js
View File

@ -211,10 +211,7 @@ module.exports.CreateDB = function (parent, func) {
Datastore = client; Datastore = client;
// Get the database name and setup the database client // Get the database name and setup the database client
var dbNamefromUrl = null;
try { dbNamefromUrl = require('url').parse(parent.args.mongodb).path.split('/')[1]; } catch (ex) { }
var dbname = 'meshcentral'; var dbname = 'meshcentral';
if (dbNamefromUrl) { dbname = dbNamefromUrl; }
if (parent.args.mongodbname) { dbname = parent.args.mongodbname; } if (parent.args.mongodbname) { dbname = parent.args.mongodbname; }
const dbcollectionname = (parent.args.mongodbcol) ? (parent.args.mongodbcol) : 'meshcentral'; const dbcollectionname = (parent.args.mongodbcol) ? (parent.args.mongodbcol) : 'meshcentral';
const db = client.db(dbname); const db = client.db(dbname);

View File

@ -1562,7 +1562,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
// Event the device group creation // Event the device group creation
var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: meshid, name: command.meshname, mtype: command.meshtype, desc: command.desc, action: 'createmesh', links: links, msg: 'Mesh created: ' + command.meshname, domain: domain.id }; var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: meshid, name: command.meshname, mtype: command.meshtype, desc: command.desc, action: 'createmesh', links: links, msg: 'Device group created: ' + command.meshname, domain: domain.id };
parent.parent.DispatchEvent(['*', meshid, user._id], obj, event); // Even if DB change stream is active, this event must be acted upon. parent.parent.DispatchEvent(['*', meshid, user._id], obj, event); // Even if DB change stream is active, this event must be acted upon.
try { ws.send(JSON.stringify({ action: 'createmesh', responseid: command.responseid, result: 'ok', meshid: meshid })); } catch (ex) { } try { ws.send(JSON.stringify({ action: 'createmesh', responseid: command.responseid, result: 'ok', meshid: meshid })); } catch (ex) { }
@ -1594,7 +1594,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
if (err != null) { if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'deletemesh', responseid: command.responseid, result: err })); } catch (ex) { } } return; } if (err != null) { if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'deletemesh', responseid: command.responseid, result: err })); } catch (ex) { } } return; }
// Fire the removal event first, because after this, the event will not route // Fire the removal event first, because after this, the event will not route
var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: command.meshid, name: command.meshname, action: 'deletemesh', msg: 'Mesh deleted: ' + command.meshname, domain: domain.id }; var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: command.meshid, name: command.meshname, action: 'deletemesh', msg: 'Device group deleted: ' + command.meshname, domain: domain.id };
parent.parent.DispatchEvent(['*', command.meshid], obj, event); // Even if DB change stream is active, this event need to be acted on. parent.parent.DispatchEvent(['*', command.meshid], obj, event); // Even if DB change stream is active, this event need to be acted on.
// Remove all user links to this mesh // Remove all user links to this mesh

View File

@ -1,6 +1,6 @@
{ {
"name": "meshcentral", "name": "meshcentral",
"version": "0.3.8-t", "version": "0.3.8-u",
"keywords": [ "keywords": [
"Remote Management", "Remote Management",
"Intel AMT", "Intel AMT",

View File

@ -2,7 +2,8 @@
"__comment__" : "This is a sample configuration file, edit a section and remove the _ in front of the name. Refer to the user's guide for details.", "__comment__" : "This is a sample configuration file, edit a section and remove the _ in front of the name. Refer to the user's guide for details.",
"settings": { "settings": {
"_Cert": "myserver.mydomain.com", "_Cert": "myserver.mydomain.com",
"_MongoDb": "mongodb://127.0.0.1:27017/meshcentral", "_MongoDb": "mongodb://127.0.0.1:27017",
"_MongoDbName": "meshcentral",
"_MongoDbChangeStream": true, "_MongoDbChangeStream": true,
"_WANonly": true, "_WANonly": true,
"_LANonly": true, "_LANonly": true,

File diff suppressed because one or more lines are too long

View File

@ -2096,7 +2096,7 @@
break; break;
} }
default: default:
console.log('Unknown message.action', message.action); //console.log('Unknown message.action', message.action);
break; break;
} }
} }