mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-23 21:55:52 -05:00
Added newAccountEmailDomains, more server fixes.
This commit is contained in:
parent
a28568f270
commit
c7adcebded
@ -37,6 +37,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
||||
obj.agentCoreCheck = 0;
|
||||
obj.agentInfo = null;
|
||||
obj.agentUpdate = null;
|
||||
obj.agentCoreUpdatePending = false;
|
||||
const agentUpdateBlockSize = 65520;
|
||||
obj.remoteaddr = req.ip;
|
||||
if (obj.remoteaddr.startsWith('::ffff:')) { obj.remoteaddr = obj.remoteaddr.substring(7); }
|
||||
@ -149,7 +150,9 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
||||
//obj.parent.parent.debug(1, 'Updating code ' + corename);
|
||||
|
||||
// Update new core with task limiting so not to flood the server. This is a high priority task.
|
||||
obj.agentCoreUpdatePending = true;
|
||||
obj.parent.parent.taskLimiter.launch(function (argument, taskid, taskLimiterQueue) {
|
||||
obj.agentCoreUpdatePending = false;
|
||||
obj.send(obj.common.ShortToStr(10) + obj.common.ShortToStr(0) + argument.hash + argument.core, function () { obj.parent.parent.taskLimiter.completed(taskid); }); // MeshCommand_CoreModule, start core update
|
||||
obj.parent.parent.debug(1, 'Updating code ' + argument.name);
|
||||
agentCoreIsStable();
|
||||
|
20
meshuser.js
20
meshuser.js
@ -462,7 +462,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
|
||||
switch (cmd) {
|
||||
case 'help': {
|
||||
r = 'Available commands: help, args, resetserver, showconfig, usersessions, tasklimiter, cores.';
|
||||
r = 'Available commands: help, args, resetserver, showconfig, usersessions, tasklimiter, setmaxtasks, cores.';
|
||||
break;
|
||||
}
|
||||
case 'args': {
|
||||
@ -489,15 +489,21 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
if (obj.parent.parent.taskLimiter != null) {
|
||||
//var obj = { maxTasks: maxTasks, maxTaskTime: (maxTaskTime * 1000), nextTaskId: 0, currentCount: 0, current: {}, pending: [[], [], []], timer: null };
|
||||
const tl = obj.parent.parent.taskLimiter;
|
||||
r += 'MaxTasks: ' + tl.maxTasks + '<br />';
|
||||
r += 'MaxTaskTime: ' + (tl.maxTaskTime / 1000) + ' seconds<br />';
|
||||
r += 'NextTaskId: ' + tl.nextTaskId + '<br />';
|
||||
r += 'CurrentCount: ' + tl.currentCount + '<br />';
|
||||
r += 'MaxTasks: ' + tl.maxTasks + ', NextTaskId: ' + tl.nextTaskId + '<br />';
|
||||
r += 'MaxTaskTime: ' + (tl.maxTaskTime / 1000) + ' seconds, Timer: ' + (tl.timer != null) + '<br />';
|
||||
var c = [];
|
||||
for (var i in tl.current) { c.push(i); }
|
||||
r += 'Current: [' + c.join(', ') + ']<br />';
|
||||
r += 'Current (' + tl.currentCount + '): [' + c.join(', ') + ']<br />';
|
||||
r += 'Pending (High/Med/Low): ' + tl.pending[0].length + ', ' + tl.pending[1].length + ', ' + tl.pending[2].length + '<br />';
|
||||
r += 'Timer: ' + (tl.timer != null) + '<br />';
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'setmaxtasks': {
|
||||
if ((args["_"].length != 1) || (parseInt(args["_"][0]) < 1) || (parseInt(args["_"][0]) > 1000)) {
|
||||
r = 'Usage: setmaxtasks [1 to 1000]';
|
||||
} else {
|
||||
obj.parent.parent.taskLimiter.maxTasks = parseInt(args["_"][0]);
|
||||
r = 'MaxTasks set to ' + obj.parent.parent.taskLimiter.maxTasks + '.';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "meshcentral",
|
||||
"version": "0.2.9-a",
|
||||
"version": "0.2.9-b",
|
||||
"keywords": [
|
||||
"Remote Management",
|
||||
"Intel AMT",
|
||||
|
20
webserver.js
20
webserver.js
@ -516,6 +516,26 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
|
||||
|
||||
if ((domain.newaccounts === 0) || (domain.newaccounts === false)) { res.sendStatus(401); return; }
|
||||
|
||||
// Check if this request is for an allows email domain
|
||||
if ((domain.newaccountemaildomains != null) && Array.isArray(domain.newaccountemaildomains)) {
|
||||
var i = -1;
|
||||
if (typeof req.body.email == 'string') { i = req.body.email.indexOf('@'); }
|
||||
if (i == -1) {
|
||||
req.session.loginmode = 2;
|
||||
req.session.error = '<b style=color:#8C001A>Unable to create account.</b>';
|
||||
res.redirect(domain.url);
|
||||
return;
|
||||
}
|
||||
var emailok = false, emaildomain = req.body.email.substring(i + 1).toLowerCase();
|
||||
for (var i in domain.newaccountemaildomains) { if (emaildomain == domain.newaccountemaildomains[i].toLowerCase()) { emailok = true; } }
|
||||
if (emailok == false) {
|
||||
req.session.loginmode = 2;
|
||||
req.session.error = '<b style=color:#8C001A>Unable to create account.</b>';
|
||||
res.redirect(domain.url);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we exceed the maximum number of user accounts
|
||||
obj.db.isMaxType(domain.limits.maxuseraccounts, 'user', domain.id, function (maxExceed) {
|
||||
if (maxExceed) {
|
||||
|
Loading…
Reference in New Issue
Block a user